Skip to content

Commit 337ca16

Browse files
committed
Support IntelliJ 2021.3
1 parent ad0bfd5 commit 337ca16

File tree

8 files changed

+62
-46
lines changed

8 files changed

+62
-46
lines changed

build.gradle

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,42 @@
11
plugins {
22
id 'java'
3-
id 'org.jetbrains.intellij' version '0.6.5'
3+
id 'org.jetbrains.intellij' version '1.5.1'
44
}
55

66
group 'org.easysoc'
77
version pluginVersion
88

9-
//sourceCompatibility = 1.8
9+
sourceCompatibility = 11
10+
targetCompatibility = 11
1011

1112
repositories {
1213
mavenCentral()
1314
}
1415

1516
dependencies {
16-
//testCompile group: 'junit', name: 'junit', version: '4.12'
17+
1718
}
1819

1920
// See https://github.com/JetBrains/gradle-intellij-plugin/
2021
intellij {
2122
// version and localPath should not be specified at the same time
22-
localPath "/home/itviewer/Downloads/software/chip"
23+
// version = '2021.3.3'
24+
localPath = "/home/itviewer/Downloads/software/idea-IC"
25+
sandboxDir = "/home/itviewer/IdeaProjects/plugins-sandbox"
2326

24-
// https://blog.jetbrains.com/platform/2019/06/java-functionality-extracted-as-a-plugin/
25-
// plugins 'studio.edaphic.sv:2019.3.2'
26-
downloadSources false
27+
// plugins = ['PsiViewer:213-SNAPSHOT']
28+
// downloadSources false
2729
}
2830

2931
runIde {
30-
// https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime
31-
jbrVersion "11_0_9_1b1145.77"
32-
ideDirectory "/home/itviewer/Downloads/software/chip"
33-
jvmArgs '-Didea.platform.prefix=Chip'
32+
ideDir = project.file('/home/itviewer/Downloads/software/idea-IC')
3433
//for jbr11
3534
jvmArgs '--add-exports=java.base/jdk.internal.vm=ALL-UNNAMED','-Djdk.module.illegalAccess.silent=true'
3635
}
3736

3837
patchPluginXml {
39-
sinceBuild "203"
40-
untilBuild "211.*"
38+
sinceBuild = '213'
39+
untilBuild = '221.*'
4140
}
4241

4342
buildSearchableOptions.onlyIf { false }

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pluginVersion=1.0.2
1+
pluginVersion=1.4.0

gradle/wrapper/gradle-wrapper.jar

333 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ case "`uname`" in
7272
Darwin* )
7373
darwin=true
7474
;;
75-
MINGW* )
75+
MSYS* | MINGW* )
7676
msys=true
7777
;;
7878
NONSTOP* )

src/main/java/org/easysoc/plugins/verilog/resolve/reference/FileInfoRef.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public PsiElement resolve() {
3636
}
3737

3838
public class MyFakePsiElement extends FakePsiElement implements SyntheticElement {
39+
40+
@Override
41+
public String getPresentableText() {
42+
return "FileInfo";
43+
}
44+
3945
@Override
4046
public PsiElement getParent() {
4147
return myElement;
@@ -44,11 +50,19 @@ public PsiElement getParent() {
4450
@Override
4551
public void navigate(boolean requestFocus) {
4652

53+
// only support first item // @[GCD.scala 24:{19,20} GCD2.scala 28:7]
4754
String[] token = myElement.getText().split(" ");
48-
String filename = token[1].substring(2);
49-
String[] pos = token[2].split(":");
50-
int line = Integer.valueOf(pos[0]) - 1;
51-
int column = Integer.valueOf(pos[1].replace("]", "")) - 1;
55+
// 只有这里和 Firrtl 不同,Verilog 具有 // 前缀
56+
String filename = token[1].substring(2); // GCD.scala
57+
String[] pos = token[2].split(":"); //
58+
int line = Integer.parseInt(pos[0]) - 1;
59+
int column;
60+
if (pos[1].startsWith("{")) {
61+
String[] columns = pos[1].split(",");
62+
column = Integer.parseInt(columns[0].replace("{", "")) - 1;
63+
} else {
64+
column = Integer.parseInt(pos[1].replace("]", "")) - 1;
65+
}
5266

5367
Project project = myElement.getProject();
5468
PsiFile[] files = FilenameIndex.getFilesByName(project,filename, GlobalSearchScope.projectScope(project));
@@ -72,9 +86,11 @@ public void navigate(boolean requestFocus) {
7286
.createPopup().showInFocusCenter();
7387
}
7488
} else {
75-
Notifications.Bus.notify(new Notification("FileInfo","",filename + " not found!",
76-
NotificationType.ERROR));
89+
Notifications.Bus.notify(new Notification(
90+
"SystemVerilog","",filename + " not found!", NotificationType.ERROR));
7791
}
7892
}
93+
94+
7995
}
8096
}

