-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix issue, where completion and resolving showed symbols that came from a completely different project. The reason was that GlobalSearchScope does not work as one would expect. This issue is fixed now and resolving of external symbols from other files or libraries should work correctly. - Fix for a minor issue in resolving patterns from Rule. In a_ -> a, the a_ should be green while the a is a global symbol - External Mathematica libraries are now regarded as "being compiled" to make navigation and resolving work correctly. You need to recreate your libraries in your project settings! - Fix local resolving of Condition expressions - Fix for the FullForm viewer
- Loading branch information
Showing
17 changed files
with
459 additions
and
376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (c) 2018 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: | ||
* | ||
* 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. | ||
*/ | ||
|
||
package de.halirutan.mathematica; | ||
|
||
import com.intellij.notification.NotificationDisplayType; | ||
import com.intellij.notification.NotificationGroup; | ||
import com.intellij.notification.NotificationType; | ||
import de.halirutan.mathematica.util.MathematicaIcons; | ||
|
||
/** | ||
* @author patrick (06.05.18). | ||
*/ | ||
public class MathematicaNotification { | ||
private static final NotificationGroup GROUP = new NotificationGroup( | ||
MathematicaBundle.message("mathematica.notification.group"), | ||
NotificationDisplayType.BALLOON, | ||
false, | ||
null, | ||
MathematicaIcons.FILE_ICON); | ||
|
||
public static void info(String message) { | ||
showNotification(message, NotificationType.INFORMATION); | ||
} | ||
|
||
public static void warning(String message) { | ||
showNotification(message, NotificationType.WARNING); | ||
} | ||
|
||
public static void error(String message) { | ||
showNotification(message, NotificationType.ERROR); | ||
} | ||
|
||
private static void showNotification(String message, NotificationType type) { | ||
GROUP.createNotification( | ||
MathematicaBundle.message("language.name"), | ||
message, | ||
type, | ||
null).notify(null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 0 additions & 96 deletions
96
src/de/halirutan/mathematica/codeinsight/completion/providers/ImportedSymbolCompletion.java
This file was deleted.
Oops, something went wrong.
85 changes: 85 additions & 0 deletions
85
src/de/halirutan/mathematica/codeinsight/completion/providers/ImportedSymbolCompletion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (c) 2018 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: | ||
* | ||
* 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. | ||
*/ | ||
|
||
package de.halirutan.mathematica.codeinsight.completion.providers | ||
|
||
import com.intellij.codeInsight.completion.CompletionContributor | ||
import com.intellij.codeInsight.completion.CompletionParameters | ||
import com.intellij.codeInsight.completion.CompletionResultSet | ||
import com.intellij.codeInsight.completion.CompletionType | ||
import com.intellij.codeInsight.completion.PrioritizedLookupElement | ||
import com.intellij.codeInsight.lookup.LookupElementBuilder | ||
import com.intellij.openapi.module.ModuleUtilCore | ||
import com.intellij.openapi.progress.ProgressManager | ||
import com.intellij.patterns.PlatformPatterns.psiElement | ||
import com.intellij.util.ProcessingContext | ||
import com.intellij.util.indexing.FileBasedIndex | ||
import de.halirutan.mathematica.codeinsight.completion.MathematicaCompletionContributor.IMPORT_VARIABLE_PRIORITY | ||
import de.halirutan.mathematica.index.packageexport.MathematicaPackageExportIndex | ||
import de.halirutan.mathematica.lang.parsing.MathematicaElementTypes | ||
import de.halirutan.mathematica.lang.psi.api.Symbol | ||
|
||
|
||
/** | ||
* Accesses the file index to provide completion for functions that are defined in other packages. | ||
*/ | ||
class ImportedSymbolCompletion : MathematicaCompletionProvider() { | ||
|
||
override fun addTo(contributor: CompletionContributor) { | ||
val symbolPattern = psiElement().withElementType(MathematicaElementTypes.IDENTIFIER) | ||
contributor.extend(CompletionType.BASIC, symbolPattern, this) | ||
} | ||
|
||
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) { | ||
val callingSymbol = parameters.position.parent | ||
val project = callingSymbol.project | ||
|
||
val prefix = findCurrentText(parameters, parameters.position) | ||
if (parameters.invocationCount == 0 && prefix.isEmpty() || callingSymbol !is Symbol) { | ||
return | ||
} | ||
val originalFile = parameters.originalFile | ||
val module = ModuleUtilCore.findModuleForFile(originalFile.virtualFile, project) | ||
if (module != null) { | ||
val moduleScope = module.getModuleWithDependenciesAndLibrariesScope(true) | ||
val index = FileBasedIndex.getInstance() | ||
val indexID = MathematicaPackageExportIndex.INDEX_ID | ||
index.getAllKeys(indexID, project).forEach { | ||
it?.let { | ||
val inScope = !index.processValues( | ||
indexID, | ||
it, | ||
null, | ||
{ _, _ -> false }, | ||
moduleScope | ||
) | ||
ProgressManager.checkCanceled() | ||
if (inScope && it.isExported) { | ||
result.addElement(PrioritizedLookupElement.withPriority( | ||
LookupElementBuilder.create(it.symbol).withTypeText("(" + it.fileName + ")", true), | ||
IMPORT_VARIABLE_PRIORITY)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.