Skip to content

Commit abe517f

Browse files
committed
Fixed bundle url to make it work with tests
Wrote tests for renaming
1 parent a376cf3 commit abe517f

4 files changed

Lines changed: 86 additions & 3 deletions

File tree

src/de/halirutan/mathematica/codeinsight/completion/SymbolInformationProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
*/
3333
public class SymbolInformationProvider {
3434

35-
private final static String ourSymbolInformationFile = "/de/halirutan/mathematica/codeinsight/completion/symbolInformationV11_0_1";
35+
private final static String ourSymbolInformationFile = "de.halirutan.mathematica.codeinsight.completion.symbolInformationV11_0_1";
36+
// private final static String ourSymbolInformationFile = "symbolInformationV11_0_1";
3637
private final static HashMap<String, SymbolInformation> ourSymbols;
3738

3839
private SymbolInformationProvider() {}

src/de/halirutan/mathematica/refactoring/MathematicaPsiRenameProcessor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ public Collection<PsiReference> findReferences(PsiElement element) {
5656
}
5757
return references;
5858
}
59+
5960
}

src/de/halirutan/mathematica/refactoring/MathematicaRefactoringSupport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ public boolean isAvailable(@NotNull PsiElement context) {
3939

4040
@Override
4141
public boolean isInplaceRenameAvailable(@NotNull PsiElement element, PsiElement context) {
42-
4342
return false;
4443
}
4544

4645
@Override
4746
public boolean isMemberInplaceRenameAvailable(@NotNull PsiElement element, PsiElement context) {
48-
return false;
47+
return true;
4948
}
5049

5150
@Nullable
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* Copyright (c) 2016 Patrick Scheibe
3+
* Permission is hereby granted, free of charge, to any person obtaining a copy
4+
* of this software and associated documentation files (the "Software"), to deal
5+
* in the Software without restriction, including without limitation the rights
6+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
* copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in
11+
* all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
* THE SOFTWARE.
20+
*/
21+
22+
package de.halirutan.mathematica.refactoring;
23+
24+
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
25+
import de.halirutan.mathematica.filetypes.MathematicaFileType;
26+
27+
/**
28+
* @author patrick (24.12.16).
29+
*/
30+
public class RenameTest extends LightCodeInsightFixtureTestCase{
31+
32+
public void testNormalVariable() throws Exception {
33+
myFixture.configureByText(MathematicaFileType.INSTANCE,
34+
"var1;\n" +
35+
"var1::usage = \"var1 is equal to nothing..\";\n" +
36+
"var1<caret>=1;");
37+
myFixture.renameElementAtCaret("var2");
38+
myFixture.checkResult("var2;\n" +
39+
"var2::usage = \"var2 is equal to nothing..\";\n" +
40+
"var2=1;");
41+
}
42+
43+
public void testModule() throws Exception {
44+
myFixture.configureByText(MathematicaFileType.INSTANCE,
45+
"var;\n" +
46+
"var::usage = \"var is equal to nothing..\";\n" +
47+
"var=1;\n" +
48+
"\n" +
49+
"Module[{var},\n" +
50+
" var + var<caret>\n" +
51+
" \n" +
52+
"]");
53+
myFixture.renameElementAtCaret("var2");
54+
myFixture.checkResult("var;\n" +
55+
"var::usage = \"var is equal to nothing..\";\n" +
56+
"var=1;\n" +
57+
"\n" +
58+
"Module[{var2},\n" +
59+
" var2 + var2\n" +
60+
" \n" +
61+
"]");
62+
}
63+
64+
public void testUsage() throws Exception {
65+
myFixture.configureByText(MathematicaFileType.INSTANCE,
66+
"func::usage = \"func<caret> is a function called like func[]\";");
67+
myFixture.renameElementAtCaret("newFunc");
68+
myFixture.checkResult("newFunc::usage = \"newFunc is a function called like newFunc[]\";");
69+
}
70+
71+
// This test fails du to a bug in idea
72+
// @Test
73+
// public void testDollarVariables() throws Exception {
74+
// myFixture.configureByText(MathematicaFileType.INSTANCE,
75+
// "var$ = 1;\n" +
76+
// "var$<caret> + var$");
77+
// myFixture.renameElementAtCaret("$var$");
78+
// myFixture.checkResult("$var$ = 1;\n" +
79+
// "$var$ + $var$");
80+
// }
81+
82+
}

0 commit comments

Comments
 (0)