use of com.intellij.codeInsight.lookup.LookupElement in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoKeywordCompletionContributor method fillCompletionVariants.
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
super.fillCompletionVariants(parameters, result);
PsiElement position = parameters.getPosition();
if (insideGoOrDeferStatements().accepts(position) || anonymousFunction().accepts(position)) {
InsertHandler<LookupElement> insertHandler = GoKeywordCompletionProvider.createTemplateBasedInsertHandler("go_lang_anonymous_func");
result.addElement(GoKeywordCompletionProvider.createKeywordLookupElement("func", CONTEXT_KEYWORD_PRIORITY, insertHandler));
}
if (referenceExpression().accepts(position)) {
InsertHandler<LookupElement> insertHandler = GoKeywordCompletionProvider.createTemplateBasedInsertHandler("go_lang_anonymous_struct");
result.addElement(GoKeywordCompletionProvider.createKeywordLookupElement("struct", CONTEXT_KEYWORD_PRIORITY, insertHandler));
}
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-elixir by KronicDeth.
the class Variants method executeOnAliasedName.
/*
* Protected Instance Methods
*/
/**
* Decides whether {@code match} matches the criteria being searched for. All other {@link #execute} methods
* eventually end here.
*
* @param match
* @param aliasedName
* @param state
* @return {@code true} to keep processing; {@code false} to stop processing.
*/
@Override
protected boolean executeOnAliasedName(@NotNull PsiNamedElement match, @NotNull final String aliasedName, @NotNull ResolveState state) {
if (lookupElementList == null) {
lookupElementList = new ArrayList<LookupElement>();
}
lookupElementList.add(LookupElementBuilder.createWithSmartPointer(aliasedName, match));
String unaliasedName = UnaliasedName.unaliasedName(match);
if (unaliasedName != null) {
Project project = match.getProject();
Collection<String> indexedNameCollection = StubIndex.getInstance().getAllKeys(AllName.KEY, project);
List<String> unaliasedNestedNames = ContainerUtil.findAll(indexedNameCollection, new org.elixir_lang.Module.IsNestedUnder(unaliasedName));
if (unaliasedNestedNames.size() > 0) {
GlobalSearchScope scope = GlobalSearchScope.allScope(project);
for (String unaliasedNestedName : unaliasedNestedNames) {
Collection<NamedElement> unaliasedNestedNamedElementCollection = StubIndex.getElements(AllName.KEY, unaliasedNestedName, project, scope, NamedElement.class);
if (unaliasedNestedNamedElementCollection.size() > 0) {
List<String> unaliasedNestedNamePartList = split(unaliasedNestedName);
List<String> unaliasedNamePartList = split(unaliasedName);
List<String> aliasedNamePartList = split(aliasedName);
List<String> aliasedNestedNamePartList = new ArrayList<String>();
aliasedNestedNamePartList.addAll(aliasedNamePartList);
for (int i = unaliasedNamePartList.size(); i < unaliasedNestedNamePartList.size(); i++) {
aliasedNestedNamePartList.add(unaliasedNestedNamePartList.get(i));
}
String aliasedNestedName = concat(aliasedNestedNamePartList);
for (NamedElement unaliasedNestedNamedElement : unaliasedNestedNamedElementCollection) {
lookupElementList.add(LookupElementBuilder.createWithSmartPointer(aliasedNestedName, unaliasedNestedNamedElement));
}
}
}
}
}
return true;
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-elixir by KronicDeth.
the class Variants method addToLookupElementByPsiElement.
/*
* Private Instance Methods
*/
private void addToLookupElementByPsiElement(@NotNull Call call) {
if (call instanceof Named) {
Named named = (Named) call;
PsiElement nameIdentifier = named.getNameIdentifier();
if (nameIdentifier != null) {
if (lookupElementByPsiElement == null || !lookupElementByPsiElement.containsKey(nameIdentifier)) {
if (lookupElementByPsiElement == null) {
lookupElementByPsiElement = new THashMap<PsiElement, LookupElement>();
}
String name = nameIdentifier.getText();
lookupElementByPsiElement.put(nameIdentifier, LookupElementBuilder.createWithSmartPointer(name, nameIdentifier).withRenderer(new org.elixir_lang.code_insight.lookup.element_renderer.CallDefinitionClause(name)));
}
}
}
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-elixir by KronicDeth.
the class CallDefinitionClauseTest method testIssue457ShorterName.
/*
* Tests
*/
public void testIssue457ShorterName() {
String name = "fo";
LookupElement lookupElement = lookupElement(name);
LookupElementPresentation lookupElementPresentation = new LookupElementPresentation();
lookupElement.renderElement(lookupElementPresentation);
assertEquals(name, lookupElementPresentation.getItemText());
}
use of com.intellij.codeInsight.lookup.LookupElement in project intellij-elixir by KronicDeth.
the class CallDefinitionClauseTest method testIssue457LongerNameIssue503.
public void testIssue457LongerNameIssue503() {
String name = "fooo";
LookupElement lookupElement = lookupElement(name);
LookupElementPresentation lookupElementPresentation = new LookupElementPresentation();
lookupElement.renderElement(lookupElementPresentation);
assertEquals(name, lookupElementPresentation.getItemText());
}
Aggregations