Skip to content

Commit ad0bfd5

Browse files
committed
Allow to select the Scala/Chisel file to jump to
1 parent a3292af commit ad0bfd5

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2+
hs_err_pid*
3+
4+
*.iml
5+
/.idea/
6+
/build/
7+
/.gradle/

build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ intellij {
2828

2929
runIde {
3030
// https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime
31-
jbrVersion "11_0_9b1145.21"
31+
jbrVersion "11_0_9_1b1145.77"
3232
ideDirectory "/home/itviewer/Downloads/software/chip"
3333
jvmArgs '-Didea.platform.prefix=Chip'
3434
//for jbr11
@@ -37,9 +37,7 @@ runIde {
3737

3838
patchPluginXml {
3939
sinceBuild "203"
40-
untilBuild "203.*"
41-
changeNotes """
42-
First release.<br>"""
40+
untilBuild "211.*"
4341
}
4442

4543
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.1
1+
pluginVersion=1.0.2

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

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import com.intellij.notification.Notifications;
66
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
77
import com.intellij.openapi.project.Project;
8+
import com.intellij.openapi.ui.popup.JBPopupFactory;
89
import com.intellij.openapi.util.TextRange;
10+
import com.intellij.openapi.vfs.VirtualFile;
911
import com.intellij.psi.PsiElement;
1012
import com.intellij.psi.PsiFile;
1113
import com.intellij.psi.PsiReferenceBase;
@@ -16,6 +18,11 @@
1618
import org.jetbrains.annotations.NotNull;
1719
import org.jetbrains.annotations.Nullable;
1820

21+
import java.util.ArrayList;
22+
import java.util.HashMap;
23+
import java.util.List;
24+
import java.util.Map;
25+
1926
public class FileInfoRef extends PsiReferenceBase<PsiElement> {
2027

2128
public FileInfoRef(@NotNull PsiElement element, TextRange textRange) {
@@ -43,18 +50,29 @@ public void navigate(boolean requestFocus) {
4350
int line = Integer.valueOf(pos[0]) - 1;
4451
int column = Integer.valueOf(pos[1].replace("]", "")) - 1;
4552

46-
Project p = myElement.getProject();
47-
PsiFile[] files = FilenameIndex.getFilesByName(p,filename, GlobalSearchScope.projectScope(p));
53+
Project project = myElement.getProject();
54+
PsiFile[] files = FilenameIndex.getFilesByName(project,filename, GlobalSearchScope.projectScope(project));
4855
int length = files.length;
4956
if (length != 0){
5057
if (length == 1) {
51-
new OpenFileDescriptor(p, files[0].getVirtualFile(),line,column).navigate(true);
58+
new OpenFileDescriptor(project, files[0].getVirtualFile(),line,column).navigate(true);
5259
} else {
53-
Notifications.Bus.notify(new Notification("","",String.valueOf(length) + " "
54-
+ filename + "files found!", NotificationType.INFORMATION));
60+
List<String> list = new ArrayList<>();
61+
final Map<String, VirtualFile> map = new HashMap<>();
62+
for (PsiFile file : files) {
63+
VirtualFile vFile = file.getVirtualFile();
64+
String relativePath = vFile.getCanonicalPath().replace(project.getBasePath(), "").substring(1);
65+
66+
map.put(relativePath, vFile);
67+
list.add(relativePath);
68+
}
69+
JBPopupFactory.getInstance().createPopupChooserBuilder(list)
70+
.setTitle("File Chooser")
71+
.setItemChosenCallback((chosenFile) -> new OpenFileDescriptor(project, map.get(chosenFile),line,column).navigate(true))
72+
.createPopup().showInFocusCenter();
5573
}
5674
} else {
57-
Notifications.Bus.notify(new Notification("","",filename + " not found!",
75+
Notifications.Bus.notify(new Notification("FileInfo","",filename + " not found!",
5876
NotificationType.ERROR));
5977
}
6078
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
<idea-plugin allow-bundled-update="true" url="https://www.easysoc.org">
1+
<idea-plugin url="https://www.easysoc.org">
22
<id>org.easysoc.verilog</id>
33
<name>EasySoC Verilog</name>
44
<vendor url="https://www.easysoc.org">EasySoC</vendor>
5-
5+
<change-notes><![CDATA[
6+
<ul>
7+
<li>Allow to select the Scala/Chisel file to jump to</li>
8+
</ul>
9+
]]></change-notes>
610
<description><![CDATA[
711
Jump to the corresponding Chisel code by navigate(Ctrl+Click) the special verilog comment.<br>
812
Currently depends on the SystemVerilog plugin by Edaphic.Studio.

0 commit comments

Comments
 (0)