Skip to content

Commit

Permalink
feat(intellij-plugin): add support for macros in the tool window
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed Mar 2, 2024
1 parent a6a5951 commit 4638ba3
Show file tree
Hide file tree
Showing 6 changed files with 3,757 additions and 2,388 deletions.
2 changes: 1 addition & 1 deletion editor/intellij/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
}

dependencies {
implementation("com.google.guava:guava:31.1-jre")
implementation("com.google.guava:guava:33.0.0-jre")
implementation("com.google.code.gson:gson:2.9.1")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ public class YakshaIcons {
public static final Icon CLASS = IconLoader.getIcon("/icons/C.svg", YakshaIcons.class);
public static final Icon DEF = IconLoader.getIcon("/icons/D.svg", YakshaIcons.class);
public static final Icon IMPORT = IconLoader.getIcon("/icons/I.svg", YakshaIcons.class);
public static final Icon MACRO = IconLoader.getIcon("/icons/J.svg", YakshaIcons.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class YakshaToolWindow {
private JTree documentationTree;
private JTextField filterText;

private Debouncer debouncer = new Debouncer();
private final Debouncer debouncer = new Debouncer();

public static class Debouncer {
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ public String generateDoc(String importPath, String name) {
return cl.genDoc(importPath);
}
}
for (YakshaMacro y: documentation.macros) {
if (y.name.equals(name)) {
return y.genDoc(importPath);
}
}
return "";
}

Expand Down Expand Up @@ -236,10 +241,20 @@ private static void addComments(String allComments, DefaultMutableTreeNode node)
public static class Doc {
public List<Import> imports;
public List<GlobalConstant> global_consts;
public List<YakshaMacro> macros;
public List<Fn> functions;
public List<Cls> classes;

public void fill(DefaultMutableTreeNode lib, String filterLowerCase) {
macros.forEach(m -> {
if (keepOut(filterLowerCase, m.getRepr(), m.getTypeText())) {
return;
}
DefaultMutableTreeNode node = new DefaultMutableTreeNode(DocWithIcon.dwi(m.getRepr(),
YakshaIcons.MACRO));
addComments(m.getTypeText(), node);
lib.add(node);
});
global_consts.forEach(c -> {
if (keepOut(filterLowerCase, c.getRepr(), c.getTypeText())) {
return;
Expand Down Expand Up @@ -268,6 +283,7 @@ public void fill(DefaultMutableTreeNode lib, String filterLowerCase) {
addComments(c.getTypeText(), node);
lib.add(node);
});

}
}

Expand Down Expand Up @@ -298,6 +314,26 @@ public String genDoc(final String importPath) {
return b.build();
}
}
public static class YakshaMacro {
public String name;
public String comment;

public String getRepr() {
return name;
}

public String getTypeText() {
return comment;
}

public String genDoc(final String importPath) {
DocBuilder b = new DocBuilder();
b.title(importPath + "." + name);
b.description(comment.replace("\n", "<br />"));
b.keyValue("<b>Kind</b>", "Macro");
return b.build();
}
}

public static class Fn {
public String name;
Expand Down
Loading

0 comments on commit 4638ba3

Please sign in to comment.