Skip to content

Commit 686b8c6

Browse files
committed
IntelliJ plugin fix
Adjust plugin to work with recent IDEA versions as there were some breaking changes in plugin setup.
1 parent e464bac commit 686b8c6

File tree

10 files changed

+25
-58
lines changed

10 files changed

+25
-58
lines changed

IdeaPlugin/DSL Platform.iml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<module type="PLUGIN_MODULE" version="4">
33
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
4-
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
4+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
55
<exclude-output />
66
<content url="file://$MODULE_DIR$">
77
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />

IdeaPlugin/META-INF/plugin.xml

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<idea-plugin version="2">
1+
<idea-plugin>
22
<id>com.dslplatform.ideaplugin</id>
33
<name>DSL Platform</name>
4-
<version>0.9.10</version>
4+
<version>0.10.1</version>
55
<vendor email="[email protected]" url="https://dsl-platform.com">DSL Platform</vendor>
66

77
<description><![CDATA[
@@ -14,39 +14,28 @@
1414

1515
<change-notes><![CDATA[
1616
<ul>
17+
<li>0.10.1 IDEA 2024 compatibility fix
1718
<li>0.9.10 Highligting fix for IDEA 2020+
1819
<li>0.9.9 Bugfix
19-
<li>0.9.8 Bugfix
20-
<li>0.9.7 Bugfix
21-
<li>0.9.6 Bugfix
2220
</ul>
2321
]]>
2422
</change-notes>
2523

2624
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
27-
<idea-version since-build="162"/>
25+
<idea-version since-build="203.5981.155"/>
2826

2927
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
3028
on how to target different products -->
3129
<depends>com.intellij.modules.lang</depends>
3230

3331
<extensions defaultExtensionNs="com.intellij">
3432
<!-- Add your extensions here -->
35-
<applicationService serviceInterface="com.dslplatform.ideaplugin.DslCompilerService" serviceImplementation="com.dslplatform.ideaplugin.DslCompilerService" />
36-
<fileTypeFactory implementation="com.dslplatform.ideaplugin.DslFileTypeFactory"/>
37-
<lang.syntaxHighlighterFactory key="DomainSpecificationLanguage" implementationClass="com.dslplatform.ideaplugin.DslSyntaxHighlighterFactory"/>
33+
<fileType name="DSL file" implementationClass="com.dslplatform.ideaplugin.DslFileType" fieldName="INSTANCE" language="DomainSpecificationLanguage" extensions="dsl" />
34+
<lang.syntaxHighlighterFactory language="DomainSpecificationLanguage" implementationClass="com.dslplatform.ideaplugin.DslSyntaxHighlighterFactory"/>
3835
<colorSettingsPage implementation="com.dslplatform.ideaplugin.DslColorSettingsPage"/>
3936
<lang.commenter language="DomainSpecificationLanguage" implementationClass="com.dslplatform.ideaplugin.DslCommenter"/>
4037
</extensions>
4138

42-
<application-components>
43-
<!-- Add your application components here -->
44-
</application-components>
45-
46-
<project-components>
47-
<!-- Add your project components here -->
48-
</project-components>
49-
5039
<actions>
5140
<!--action
5241
id="dsl.AvailableConcepts"

IdeaPlugin/lib/dsl-clc-1.9.9.jar

-1.2 MB
Binary file not shown.

IdeaPlugin/lib/dsl-clc-2.1.1.jar

1.7 MB
Binary file not shown.

IdeaPlugin/src/com/dslplatform/ideaplugin/DslColorSettingsPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class DslColorSettingsPage implements ColorSettingsPage {
2121
@Nullable
2222
@Override
2323
public Icon getIcon() {
24-
return Icons.FILE;
24+
return DslIcons.FILE;
2525
}
2626

2727
@NotNull

IdeaPlugin/src/com/dslplatform/ideaplugin/DslCompilerService.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.dslplatform.compiler.client.Main;
66
import com.dslplatform.compiler.client.parameters.Download;
77
import com.dslplatform.compiler.client.parameters.DslCompiler;
8+
import com.intellij.openapi.components.Service;
89
import com.intellij.openapi.diagnostic.Logger;
910

1011
import java.io.File;
@@ -13,10 +14,11 @@
1314
import java.util.List;
1415
import java.util.Stack;
1516

16-
public class DslCompilerService {
17+
@Service(Service.Level.APP)
18+
public final class DslCompilerService {
1719

1820
private DslCompiler.TokenParser tokenParser;
19-
private final List<Runnable> notifications = new ArrayList<Runnable>();
21+
private final List<Runnable> notifications = new ArrayList<>();
2022

2123
public DslCompilerService() {
2224
final Logger logger = com.intellij.openapi.diagnostic.Logger.getInstance("DSL Platform");
@@ -80,7 +82,7 @@ public void run() {
8082

8183
Either<List<AST>> analyze(String dsl) {
8284
if (dsl.trim().isEmpty()) {
83-
List<AST> empty = new ArrayList<AST>(0);
85+
List<AST> empty = new ArrayList<>(0);
8486
return Either.success(empty);
8587
}
8688
if (tokenParser == null) return Either.fail("Token parser not ready");

IdeaPlugin/src/com/dslplatform/ideaplugin/DslFileType.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
import com.intellij.openapi.fileTypes.LanguageFileType;
44
import org.jetbrains.annotations.NotNull;
5-
import org.jetbrains.annotations.Nullable;
65

76
import javax.swing.*;
87

9-
public class DslFileType extends LanguageFileType {
8+
public final class DslFileType extends LanguageFileType {
109
public static final DslFileType INSTANCE = new DslFileType();
1110

1211
private DslFileType() {
@@ -31,9 +30,8 @@ public String getDefaultExtension() {
3130
return "dsl";
3231
}
3332

34-
@Nullable
3533
@Override
3634
public Icon getIcon() {
37-
return Icons.FILE;
35+
return DslIcons.FILE;
3836
}
3937
}

IdeaPlugin/src/com/dslplatform/ideaplugin/DslFileTypeFactory.java

Lines changed: 0 additions & 12 deletions
This file was deleted.

IdeaPlugin/src/com/dslplatform/ideaplugin/Icons.java renamed to IdeaPlugin/src/com/dslplatform/ideaplugin/DslIcons.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
import javax.swing.*;
66

7-
public class Icons {
8-
public static final Icon FILE = IconLoader.getIcon("/com/dslplatform/ideaplugin/dsl.png");
7+
public class DslIcons {
8+
public static final Icon FILE = IconLoader.getIcon("/com/dslplatform/ideaplugin/dsl.png", DslIcons.class);
99
}

IdeaPlugin/src/com/dslplatform/ideaplugin/DslLexerParser.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
import com.intellij.lexer.*;
55
import com.intellij.openapi.application.Application;
66
import com.intellij.openapi.application.ApplicationManager;
7-
import com.intellij.openapi.components.ServiceManager;
87
import com.intellij.openapi.diagnostic.Logger;
98
import com.intellij.openapi.editor.Document;
109
import com.intellij.openapi.editor.DocumentRunnable;
11-
import com.intellij.openapi.editor.ex.util.LexerEditorHighlighter;
1210
import com.intellij.openapi.project.DumbAwareRunnable;
1311
import com.intellij.openapi.project.Project;
1412
import com.intellij.openapi.vfs.VirtualFile;
@@ -35,15 +33,15 @@ public class DslLexerParser extends Lexer {
3533
private boolean waitingForSync;
3634
private long delayUntil;
3735
private String lastDsl = "";
38-
private final List<AST> ast = new ArrayList<AST>();
36+
private final List<AST> ast = new ArrayList<>();
3937
private int position = 0;
4038
private boolean isActive = true;
4139
private final Logger logger = com.intellij.openapi.diagnostic.Logger.getInstance("DSL Platform");
4240

4341
public DslLexerParser(Project project, VirtualFile file) {
4442
this.project = project;
4543
this.application = ApplicationManager.getApplication();
46-
this.dslService = ServiceManager.getService(DslCompilerService.class);
44+
this.dslService = application.getService(DslCompilerService.class);
4745
if (project != null && file != null) {
4846
psiFile = PsiManager.getInstance(project).findFile(file);
4947
document = psiFile != null ? PsiDocumentManager.getInstance(project).getDocument(psiFile) : null;
@@ -90,16 +88,8 @@ public void run() {
9088
} else {
9189
psiFile = null;
9290
document = null;
93-
refreshAll = new Runnable() {
94-
@Override
95-
public void run() {
96-
}
97-
};
98-
scheduleRefresh = new Runnable() {
99-
@Override
100-
public void run() {
101-
}
102-
};
91+
refreshAll = () -> {};
92+
scheduleRefresh = () -> {};
10393
}
10494
}
10595

@@ -179,7 +169,7 @@ public void start(@NotNull CharSequence charSequence, int start, int end, int st
179169
if (project != null && project.isDisposed() || !isActive) return;
180170
final boolean nonEditorPage = project == null || psiFile == null || !document.isWritable();
181171
final String dsl = charSequence.toString();
182-
if (forceRefresh || nonEditorPage || ast.size() == 0) {
172+
if (forceRefresh || nonEditorPage || ast.isEmpty()) {
183173
if (lastParsedAnalysis != null && dsl.equals(lastParsedDsl)) {
184174
changeAst(start, lastParsedAnalysis);
185175
lastDsl = lastParsedDsl;
@@ -189,7 +179,7 @@ public void start(@NotNull CharSequence charSequence, int start, int end, int st
189179
if (tryNewAst.isSuccess()) {
190180
List<AST> newAst = tryNewAst.get();
191181
logger.debug("analyzed successfuly = " + newAst.size());
192-
if (newAst.size() == 0) {
182+
if (newAst.isEmpty()) {
193183
newAst.add(new AST(null, 0, dsl.length(), null));
194184
}
195185
fixupAndReposition(dsl, newAst, start);
@@ -206,7 +196,7 @@ public void start(@NotNull CharSequence charSequence, int start, int end, int st
206196
} else if (!dsl.equals(lastDsl)) {
207197
logger.debug("changed dsl");
208198
final String actualDsl;
209-
if (start == end && dsl.length() == 0) {
199+
if (start == end && dsl.isEmpty()) {
210200
if (psiFile.getLanguage() == DomainSpecificationLanguage.INSTANCE) {
211201
actualDsl = psiFile.getText();
212202
if (actualDsl.equals(lastDsl)) {
@@ -219,7 +209,7 @@ public void start(@NotNull CharSequence charSequence, int start, int end, int st
219209
return;
220210
}
221211
} else actualDsl = dsl;
222-
List<AST> newAst = new ArrayList<AST>(ast.size());
212+
List<AST> newAst = new ArrayList<>(ast.size());
223213
int cur = 0;
224214
int pos = start;
225215
while(pos < dsl.length() && pos < lastDsl.length() && dsl.charAt(pos) == lastDsl.charAt(pos)) {

0 commit comments

Comments
 (0)