From 3319fc1c45a8e81341c80b37a2cc73dadc379076 Mon Sep 17 00:00:00 2001 From: chrisly42 Date: Tue, 20 Jul 2021 14:25:41 +0200 Subject: [PATCH] Fixed compatibility with older IntelliJ versions. Minimum version now 2019.3.5, though. Converted a few missing files from Java to Kotlin. --- README.md | 4 +- build.gradle | 4 +- .../plugins/m68k/M68kFileElementType.kt | 49 +++++------ .../intellij/plugins/m68k/M68kFileType.kt | 3 +- .../plugins/m68k/M68kStringQuoteHandler.kt | 12 +-- .../m68k/parser/M68kParserDefinition.kt | 82 ++++++------------- .../plugins/m68k/parser/M68kParserUtilBase.kt | 8 +- .../m68k/syntax/M68kColorSettingsPage.kt | 3 +- src/main/resources/META-INF/plugin.xml | 4 +- 9 files changed, 62 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index ee95b81..c6f13ad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# MC68000 Assembly Language Plugin [![Build Status](https://travis-ci.com/chrisly42/mc68000-asm-plugin.svg?branch=master)](https://travis-ci.com/chrisly42/mc68000-asm-plugin) [![Coverage Status](https://coveralls.io/repos/github/chrisly42/mc68000-asm-plugin/badge.svg?branch=master)](https://coveralls.io/github/chrisly42/mc68000-asm-plugin?branch=master) +# MC68000 Assembly Language Plugin [![Build Status](https://travis-ci.com/chrisly42/mc68000-asm-plugin.svg?branch=main)](https://travis-ci.com/chrisly42/mc68000-asm-plugin) [![Coverage Status](https://coveralls.io/repos/github/chrisly42/mc68000-asm-plugin/badge.svg?branch=main)](https://coveralls.io/github/chrisly42/mc68000-asm-plugin?branch=main) _MC68000 Assembly Language Plugin_ is plugin for Jetbrains IDEs (CLion, IntelliJ, etc.). @@ -67,4 +67,4 @@ make it work with JUnit 5. Feel free to use the code (in package ```de.platon42. ### V0.1 (20-Jun-21) -- Initial release. \ No newline at end of file +- Initial public release. \ No newline at end of file diff --git a/build.gradle b/build.gradle index 80c1296..856be9c 100644 --- a/build.gradle +++ b/build.gradle @@ -46,9 +46,9 @@ intellij { patchPluginXml { setChangeNotes(""" -

V0.1 (xx-Jun-21)

+

V0.1 (20-Jun-21)

Full changelog available at Github project site.

""") diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt b/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt index 36ff2ed..7153b05 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt @@ -1,36 +1,27 @@ -package de.platon42.intellij.plugins.m68k; +package de.platon42.intellij.plugins.m68k -import com.intellij.psi.PsiFile; -import com.intellij.psi.StubBuilder; -import com.intellij.psi.stubs.DefaultStubBuilder; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.tree.IStubFileElementType; -import de.platon42.intellij.plugins.m68k.psi.M68kFile; -import de.platon42.intellij.plugins.m68k.stubs.M68kFileStub; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.PsiFile +import com.intellij.psi.stubs.DefaultStubBuilder +import com.intellij.psi.stubs.StubElement +import com.intellij.psi.tree.IStubFileElementType +import de.platon42.intellij.plugins.m68k.psi.M68kFile +import de.platon42.intellij.plugins.m68k.stubs.M68kFileStub -public class M68kFileElementType extends IStubFileElementType { - public static final IStubFileElementType INSTANCE = new M68kFileElementType(); - public static final int VERSION = 1; +class M68kFileElementType private constructor() : IStubFileElementType("MC68000_FILE", MC68000Language.INSTANCE) { - private M68kFileElementType() { - super("MC68000_FILE", MC68000Language.Companion.getINSTANCE()); + companion object { + @JvmField + val INSTANCE = M68kFileElementType() + + const val STUB_VERSION = 1 } - @Override - public int getStubVersion() { - return VERSION; - } + override fun getStubVersion() = STUB_VERSION - @Override - public StubBuilder getBuilder() { - return new DefaultStubBuilder() { - - @Override - protected @NotNull StubElement createStubForFile(@NotNull PsiFile file) { - if (file instanceof M68kFile) return new M68kFileStub((M68kFile) file); - return super.createStubForFile(file); + override fun getBuilder() = + object : DefaultStubBuilder() { + override fun createStubForFile(file: PsiFile): StubElement<*> { + return if (file is M68kFile) M68kFileStub(file) else super.createStubForFile(file) } - }; - } -} + } +} \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileType.kt b/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileType.kt index fc614f7..f1ca559 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileType.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileType.kt @@ -5,8 +5,7 @@ import de.platon42.intellij.plugins.m68k.M68kIcons.FILE import org.jetbrains.annotations.NonNls import javax.swing.Icon -@Suppress("unused") -class M68kFileType private constructor() : LanguageFileType(MC68000Language.INSTANCE, false) { +class M68kFileType private constructor() : LanguageFileType(MC68000Language.INSTANCE) { @NonNls override fun getName(): String { return "MC68000 Assembler" diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/M68kStringQuoteHandler.kt b/src/main/java/de/platon42/intellij/plugins/m68k/M68kStringQuoteHandler.kt index 7e53eab..93bcacc 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/M68kStringQuoteHandler.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/M68kStringQuoteHandler.kt @@ -1,10 +1,6 @@ -package de.platon42.intellij.plugins.m68k; +package de.platon42.intellij.plugins.m68k -import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler; -import de.platon42.intellij.plugins.m68k.psi.M68kTypes; +import com.intellij.codeInsight.editorActions.SimpleTokenSetQuoteHandler +import de.platon42.intellij.plugins.m68k.psi.M68kTypes -public class M68kStringQuoteHandler extends SimpleTokenSetQuoteHandler { - public M68kStringQuoteHandler() { - super(M68kTypes.STRINGLIT); - } -} +class M68kStringQuoteHandler : SimpleTokenSetQuoteHandler(M68kTypes.STRINGLIT) \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserDefinition.kt b/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserDefinition.kt index bbbc235..a358be4 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserDefinition.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserDefinition.kt @@ -1,68 +1,40 @@ -package de.platon42.intellij.plugins.m68k.parser; +package de.platon42.intellij.plugins.m68k.parser -import com.intellij.lang.ASTNode; -import com.intellij.lang.ParserDefinition; -import com.intellij.lang.PsiParser; -import com.intellij.lexer.Lexer; -import com.intellij.openapi.project.Project; -import com.intellij.psi.FileViewProvider; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.tree.IFileElementType; -import com.intellij.psi.tree.TokenSet; -import de.platon42.intellij.plugins.m68k.M68kFileElementType; -import de.platon42.intellij.plugins.m68k.lexer.M68kLexer; -import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs; -import de.platon42.intellij.plugins.m68k.psi.M68kFile; -import de.platon42.intellij.plugins.m68k.psi.M68kTypes; -import org.jetbrains.annotations.NotNull; +import com.intellij.lang.ASTNode +import com.intellij.lang.ParserDefinition +import com.intellij.lexer.Lexer +import com.intellij.openapi.project.Project +import com.intellij.psi.FileViewProvider +import com.intellij.psi.tree.TokenSet +import de.platon42.intellij.plugins.m68k.M68kFileElementType +import de.platon42.intellij.plugins.m68k.lexer.M68kLexer +import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs +import de.platon42.intellij.plugins.m68k.psi.M68kFile +import de.platon42.intellij.plugins.m68k.psi.M68kTypes -public class M68kParserDefinition implements ParserDefinition { - public static final TokenSet STRING_LITERALS = TokenSet.create(M68kTypes.STRINGLIT); - public static final TokenSet COMMENTS = TokenSet.create(M68kTypes.COMMENT); +class M68kParserDefinition : ParserDefinition { - private M68kLexerPrefs lexerPrefs = new M68kLexerPrefs(); // TODO make this configurable + val lexerPrefs = M68kLexerPrefs() // TODO make this configurable - public M68kParserDefinition() { - } - - public M68kLexerPrefs getLexerPrefs() { - return lexerPrefs; - } - - @Override - public @NotNull Lexer createLexer(Project project) { + override fun createLexer(project: Project): Lexer { // TODO take prefs from project somehow - return new M68kLexer(lexerPrefs); + return M68kLexer(lexerPrefs) } - @Override - public @NotNull PsiParser createParser(Project project) { - return new M68kParser(); - } + override fun createParser(project: Project) = M68kParser() - @Override - public @NotNull IFileElementType getFileNodeType() { - return M68kFileElementType.INSTANCE; - } + override fun getFileNodeType() = M68kFileElementType.INSTANCE - @Override - public @NotNull TokenSet getCommentTokens() { - return COMMENTS; - } + override fun getCommentTokens() = COMMENTS - @Override - public @NotNull TokenSet getStringLiteralElements() { - return STRING_LITERALS; - } + override fun getStringLiteralElements() = STRING_LITERALS - @Override - public @NotNull PsiElement createElement(ASTNode node) { - return M68kTypes.Factory.createElement(node); - } + override fun createElement(node: ASTNode) = M68kTypes.Factory.createElement(node) - @Override - public @NotNull PsiFile createFile(@NotNull FileViewProvider viewProvider) { - return new M68kFile(viewProvider); + override fun createFile(viewProvider: FileViewProvider) = M68kFile(viewProvider) + + companion object { + val STRING_LITERALS = TokenSet.create(M68kTypes.STRINGLIT) + val COMMENTS = TokenSet.create(M68kTypes.COMMENT) } -} +} \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserUtilBase.kt b/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserUtilBase.kt index 26c8dce..98d4370 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserUtilBase.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/parser/M68kParserUtilBase.kt @@ -1,7 +1,5 @@ -package de.platon42.intellij.plugins.m68k.parser; +package de.platon42.intellij.plugins.m68k.parser -import com.intellij.lang.parser.GeneratedParserUtilBase; +import com.intellij.lang.parser.GeneratedParserUtilBase -public class M68kParserUtilBase extends GeneratedParserUtilBase { - -} +class M68kParserUtilBase : GeneratedParserUtilBase() \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kColorSettingsPage.kt b/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kColorSettingsPage.kt index b74b098..cd3290a 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kColorSettingsPage.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kColorSettingsPage.kt @@ -5,7 +5,6 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighter import com.intellij.openapi.options.colors.AttributesDescriptor import com.intellij.openapi.options.colors.ColorDescriptor import com.intellij.openapi.options.colors.ColorSettingsPage -import com.intellij.openapi.util.NlsContexts.ConfigurableName import de.platon42.intellij.plugins.m68k.M68kIcons.FILE import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.AREG import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.BAD_CHARACTER @@ -90,7 +89,7 @@ hello: dc.b 'Hello World!',10,0 return ColorDescriptor.EMPTY_ARRAY } - override fun getDisplayName(): @ConfigurableName String { + override fun getDisplayName(): String { return "M68k Assembly" } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 255b9d9..5a8ac43 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -5,11 +5,11 @@ Full documentation here... ]]> - + com.intellij.modules.lang