added tests for selection

This commit is contained in:
Ekaterina Tuzova
2010-12-01 20:22:04 +03:00
parent e08de42bc5
commit df4c869d1a
10 changed files with 22 additions and 2 deletions
@@ -3,6 +3,7 @@ package com.jetbrains.python.codeInsight;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
@@ -88,8 +89,11 @@ public class PyDictKeyNamesCompletionContributor extends PySeeingOriginalComplet
private static CompletionResultSet createResult(PsiElement original, CompletionResultSet result) {
PsiElement prevElement = original.getPrevSibling();
if (prevElement != null) {
if (prevElement.getNode().getElementType() != PyTokenTypes.LBRACKET)
return result.withPrefixMatcher(findPrefix(prevElement));
ASTNode prevNode = prevElement.getNode();
if (prevNode != null) {
if (prevNode.getElementType() != PyTokenTypes.LBRACKET)
return result.withPrefixMatcher(findPrefix(prevElement));
}
}
PsiElement parentElement = original.getParent();
if (parentElement != null) {
@@ -0,0 +1 @@
d = {'school_id':parent_id, "next": <selection>next</selection>}
@@ -0,0 +1 @@
d = {'school_id':parent_id, <selection>"next": next</selection>}
@@ -0,0 +1 @@
d = {'school_id':parent_id<selection>, "next": next</selection>}
@@ -0,0 +1 @@
d = {'school_id':parent_id, "next": ne<caret>xt}
@@ -0,0 +1 @@
x = [1, 2, 3, <selection>4</selection>]
@@ -0,0 +1 @@
x = [1, 2, 3<selection>, 4</selection>]
@@ -0,0 +1 @@
x = [<selection>1, 2, 3, 4</selection>]
@@ -0,0 +1 @@
x = [1, 2, 3, 4<caret>]
@@ -23,6 +23,14 @@ public class PySelectWordTest extends PyLightFixtureTestCase {
doTest();
}
public void testList() { // PY-1686
doTest();
}
public void testComma() { // PY-1378
doTest();
}
private void doTest() {
@NonNls final String path = "selectWord/" + getTestName(true);
myFixture.copyDirectoryToProject(path, path);