Skip to content

Commit

Permalink
Implement several separate caches and adapt code
Browse files Browse the repository at this point in the history
  • Loading branch information
halirutan committed Dec 1, 2017
1 parent 914efff commit ed61bca
Show file tree
Hide file tree
Showing 54 changed files with 900 additions and 616 deletions.
13 changes: 0 additions & 13 deletions Mathematica-IntelliJ-Plugin.iml

This file was deleted.

5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ buildscript {
maven {
url 'http://dl.bintray.com/jetbrains/intellij-plugin-service'
}
maven {
url 'http://dl.bintray.com/kotlin/kotlin-eap-1.2'
}
}

dependencies {
Expand Down Expand Up @@ -72,7 +75,7 @@ task wrapper(type: Wrapper) {
// Information about the plugin

// Plugin version number
version '3.0pre1'
version '3.0pre2'

intellij {
version = '2017.2.5'
Expand Down
4 changes: 3 additions & 1 deletion resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@

<applicationService serviceInterface="de.halirutan.mathematica.codeinsight.folding.MathematicaCodeFoldingSettingsImpl" serviceImplementation="de.halirutan.mathematica.codeinsight.folding.MathematicaCodeFoldingSettingsImpl"/>
<codeFoldingOptionsProvider instance="de.halirutan.mathematica.codeinsight.folding.MathematicaFoldingOptionProvider"/>

<!-- Code-style and colors-->
<colorSettingsPage implementation="de.halirutan.mathematica.codeinsight.highlighting.MathematicaColorSettingsPage"/>
<codeStyleSettingsProvider implementation="de.halirutan.mathematica.codeinsight.formatter.settings.MathematicaCodeStyleSettingsProvider"/>
Expand All @@ -105,13 +104,16 @@
<spellchecker.support language="Mathematica" implementationClass="de.halirutan.mathematica.codeinsight.spellcheck.MathematicaSpellCheck"/>
<spellchecker.bundledDictionaryProvider implementation="de.halirutan.mathematica.codeinsight.spellcheck.MathematicaDictionaryProvider"/>

<projectService serviceInterface="de.halirutan.mathematica.lang.resolve.MathematicaGlobalResolveCache" serviceImplementation="de.halirutan.mathematica.lang.resolve.MathematicaGlobalResolveCache"/>
<intentionAction>
<className>de.halirutan.mathematica.intentions.localization.MoveVariableToLocalisation</className>
</intentionAction>
<!--<findUsagesHandlerFactory implementation="de.halirutan.mathematica.find.MathematicaFindUsageHandlerFactory"/>-->

<errorHandler implementation="de.halirutan.mathematica.errorreporting.GitHubErrorReporter"/>
<referencesSearch implementation="de.halirutan.mathematica.lang.search.MathematicaReferenceSearch"/>
<gotoDeclarationHandler implementation="de.halirutan.mathematica.codeinsight.navigation.MathematicaGotoDeclarationProvider"/>


</extensions>

Expand Down
10 changes: 9 additions & 1 deletion resources/colors/MathematicaDarcula.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
</value>
</option>

<option name="MMA.IMPORTED_SYMBOL">
<option name="MMA.UNKNOWN_SYMBOL">
<value>
<option name="FOREGROUND" value="A9B7C6"/>
<option name="EFFECT_COLOR" value="AA8080"/>
<option name="EFFECT_TYPE" value="2"/>
</value>
</option>

<option name="MMA.IMPORTED_SYMBOL">
<value>
<option name="FOREGROUND" value="A9B7C6"/>
<option name="EFFECT_COLOR" value="808080"/>
Expand Down
8 changes: 8 additions & 0 deletions resources/colors/MathematicaDefault.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
</value>
</option>

<option name="MMA.UNKNOWN_SYMBOL">
<value>
<option name="FOREGROUND" value="000000"/>
<option name="EFFECT_COLOR" value="AA8080"/>
<option name="EFFECT_TYPE" value="2"/>
</value>
</option>

<option name="MMA.IMPORTED_SYMBOL">
<value>
<option name="FOREGROUND" value="000000"/>
Expand Down
44 changes: 25 additions & 19 deletions resources/de/halirutan/mathematica/MathematicaBundle.properties
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
#
# Copyright (c) 2014 Patrick Scheibe
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# Copyright (c) 2017 Patrick Scheibe
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

language.name=Mathematica
Expand All @@ -33,11 +35,13 @@ module.type.description=Creates an empty project or module for custom layouts.
module.type.name=Empty Module
project.template.mathematica=Mathematica
project.template.basic=Basic Package
project.template.basic.description=A basic Mathematica package provides a simple package file and a notebook. Use this for simple or moderately sized Mathematica packages.
project.template.application=Mathematica Application
project.template.application.description=A Mathematica application is used for large packages and more complicated applications.
project.template.empty=Empty Mathematica Module
project.template.empty.description=An empty module where you can set the file structure yourself
project.template.test=Unit Test Module
project.template.documentation=Documentation Module
project.template.basic.description=A basic Mathematica package provides a simple package file and a notebook. Use this for simple or moderately sized Mathematica packages.
project.template.application.description=A Mathematica application is used for large packages and more complicated applications.
project.template.test.description=Unit test module
project.template.documentation.description=Documentation module
surround.anonymous.function.description=Anonymous function
Expand All @@ -47,4 +51,6 @@ structureview.grouper.by.symbol.name.text=Group by Name
structureview.grouper.by.type.description=Groups all assignments by their type
structureview.grouper.by.type.text=Group by Assignment Type
structureview.sorter.by.appearance.text=Sort by Appearance
structureview.sorter.by.appearance.description=Sorts the entries by appearance in the source file.
structureview.sorter.by.appearance.description=Sorts the entries by appearance in the source file.
library.new=Mathematica Library
library.description=A Mathematica package directory that acts as library

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

import com.intellij.codeInsight.completion.CompletionContributor;
import com.intellij.codeInsight.completion.CompletionInitializationContext;
import de.halirutan.mathematica.codeinsight.completion.providers.BuiltinFunctionCompletionProvider;
import de.halirutan.mathematica.codeinsight.completion.providers.CommentCompletionProvider;
import de.halirutan.mathematica.codeinsight.completion.providers.FileSymbolCompletion;
import de.halirutan.mathematica.codeinsight.completion.providers.ImportedSymbolCompletion;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -33,10 +37,16 @@
*/
public class MathematicaCompletionContributor extends CompletionContributor {

public static final double LOCAL_VARIABLE_PRIORITY = 4000;
public static final double GLOBAL_VARIABLE_PRIORITY = 3500;
public static final double IMPORT_VARIABLE_PRIORITY = 3000;


public MathematicaCompletionContributor() {
new BuiltinFunctionCompletionProvider().addTo(this);
new FileSymbolCompletion().addTo(this);
new ImportedSymbolCompletion().addTo(this);
new SmartContextAwareCompletion().addTo(this);
new VariableNameCompletion().addTo(this);
new CommentCompletionProvider().addTo(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
import com.intellij.patterns.PsiElementPattern.Capture;
import com.intellij.psi.PsiElement;
import com.intellij.util.ProcessingContext;
import de.halirutan.mathematica.util.MathematicaIcons;
import de.halirutan.mathematica.codeinsight.completion.SymbolInformationProvider.SymbolInformation;
import de.halirutan.mathematica.codeinsight.completion.providers.MathematicaCompletionProvider;
import de.halirutan.mathematica.lang.psi.MathematicaRecursiveVisitor;
import de.halirutan.mathematica.lang.psi.api.FunctionCall;
import de.halirutan.mathematica.lang.psi.api.MessageName;
import de.halirutan.mathematica.lang.psi.api.Symbol;
import de.halirutan.mathematica.util.MathematicaIcons;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
Expand All @@ -57,13 +58,12 @@ class SmartContextAwareCompletion extends MathematicaCompletionProvider {


private static final HashMap<String, SymbolInformation> ourSymbolInformation = SymbolInformationProvider.getSymbolNames();
private static final HashSet<String> ourOptionsWithSetDelayed = new HashSet<>(Arrays.asList(new String[]{
"EvaluationMonitor", "StepMonitor", "DisplayFunction", "Deinitialization", "DisplayFunction",
"DistributedContexts", "Initialization", "UnsavedVariables", "UntrackedVariables"
}));
private static final HashSet<String> ourOptionsWithSetDelayed = new HashSet<>(
Arrays.asList("EvaluationMonitor", "StepMonitor", "DisplayFunction", "Deinitialization", "DisplayFunction",
"DistributedContexts", "Initialization", "UnsavedVariables", "UntrackedVariables"));

@Override
void addTo(CompletionContributor contributor) {
public void addTo(CompletionContributor contributor) {
final Capture<PsiElement> funcPattern = psiElement().withSuperParent(2, FunctionCall.class);
contributor.extend(CompletionType.SMART, funcPattern, this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public static HashMap<String, SymbolInformation> getSymbolNames() {
public static class SymbolInformation {
public final String name;
public final int importance;
public final String callPattern;
final String callPattern;
public final boolean function;
public final String attributes[];
final String[] attributes;
public final String options[];
public final String context;
public final String nameWithoutContext;
Expand All @@ -120,7 +120,7 @@ public static class SymbolInformation {
* Removes the braces around the call patter
* @return call pattern without braces
*/
String getCallPattern() {
public String getCallPattern() {
if (callPattern.length() > 2 && callPattern.matches("\\{.*}")) {
return callPattern.substring(1, callPattern.length() - 1);
}
Expand Down
Loading

0 comments on commit ed61bca

Please sign in to comment.