Fixed compatibility with older IntelliJ versions. Minimum version now 2019.3.5, though. Converted a few missing files from Java to Kotlin.

This commit is contained in:
Chris Hodges 2021-07-20 14:25:41 +02:00
parent 25245bea10
commit 3319fc1c45
9 changed files with 62 additions and 107 deletions

View File

@ -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.
- Initial public release.

View File

@ -46,9 +46,9 @@ intellij {
patchPluginXml {
setChangeNotes("""
<h4>V0.1 (xx-Jun-21)</h4>
<h4>V0.1 (20-Jun-21)</h4>
<ul>
<li>Initial.
<li>Initial public release.
</ul>
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
""")

View File

@ -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<M68kFileStub> {
public static final IStubFileElementType<M68kFileStub> INSTANCE = new M68kFileElementType();
public static final int VERSION = 1;
class M68kFileElementType private constructor() : IStubFileElementType<M68kFileStub>("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)
}
};
}
}
}
}

View File

@ -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"

View File

@ -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)

View File

@ -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)
}
}
}

View File

@ -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()

View File

@ -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"
}

View File

@ -5,11 +5,11 @@
</vendor>
<description><![CDATA[
MC68000-asm-plugin is a plugin to add language support for Motorola 68000 assembly language files.
MC68000 Assembly Language Plugin adds language support for Motorola 68000 (M68k) assembly language files.
<p>
<a href="https://github.com/chrisly42/mc68000-asm-plugin/blob/main/README.md">Full documentation here...</a>
]]></description>
<idea-version since-build="192.4205.45"/>
<idea-version since-build="193.7288.26"/>
<depends>com.intellij.modules.lang</depends>