Skip to content

Commit 749452b

Browse files
committed
Implement that you can navigate to all declarations of external library symbols
1 parent 67ae628 commit 749452b

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

src/de/halirutan/mathematica/codeinsight/navigation/MathematicaGotoDeclarationProvider.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
/*
2+
* Copyright (c) 2018 Patrick Scheibe
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
123
package de.halirutan.mathematica.codeinsight.navigation;
224

325
import com.intellij.codeInsight.navigation.actions.GotoDeclarationHandler;
@@ -38,8 +60,8 @@ public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement sourceElement
3860
final ResolveResult[] resolve = symbol.multiResolve(false);
3961
if (resolve.length > 0) {
4062
final PsiElement elm = resolve[0].getElement();
41-
if (elm != null) {
42-
return new PsiElement[]{elm};
63+
if (elm instanceof Symbol) {
64+
return findDeclarations((Symbol) elm);
4365
}
4466
}
4567
}
@@ -62,7 +84,7 @@ private PsiElement[] findDeclarations(@NotNull Symbol symbol) {
6284
c.getAssignments().get(symbol.getSymbolName()).forEach(
6385
assignmentProperty -> result.add(assignmentProperty.myLhsOfAssignment));
6486
}
65-
return result.toArray(new PsiElement[result.size()]);
87+
return result.toArray(PsiElement.EMPTY_ARRAY);
6688
}
6789

6890
}

0 commit comments

Comments
 (0)