Skip to content

Commit 7b8e7ed

Browse files
authored
Release 0.1.4 (#27)
* Rename .java to .kt * Release 0.1.4 ## Fixes - Fixed doc comments not finding macro parameters - Fixed doc comment completions - Fixed IDE error caused by doc comment not finding underlying function or macro - Fixed doc comment not finding underlying function or macro when in default module - Fixed top level code completion interfering with doc comments - Fixed hover doc displaying parameters that only existed in the doc comment ## Additions - Added hover doc for macros - Added doc comment description to hover doc - Added inspection for missing imports - Added inspection for missing functions or macro in imports - Added stdlib path selector in both project wizards - Added banner that shows if the stdlib path couldn't be detected - Added string highlighting in doc comments for all strings - Added settings page - Added styled parameter names in doc comments ## Optimizations - Optimized stdlib path lookup by the IDE - Optimized code completion by implementing new completion system * Minor fixes - Fixed stdlibPath possibly being null - Fixed inspection not checking for same module functions or macros - Fixed inspection not displaying the call module - Fixed doc comment not allowing parameters starting with `#` or `$` * Minor fixes - Fixed inspection wrongfully annotating correct function call as not found - Fixed stdlib path not being correctly detected on windows * Fixed Plugin crashes - Fixed Macro doc comment expecting a set return type - Fixed inspection wrongfully assuming some elements as call expressions * Fixed Inspection wrongfully highlighting elements * Temporarily disabled inspections for function calls * Fixed hover doc sometimes crashing due to faulty parameter evaluation
1 parent 7e39832 commit 7b8e7ed

31 files changed

+1602
-375
lines changed

src/main/gen/org/c3lang/intellij/psi/C3CallExpr.java

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/org/c3lang/intellij/psi/impl/C3CallExprImpl.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/c3lang/intellij/C3.bnf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ ct_defined_check_expr_list ::= ct_defined_check_expr (COMMA ct_defined_check_exp
452452
ct_defined_expr ::= KW_CT_DEFINED LP ct_defined_check_expr_list RP
453453
lambda_decl_expr ::= lambda_decl compound_statement
454454
lambda_decl_short_expr ::= lambda_decl IMPLIES expr
455-
call_expr ::= expr call_expr_tail
455+
call_expr ::= expr call_expr_tail {
456+
methods=[isDeprecated]
457+
}
456458
unary_expr ::= unary_op expr { rightAssociative=true }
457459
expr_terminator ::= EOS | RP | RBT | RB | COMMA | COLON
458460
ternary_expr ::= expr QUESTION !((BANGBANG | BANG)? expr_terminator) expr COLON expr { rightAssociative=true }
Lines changed: 94 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,94 @@
1-
package org.c3lang.intellij;
2-
3-
import com.intellij.codeInsight.completion.*;
4-
import com.intellij.codeInsight.lookup.LookupElement;
5-
import com.intellij.codeInsight.lookup.LookupElementBuilder;
6-
import com.intellij.openapi.project.DumbAware;
7-
import com.intellij.patterns.ObjectPattern;
8-
import com.intellij.patterns.PatternCondition;
9-
import com.intellij.patterns.PlatformPatterns;
10-
import com.intellij.patterns.PsiElementPattern;
11-
import com.intellij.psi.PsiComment;
12-
import com.intellij.psi.PsiElement;
13-
import com.intellij.psi.PsiWhiteSpace;
14-
import com.intellij.psi.tree.IElementType;
15-
import com.intellij.util.ProcessingContext;
16-
import org.c3lang.intellij.psi.*;
17-
import org.jetbrains.annotations.NotNull;
18-
19-
import java.sql.Array;
20-
import java.util.ArrayList;
21-
import java.util.Arrays;
22-
import java.util.Collections;
23-
import java.util.List;
24-
25-
import static com.intellij.patterns.PlatformPatterns.psiElement;
26-
27-
public class C3CompletionContributor extends CompletionContributor implements DumbAware
28-
{
29-
public C3CompletionContributor()
30-
{
31-
String[] topLevelKw = {
32-
"fn",
33-
"struct",
34-
"fault",
35-
"macro",
36-
"def",
37-
"module",
38-
"import",
39-
"extern",
40-
"const",
41-
"tlocal",
42-
"bitstruct",
43-
"static initialize",
44-
"static finalize",
45-
"asm",
46-
"$switch",
47-
};
48-
final List<LookupElement> topLevelLookups = new ArrayList<>();
49-
for (String s : topLevelKw)
50-
{
51-
topLevelLookups.add(LookupElementBuilder.create(s + " ").withPresentableText(s).bold());
52-
}
53-
InsertHandler<LookupElement> handler = (insertionContext, lookupElement) -> {
54-
insertionContext.getDocument().insertString(insertionContext.getEditor().getCaretModel().getOffset(), "()");
55-
insertionContext.getEditor().getCaretModel().moveCaretRelatively(1, 0, false, false, false);
56-
};
57-
58-
for (String s : Arrays.asList("$include", "$assert", "$echo", "$if"))
59-
{
60-
topLevelLookups.add(LookupElementBuilder
61-
.create(s + " (")
62-
.bold()
63-
.withPresentableText(s));
64-
}
65-
PsiElementPattern.Capture<PsiElement> context = psiElement()
66-
.with(new PatternCondition<>("toplevel")
67-
{
68-
@Override
69-
public boolean accepts(@NotNull PsiElement psiElement, ProcessingContext processingContext)
70-
{
71-
if (!(psiElement.getParent() instanceof C3File)) return false;
72-
PsiElement sib = psiElement.getPrevSibling();
73-
while (sib instanceof PsiComment || sib instanceof PsiWhiteSpace)
74-
{
75-
sib = sib.getPrevSibling();
76-
}
77-
if (sib == null) return true;
78-
if (sib instanceof C3DefaultModuleSection || sib instanceof C3ModuleSection) return true;
79-
return false;
80-
}
81-
});
82-
83-
extend(CompletionType.BASIC, context, new CompletionProvider<>()
84-
{
85-
public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context,
86-
@NotNull CompletionResultSet resultSet)
87-
{
88-
System.out.println(parameters.getPosition());
89-
resultSet.addAllElements(topLevelLookups);
90-
}
91-
});
92-
}
93-
94-
95-
}
1+
//package org.c3lang.intellij;
2+
//
3+
//import com.intellij.codeInsight.completion.*;
4+
//import com.intellij.codeInsight.lookup.LookupElement;
5+
//import com.intellij.codeInsight.lookup.LookupElementBuilder;
6+
//import com.intellij.openapi.project.DumbAware;
7+
//import com.intellij.patterns.ObjectPattern;
8+
//import com.intellij.patterns.PatternCondition;
9+
//import com.intellij.patterns.PlatformPatterns;
10+
//import com.intellij.patterns.PsiElementPattern;
11+
//import com.intellij.psi.PsiComment;
12+
//import com.intellij.psi.PsiElement;
13+
//import com.intellij.psi.PsiWhiteSpace;
14+
//import com.intellij.psi.tree.IElementType;
15+
//import com.intellij.util.ProcessingContext;
16+
//import org.c3lang.intellij.psi.*;
17+
//import org.jetbrains.annotations.NotNull;
18+
//
19+
//import java.sql.Array;
20+
//import java.util.ArrayList;
21+
//import java.util.Arrays;
22+
//import java.util.List;
23+
//
24+
//import static com.intellij.patterns.PlatformPatterns.psiElement;
25+
//
26+
//public class C3CompletionContributor extends CompletionContributor implements DumbAware
27+
//{
28+
// public C3CompletionContributor()
29+
// {
30+
// String[] topLevelKw = {
31+
// "fn",
32+
// "struct",
33+
// "fault",
34+
// "macro",
35+
// "def",
36+
// "module",
37+
// "import",
38+
// "extern",
39+
// "const",
40+
// "tlocal",
41+
// "bitstruct",
42+
// "static initialize",
43+
// "static finalize",
44+
// "asm",
45+
// "$switch",
46+
// };
47+
// final List<LookupElement> topLevelLookups = new ArrayList<>();
48+
// for (String s : topLevelKw)
49+
// {
50+
// topLevelLookups.add(LookupElementBuilder.create(s + " ").withPresentableText(s).bold());
51+
// }
52+
// InsertHandler<LookupElement> handler = (insertionContext, lookupElement) -> {
53+
// insertionContext.getDocument().insertString(insertionContext.getEditor().getCaretModel().getOffset(), "()");
54+
// insertionContext.getEditor().getCaretModel().moveCaretRelatively(1, 0, false, false, false);
55+
// };
56+
//
57+
// for (String s : Arrays.asList("$include", "$assert", "$echo", "$if"))
58+
// {
59+
// topLevelLookups.add(LookupElementBuilder
60+
// .create(s + " (")
61+
// .bold()
62+
// .withPresentableText(s));
63+
// }
64+
// PsiElementPattern.Capture<PsiElement> context = psiElement()
65+
// .with(new PatternCondition<>("toplevel")
66+
// {
67+
// @Override
68+
// public boolean accepts(@NotNull PsiElement psiElement, ProcessingContext processingContext)
69+
// {
70+
// if (!(psiElement.getParent() instanceof C3File)) return false;
71+
// PsiElement sib = psiElement.getPrevSibling();
72+
// while (sib instanceof PsiComment || sib instanceof PsiWhiteSpace)
73+
// {
74+
// sib = sib.getPrevSibling();
75+
// }
76+
// if (sib == null) return true;
77+
// if (sib instanceof C3DefaultModuleSection || sib instanceof C3ModuleSection) return true;
78+
// return false;
79+
// }
80+
// });
81+
//
82+
// extend(CompletionType.BASIC, context, new CompletionProvider<>()
83+
// {
84+
// public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context,
85+
// @NotNull CompletionResultSet resultSet)
86+
// {
87+
// System.out.println(parameters.getPosition());
88+
// resultSet.addAllElements(topLevelLookups);
89+
// }
90+
// });
91+
// }
92+
//
93+
//
94+
//}

src/main/java/org/c3lang/intellij/C3SettingsState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
public class C3SettingsState implements PersistentStateComponent<C3SettingsState>
1212
{
1313
public String sdk = "c3c";
14+
public String stdlibPath = "";
1415

1516
public static C3SettingsState getInstance()
1617
{

src/main/java/org/c3lang/intellij/C3Util.java

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

0 commit comments

Comments
 (0)