use of com.intellij.codeInsight.lookup.LookupElement in project intellij-plugins by JetBrains.
the class CompletionTest method doTest.
private void doTest() {
final String testName = getTestName(true);
myFixture.configureByFile(testName + ".feature");
LookupElement[] result = myFixture.completeBasic();
LookupElement scenarioOutlineLookupElement = null;
for (LookupElement lookupElement : result) {
if (lookupElement.getUserDataString().contains("Scenario")) {
scenarioOutlineLookupElement = lookupElement;
break;
}
}
assert scenarioOutlineLookupElement != null;
myFixture.getLookup().setCurrentItem(scenarioOutlineLookupElement);
myFixture.finishLookup(Lookup.REPLACE_SELECT_CHAR);
myFixture.checkResultByFile(testName + "_after.feature");
}
use of com.intellij.codeInsight.lookup.LookupElement in project android by JetBrains.
the class AndroidLayoutDomTest method testDimenUnitsCompletion1.
public void testDimenUnitsCompletion1() throws Exception {
VirtualFile file = copyFileToProject(getTestName(true) + ".xml");
myFixture.configureFromExistingVirtualFile(file);
myFixture.complete(CompletionType.BASIC);
UsefulTestCase.assertSameElements(myFixture.getLookupElementStrings(), "3dp", "3px", "3sp", "3pt", "3mm", "3in");
PsiElement originalElement = myFixture.getFile().findElementAt(myFixture.getEditor().getCaretModel().getOffset());
LookupEx lookup = myFixture.getLookup();
LookupElement dpElement = null;
LookupElement pxElement = null;
for (LookupElement element : lookup.getItems()) {
if (element.getLookupString().endsWith("dp")) {
dpElement = element;
} else if (element.getLookupString().endsWith("px")) {
pxElement = element;
}
}
DocumentationProvider provider;
PsiElement docTargetElement;
lookup.setCurrentItem(dpElement);
docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
provider = DocumentationManager.getProviderFromElement(docTargetElement);
assertEquals("<html><body><b>Density-independent Pixels</b> - an abstract unit that is based on the physical " + "density of the screen.</body></html>", provider.generateDoc(docTargetElement, originalElement));
lookup.setCurrentItem(pxElement);
docTargetElement = DocumentationManager.getInstance(getProject()).findTargetElement(myFixture.getEditor(), myFixture.getFile(), originalElement);
provider = DocumentationManager.getProviderFromElement(docTargetElement);
assertEquals("<html><body><b>Pixels</b> - corresponds to actual pixels on the screen. Not recommended.</body></html>", provider.generateDoc(docTargetElement, originalElement));
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-plugins by JetBrains.
the class DartServerCompletionTest method selectLookup.
private void selectLookup(@NotNull final String lookupToSelect, final char completionChar) {
final LookupEx activeLookup = LookupManager.getActiveLookup(getEditor());
assertNotNull(activeLookup);
final LookupElement lookup = ContainerUtil.find(activeLookup.getItems(), element -> lookupToSelect.equals(element.getLookupString()));
assertNotNull(lookupToSelect + " is not in the completion list", lookup);
activeLookup.setCurrentItem(lookup);
myFixture.finishLookup(completionChar);
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-plugins by JetBrains.
the class ActionScriptCompletionTest method testTwoSdks.
public void testTwoSdks() throws Exception {
final Sdk sdk45 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.5"), null, true);
final Sdk sdk46 = FlexTestUtils.createSdk(FlexTestUtils.getPathToCompleteFlexSdk("4.6"), null, false);
FlexTestUtils.modifyConfigs(myProject, new Consumer<FlexProjectConfigurationEditor>() {
public void consume(final FlexProjectConfigurationEditor editor) {
ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
bc1.setName("1");
FlexTestUtils.setSdk(bc1, sdk45);
ModifiableFlexBuildConfiguration bc2 = editor.createConfiguration(myModule);
bc2.setName("2");
FlexTestUtils.setSdk(bc2, sdk46);
}
});
final FlexBuildConfigurationManager m = FlexBuildConfigurationManager.getInstance(myModule);
class TestZZ implements ThrowableRunnable<Exception> {
private final String myBcName;
private final String myExpectedTypeText;
TestZZ(final String bcName, final String expectedTypeText) {
myBcName = bcName;
myExpectedTypeText = expectedTypeText;
}
@Override
public void run() throws Exception {
m.setActiveBuildConfiguration(m.findConfigurationByName(myBcName));
defaultTest();
for (LookupElement item : myItems) {
final LookupElementPresentation p = new LookupElementPresentation();
item.renderElement(p);
assertEquals(myExpectedTypeText, p.getTypeText());
}
}
}
new TestZZ("1", sdk45.getName()).run();
new TestZZ("2", sdk46.getName()).run();
new TestZZ("1", sdk45.getName()).run();
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-plugins by JetBrains.
the class FlexCompletionInTextFieldBase method checkTextFieldCompletion.
protected void checkTextFieldCompletion(JSExpressionCodeFragment fragment, String[] included, String[] excluded, @Nullable String choose, String file) throws Exception {
doTestForEditorTextField(fragment, "", "js2", file);
assertContains(myItems, true, included);
assertContains(myItems, false, excluded);
if (choose != null) {
boolean found = false;
for (LookupElement item : myItems) {
if (choose.equals(item.getLookupString())) {
selectItem(item);
found = true;
break;
}
}
assertTrue("Item '" + choose + "' not found in lookup", found);
checkResultByFile(BASE_PATH + getTestName(false) + "_after.txt");
}
}
Aggregations