Skip to content

Commit

Permalink
Add simple comment handler for inserting * and completion fix
Browse files Browse the repository at this point in the history
This fixes the missing completion for file-global functions. Additionally,
this version includes a simple enter handler that inserts * automatically
in multi-line comments.
  • Loading branch information
halirutan committed Dec 4, 2017
1 parent c83fa41 commit 47ecca4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
- Better rendering for "Go to Declaration" targets
- Inspection for using the same variable in the e.g. Module definition list several times
- Quick fix for adding usages and other messages
- Keeping a leading * when pressing enter inside comments
- Rework of creating project templates and modules
- Update to Mathematica version 11.2
- Quick fix for pushing a variable inside the Module definition list
- Completion for file names inside strings

## Version 3.0

- Keeping a leading * when pressing enter inside comments
- Quick Documentation lookup for own functions. This will show the usage message of a function if available.
- Performance improvement through caching
- Support for Libraries. Libraries are basically a package folder with Mathematica source code. This code is indexed and
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ task wrapper(type: Wrapper) {
// Information about the plugin

// Plugin version number
version '3.0pre4'
version '3.0pre5'

intellij {
// version = '2017.2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.intellij.util.containers.hash.HashSet;
import de.halirutan.mathematica.codeinsight.completion.util.LocalDefinitionCompletionProvider;
import de.halirutan.mathematica.lang.psi.api.Symbol;
import de.halirutan.mathematica.lang.resolve.MathematicaGlobalResolveCache;
import org.jetbrains.annotations.NotNull;

import java.util.List;
Expand Down Expand Up @@ -82,6 +83,18 @@ protected void addCompletions(@NotNull CompletionParameters parameters, Processi
LookupElementBuilder.create(currentSymbol).bold().withItemTextForeground(JBColor.GREEN),
LOCAL_VARIABLE_PRIORITY));
}

final MathematicaGlobalResolveCache cache =
MathematicaGlobalResolveCache.getInstance(callingSymbol.getProject());
cache.getCachedFileSymbolResolves(parameters.getOriginalFile())
.forEach(symbolResolveResult -> {
if (symbolResolveResult.getElement() != null) {
result.addElement(PrioritizedLookupElement.withPriority(
LookupElementBuilder.create(symbolResolveResult.getElement()).bold(),
GLOBAL_VARIABLE_PRIORITY));
}
});

} else {
final Set<String> allSymbols = new HashSet<>();
PsiRecursiveElementVisitor visitor = new PsiRecursiveElementVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class SymbolAnnotator : Annotator {
/** Annotates a [symbol] by checking its localization */
override fun annotate(symbol: PsiElement, holder: AnnotationHolder) {
if (symbol is Symbol) {
symbol.resolve()
val scope = symbol.localizationConstruct
val scopeType = scope.type
if (LocalizationConstruct.MScope.NULL_SCOPE == scope) {
Expand Down

0 comments on commit 47ecca4

Please sign in to comment.