use of com.intellij.openapi.editor.LogicalPosition in project WebStormRequireJsPlugin by Fedott.
the class CompletionPathWithDotTest method testCompletionWithOneDot.
public void testCompletionWithOneDot() {
// WithOneDot
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(1, 37));
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
// WithOneDotAndSlash
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(2, 46));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assertTrue(strings.containsAll(Arrays.asList("./block", "./childWebPathFile", "./fileWithDotPath", "./fileWithTwoDotPath", "./childBlocks/childBlock")));
assertEquals(5, strings.size());
// WithOneDotAndSlashTwoChars
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(3, 56));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("./block");
// WithOneDotAndDirectory
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(4, 61));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("./childBlocks/childBlock");
// WithOneDotAndDirectoryAndSlash
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(5, 70));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("./childBlocks/childBlock");
// WithOneDotAndDirectoryAndSlashTwoChars
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(6, 80));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("./childBlocks/childBlock");
}
use of com.intellij.openapi.editor.LogicalPosition in project WebStormRequireJsPlugin by Fedott.
the class CompletionPathWithTwoDotTest method testCompletionParentWebPath.
public void testCompletionParentWebPath() {
// WithTwoDotAndDirectoryAndSlashTwoChars
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(10, 60));
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
}
use of com.intellij.openapi.editor.LogicalPosition in project WebStormRequireJsPlugin by Fedott.
the class CompletionTest method testCompletionInRootWebPathFile.
public void testCompletionInRootWebPathFile() {
myFixture.configureByFile("public/rootWebPathFile.js");
// NotFound
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(1, 40));
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
// True
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(2, 37));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("blocks/block", "blocks/childWebPathFile", "blocks/fileWithDotPath", "blocks/fileWithTwoDotPath", "blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// WithoutSlash
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(3, 44));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("blocks/block", "blocks/childWebPathFile", "blocks/fileWithDotPath", "blocks/fileWithTwoDotPath", "blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// TwoChars
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(4, 36));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("blocks/block", "blocks/childWebPathFile", "blocks/fileWithDotPath", "blocks/fileWithTwoDotPath", "blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// TwoDirectory
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(5, 56));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("blocks/childBlocks/childBlock");
// TwoDirectoryWithSlash
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(6, 66));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("blocks/childBlocks/childBlock");
// RootFound
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(7, 39));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
assert element != null;
assertEquals("'rootWebPathFile'", element.getText());
}
use of com.intellij.openapi.editor.LogicalPosition in project WebStormRequireJsPlugin by Fedott.
the class CompletionTest method testCompletion.
public void testCompletion() {
// NotFound
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(1, 40));
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
// True
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(2, 37));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("blocks/block", "blocks/childWebPathFile", "blocks/fileWithDotPath", "blocks/fileWithTwoDotPath", "blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// WithoutSlash
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(3, 44));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("blocks/block", "blocks/childWebPathFile", "blocks/fileWithDotPath", "blocks/fileWithTwoDotPath", "blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// TwoChars
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(4, 36));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("blocks/block", "blocks/childWebPathFile", "blocks/fileWithDotPath", "blocks/fileWithTwoDotPath", "blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// TwoDirectory
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(5, 56));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("blocks/childBlocks/childBlock");
// TwoDirectoryWithSlash
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(6, 66));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("blocks/childBlocks/childBlock");
// RootFound
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(7, 39));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
assert element != null;
assertEquals("'rootWebPathFile'", element.getText());
}
use of com.intellij.openapi.editor.LogicalPosition in project WebStormRequireJsPlugin by Fedott.
the class CompletionTest method testCompletionWithBaseUrl.
public void testCompletionWithBaseUrl() {
List<String> strings;
PsiElement element;
myFixture.configureByFiles("public/fileForTestBaseUrl.js", "public/mainWithBaseUrl.js");
Settings.getInstance(getProject()).configFilePath = "mainWithBaseUrl.js";
// NotFound
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(1, 40));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
// 1
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(2, 29));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assertNull(strings);
element = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
assert element != null;
assertEquals("'block'", element.getText());
// 2
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(3, 34));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
element = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
assert element != null;
assertEquals("'childBlocks/childBlock'", element.getText());
// 3
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(4, 39));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("childBlocks/childBlock");
// 4
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(5, 41));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
element = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
assert element != null;
assertEquals("'childBlocks/childBlock'", element.getText());
// 5
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(6, 33));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.containsAll(Arrays.asList("/blocks/block", "/blocks/childWebPathFile", "/blocks/fileWithDotPath", "/blocks/fileWithTwoDotPath", "/blocks/childBlocks/childBlock")));
assertEquals(5, strings.size());
// 6
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(7, 37));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("/blocks/block");
// 7
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(8, 50));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
// 8
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(9, 38));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings == null;
assertCompletionSingle("./blocks/block");
// 9
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(10, 30));
myFixture.complete(CompletionType.BASIC, 1);
strings = myFixture.getLookupElementStrings();
assert strings != null;
assertTrue(strings.isEmpty());
assertEquals(0, strings.size());
}
Aggregations