Skip to content

Commit

Permalink
Added guards to prevent exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
halirutan committed Jan 26, 2017
1 parent f81f485 commit f30f5d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
10 changes: 2 additions & 8 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<id>de.halirutan.mathematica</id>
<name>Mathematica Support</name>
<category>Custom Language</category>
<version>2.0.20</version>
<version>2.0.21</version>
<idea-version since-build="163"/>
<vendor email="[email protected]" url="http://mathematicaplugin.halirutan.de">Patrick Scheibe</vendor>
<depends>com.intellij.modules.lang</depends>
Expand Down Expand Up @@ -67,13 +67,7 @@
<i>New features and bug-fixes:</i>
<br/>
<ul>
<li>Improvement of syntax highlighting for full names of symbols inside scoping constructs (<a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/52">GH-52</a>)</li>
<li>Recognize function names in usage messages (<a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/58">GH-58</a>)</li>
<li>Improved highlighting settings colors (<a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/47">GH-47</a>)</li>
<li>Fixed smart-completion of Options that stopped working (<a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/30">GH-30</a>)</li>
<li>Fixed some localization constructs and added unicode of the Eth symbol (<a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/26">GH-26</a> and <a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/27">GH-27</a>)</li>
<li>Made indentation for Association brackets like the indentation for lists <a href="https://github.com/halirutan/Mathematica-IntelliJ-Plugin/issues/20">(GH-20)</a></li>
<li>Fixed the renaming engine so that renamed variables can now have context back-ticks</li>
<li>Added guard to fix exception (<a href="https://halirutan.myjetbrains.com/youtrack/issue/MMAP-88">MMAP-88</a>)</li>
</ul>
]]>
</change-notes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class MathematicaCharFilter extends CharFilter {
@Nullable
@Override
public Result acceptChar(final char c, final int prefixLength, final Lookup lookup) {
if (!lookup.isCompletion()) return null;
final PsiFile psiFile = lookup.getPsiFile();
if (psiFile == null || !(psiFile.getFileType() instanceof MathematicaFileType)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016 Patrick Scheibe
* Copyright (c) 2017 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
Expand All @@ -26,7 +26,6 @@
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.util.ProcessingContext;
import de.halirutan.mathematica.parsing.psi.api.Symbol;
import de.halirutan.mathematica.parsing.psi.api.string.MString;
import de.halirutan.mathematica.parsing.psi.impl.SymbolPsiReference;
import org.jetbrains.annotations.NotNull;

Expand All @@ -42,7 +41,7 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNu
if (!(element instanceof Symbol)) {
return new PsiReference[0];
}
ArrayList<PsiReference> result = new ArrayList<PsiReference>();
ArrayList<PsiReference> result = new ArrayList<>();

Symbol symbol = (Symbol) element;
final SymbolPsiReference reference = (SymbolPsiReference) symbol.getReference();
Expand All @@ -52,8 +51,10 @@ public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNu
resolve = reference.resolve();
if (resolve instanceof Symbol) {
final PsiElement[] elemsReferencingToMe = ((Symbol) resolve).getElementsReferencingToMe();
for (PsiElement psiElement : elemsReferencingToMe) {
result.add(psiElement.getReference());
if (elemsReferencingToMe != null) {
for (PsiElement psiElement : elemsReferencingToMe) {
result.add(psiElement.getReference());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013 Patrick Scheibe
* Copyright (c) 2017 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
Expand Down Expand Up @@ -168,6 +168,7 @@ public void addElementReferencingToMe(Symbol reference) {

@Override
public PsiElement[] getElementsReferencingToMe() {
if (myReferringElements.isEmpty()) return new PsiElement[0];
return myReferringElements.toArray(new Symbol[myReferringElements.size()]);
}

Expand Down

0 comments on commit f30f5d6

Please sign in to comment.