src/main/java/org/easysoc/plugins/verilog/resolve/reference/VerilogReferenceContributor.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@
77
import org.jetbrains.annotations.NotNull;
88

99
public class VerilogReferenceContributor extends PsiReferenceContributor {
10-
@Override
11-
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
10+
@Override
11+
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
1212
// PlatformPatterns.psiElement(PsiComment.class)
13-
registrar.registerReferenceProvider(PlatformPatterns.psiComment(),
14-
new PsiReferenceProvider() {
15-
@NotNull
16-
@Override
17-
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
18-
@NotNull ProcessingContext context) {
19-
PsiComment comment = (PsiComment) element;
20-
String value = comment.getText();
21-
if ((value.startsWith("// @["))) {
22-
TextRange textRange = new TextRange(5, value.length() - 1);
23-
return new PsiReference[]{new FileInfoRef(element, textRange)};
24-
}
25-
return PsiReference.EMPTY_ARRAY;
26-
}
27-
});
28-
}
13+
registrar.registerReferenceProvider(PlatformPatterns.psiComment(),
14+
new PsiReferenceProvider() {
15+
@NotNull
16+
@Override
17+
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
18+
@NotNull ProcessingContext context) {
19+
PsiComment comment = (PsiComment) element;
20+
String value = comment.getText();
21+
if ((value.startsWith("// @["))) {
22+
// 这里只影响鼠标点击时的提示范围,不影响 getText() 内容
23+
TextRange textRange = new TextRange(5, value.length() - 1);
24+
return new PsiReference[]{new FileInfoRef(element, textRange)};
25+
}
26+
return PsiReference.EMPTY_ARRAY;
27+
}
28+
});
29+
}
2930
}

src/main/resources/META-INF/plugin.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@
44
<vendor url="https://www.easysoc.org">EasySoC</vendor>
55
<change-notes><![CDATA[
66
<ul>
7-
<li>Allow to select the Scala/Chisel file to jump to</li>
7+
<li>Support IntelliJ 2021.3</li>
88
</ul>
99
]]></change-notes>
1010
<description><![CDATA[
11-
Jump to the corresponding Chisel code by navigate(Ctrl+Click) the special verilog comment.<br>
11+
Jump to the corresponding Chisel code by Ctrl+Click on the special verilog comment.<br>
1212
Currently depends on the SystemVerilog plugin by Edaphic.Studio.
1313
]]></description>
1414

15-
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
16-
on how to target different products -->
1715
<depends>studio.edaphic.sv</depends>
16+
<depends>org.easysoc.chisel</depends>
1817
<depends>com.intellij.modules.platform</depends>
1918

2019
<extensions defaultExtensionNs="com.intellij">
21-
<!-- Add your extensions here -->
20+
<notificationGroup id="SystemVerilog" displayType="BALLOON"/>
21+
2222
<psi.referenceContributor language="SystemVerilog" implementation="org.easysoc.plugins.verilog.resolve.reference.VerilogReferenceContributor"/>
23-
<documentationProvider implementation="org.easysoc.plugins.verilog.paths.FileInfoRefDocumentationProvider"/>
23+
<lang.documentationProvider language="SystemVerilog" implementationClass="org.easysoc.plugins.verilog.paths.FileInfoRefDocumentationProvider"/>
2424
</extensions>
2525

2626
<actions>

0 commit comments

Comments
 (0)