Skip to content

Commit 47ecca4

Browse files
committed
Add simple comment handler for inserting * and completion fix
This fixes the missing completion for file-global functions. Additionally, this version includes a simple enter handler that inserts * automatically in multi-line comments.
1 parent c83fa41 commit 47ecca4

4 files changed

Lines changed: 16 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
- Better rendering for "Go to Declaration" targets
66
- Inspection for using the same variable in the e.g. Module definition list several times
77
- Quick fix for adding usages and other messages
8-
- Keeping a leading * when pressing enter inside comments
98
- Rework of creating project templates and modules
109
- Update to Mathematica version 11.2
1110
- Quick fix for pushing a variable inside the Module definition list
1211
- Completion for file names inside strings
1312

1413
## Version 3.0
1514

15+
- Keeping a leading * when pressing enter inside comments
1616
- Quick Documentation lookup for own functions. This will show the usage message of a function if available.
1717
- Performance improvement through caching
1818
- Support for Libraries. Libraries are basically a package folder with Mathematica source code. This code is indexed and

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ task wrapper(type: Wrapper) {
7575
// Information about the plugin
7676

7777
// Plugin version number
78-
version '3.0pre4'
78+
version '3.0pre5'
7979

8080
intellij {
8181
// version = '2017.2.5'

src/de/halirutan/mathematica/codeinsight/completion/providers/FileSymbolCompletion.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.intellij.util.containers.hash.HashSet;
3939
import de.halirutan.mathematica.codeinsight.completion.util.LocalDefinitionCompletionProvider;
4040
import de.halirutan.mathematica.lang.psi.api.Symbol;
41+
import de.halirutan.mathematica.lang.resolve.MathematicaGlobalResolveCache;
4142
import org.jetbrains.annotations.NotNull;
4243

4344
import java.util.List;
@@ -82,6 +83,18 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi
8283
LookupElementBuilder.create(currentSymbol).bold().withItemTextForeground(JBColor.GREEN),
8384
LOCAL_VARIABLE_PRIORITY));
8485
}
86+
87+
final MathematicaGlobalResolveCache cache =
88+
MathematicaGlobalResolveCache.getInstance(callingSymbol.getProject());
89+
cache.getCachedFileSymbolResolves(parameters.getOriginalFile())
90+
.forEach(symbolResolveResult -> {
91+
if (symbolResolveResult.getElement() != null) {
92+
result.addElement(PrioritizedLookupElement.withPriority(
93+
LookupElementBuilder.create(symbolResolveResult.getElement()).bold(),
94+
GLOBAL_VARIABLE_PRIORITY));
95+
}
96+
});
97+
8598
} else {
8699
final Set<String> allSymbols = new HashSet<>();
87100
PsiRecursiveElementVisitor visitor = new PsiRecursiveElementVisitor() {

src/de/halirutan/mathematica/codeinsight/highlighting/annotators/SymbolAnnotator.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class SymbolAnnotator : Annotator {
4343
/** Annotates a [symbol] by checking its localization */
4444
override fun annotate(symbol: PsiElement, holder: AnnotationHolder) {
4545
if (symbol is Symbol) {
46+
symbol.resolve()
4647
val scope = symbol.localizationConstruct
4748
val scopeType = scope.type
4849
if (LocalizationConstruct.MScope.NULL_SCOPE == scope) {

0 commit comments

Comments
 (0)