當前位置: 首頁>>代碼示例>>Java>>正文


Java LookupElement類代碼示例

本文整理匯總了Java中com.intellij.codeInsight.lookup.LookupElement的典型用法代碼示例。如果您正苦於以下問題:Java LookupElement類的具體用法?Java LookupElement怎麽用?Java LookupElement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LookupElement類屬於com.intellij.codeInsight.lookup包,在下文中一共展示了LookupElement類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleInsert

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@Override
public void handleInsert(final InsertionContext insertionContext,
    final LookupElement lookupElement) {
  if (shouldUseQuotes(lookupElement)) {
    final boolean hasDoubleQuotes =
        hasStartingOrEndingQuoteOfType(insertionContext, lookupElement, DOUBLE_QUOTE);

    if (hasDoubleQuotes) {
      handleEndingQuote(insertionContext, DOUBLE_QUOTE);
      handleStartingQuote(insertionContext, lookupElement, DOUBLE_QUOTE);
    } else {
      handleEndingQuote(insertionContext, SINGLE_QUOTE);
      handleStartingQuote(insertionContext, lookupElement, SINGLE_QUOTE);
    }
  }
}
 
開發者ID:1tontech,項目名稱:intellij-spring-assistant,代碼行數:17,代碼來源:YamlValueInsertHandler.java

示例2: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    Collection<TSVarExpr> globals = TSUtil.getGlobalList(project);
    List<LookupElement> variants = new ArrayList<>();

    for (final TSVarExpr global : globals) {
        if (global.getName() != null && global.getName().length() > 0) {
            variants.add(LookupElementBuilder.create(global)
                    .withIcon(TSIcons.FILE)
                    .withTypeText(global.getContainingFile().getName())
                    .withCaseSensitivity(false)

            );
        }
    }

    return variants.toArray();
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:21,代碼來源:TSGlobalVariableReference.java

示例3: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project);
    List<LookupElement> variants = new ArrayList<>();

    for (final TSFnDeclStmt function : functions) {
        if (function.getFunctionName() != null && function.getFunctionName().length() > 0) {
            variants.add(LookupElementBuilder.create(function)
                    .withIcon(TSIcons.FILE)
                    .withTypeText(function.getContainingFile().getName())
                    .withCaseSensitivity(false)

            );
        }
    }

    return variants.toArray();
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:21,代碼來源:TSFunctionCallReference.java

示例4: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    Collection<TSObjectExpr> globals = TSUtil.getObjectList(project);
    List<LookupElement> variants = new ArrayList<>();

    for (final TSObjectExpr global : globals) {
        if (global.getName() != null && global.getName().length() > 0) {
            variants.add(LookupElementBuilder.create(global)
                    .withIcon(TSIcons.FILE)
                    .withTypeText(global.getContainingFile().getName())
                    .withCaseSensitivity(false)

            );
        }
    }

    return variants.toArray();
}
 
開發者ID:CouleeApps,項目名稱:TS-IJ,代碼行數:21,代碼來源:TSLiteralReference.java

示例5: addLookupElement

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
private void addLookupElement(List<LookupElement> lookupElements, PsiElement el) {
  if (!el.isValid()) return;
  LookupElementBuilder builder;
  if (el instanceof DictionaryComponent) {
    DictionaryComponent dc = (DictionaryComponent) el;
    String dName = dc.getDictionary().getName();
    builder = LookupElementBuilder.createWithIcon(dc).appendTailText("   " + dName, true);
  } else if (el instanceof AppleScriptComponent) {
    builder = LookupElementBuilder.createWithIcon((AppleScriptComponent) el);
    if (el instanceof AppleScriptHandlerPositionalParametersDefinition) {
      AppleScriptHandlerPositionalParametersDefinition handlerCall = (AppleScriptHandlerPositionalParametersDefinition) el;
      builder = builder.withInsertHandler(handlerCall.getFormalParameterList() != null ?
          ParenthesesInsertHandler.WITH_PARAMETERS : ParenthesesInsertHandler.NO_PARAMETERS);
    }
  } else {
    builder = LookupElementBuilder.create(el);
  }
  AppleScriptComponentType componentType = AppleScriptComponentType.typeOf(el);
  String typeText = componentType != null ? componentType.toString().toLowerCase() : null;
  builder = builder.withTypeText(typeText, null, true);
  lookupElements.add(builder);
}
 
開發者ID:ant-druha,項目名稱:AppleScript-IDEA,代碼行數:23,代碼來源:AppleScriptReferenceElementImpl.java

示例6: testReferenceCanResolveVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
public void testReferenceCanResolveVariants() {
    PsiFile file = myFixture.configureByText(PhpFileType.INSTANCE, "<?php \n" +
            "\"LLL:EXT:foo/sample.xlf:sys_<caret>language.language_isocode.ab\";");

    PsiElement elementAtCaret = file.findElementAt(myFixture.getCaretOffset()).getParent();
    PsiReference[] references = elementAtCaret.getReferences();
    for (PsiReference reference : references) {
        if (reference instanceof TranslationReference) {
            Object[] variants = reference.getVariants();
            for (Object variant : variants) {
                if (variant instanceof LookupElement) {
                    String lookupString = ((LookupElement) variant).getLookupString();
                    assertEquals("LLL:EXT:foo/sample.xlf:sys_language.language_isocode.ab", lookupString);
                    return;
                }
            }

        }
    }

    fail("No TranslationReference found");
}
 
開發者ID:cedricziel,項目名稱:idea-php-typo3-plugin,代碼行數:23,代碼來源:TranslationReferenceTest.java

示例7: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
public Object[] getVariants() {
    Project project = myElement.getProject();
    List<GCMTypeDeclaration> properties = GCMUtil.findProperties(project);
    List<LookupElement> variants = new ArrayList<LookupElement>();
    for (final GCMTypeDeclaration property : properties) {
        if (property != null && property.getName() != null && property.getName().length() > 0) {
            variants.add(LookupElementBuilder.create(property).
                    withIcon(GCMIcons.GCM_ICON_16x16).
                    withTypeText(property.getContainingFile().getName())
            );
        }
    }
    return variants.toArray();
}
 
開發者ID:datathings,項目名稱:greycat-idea-plugin,代碼行數:17,代碼來源:GCMReference.java

示例8: getSubCompletions

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
private List<LookupElement> getSubCompletions(PsiElement psiElement)
{
    JSProperty property = PsiTreeUtil.getParentOfType(psiElement, JSProperty.class);

    if (property == null)
    {
        return Collections.emptyList();
    }

    String name = property.getQualifiedName();

    if (name == null)
    {
        return Collections.emptyList();
    }

    Setting setting = CompletionPreloader
        .getCompletions()
        .getSetting(name);

    return setting != null ? setting.getSubCompletionVariants() : Collections.emptyList();
}
 
開發者ID:whitefire,項目名稱:roc-completion,代碼行數:23,代碼來源:RocSettingsProvider.java

示例9: apply

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@Override
public final boolean apply(@Nullable final Object input) {
  if (input == null) {
    return false;
  }
  if (myFilter == null) {
    return true; // No need to check
  }
  if (!(input instanceof LookupElement)) {
    return true; // Do not know how to check
  }
  final PyElement pyElement = PyUtil.as(((LookupElement)input).getPsiElement(), PyElement.class);
  if (pyElement == null) {
    return false;
  }
  return myFilter.process(pyElement);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:PyCustomType.java

示例10: createLookupElement

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
protected LookupElement createLookupElement(@NotNull PsiMember member, @NotNull final PsiClass containingClass, boolean shouldImport) {
  shouldImport |= myOriginalPosition != null && PsiTreeUtil.isAncestor(containingClass, myOriginalPosition, false);

  if (member instanceof PsiMethod) {
    return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new GlobalMethodCallElement((PsiMethod)member, shouldImport, false));
  }
  return AutoCompletionPolicy.NEVER_AUTOCOMPLETE.applyPolicy(new VariableLookupItem((PsiField)member, shouldImport) {
    @Override
    public void handleInsert(InsertionContext context) {
      FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.GLOBAL_MEMBER_NAME);

      super.handleInsert(context);
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:JavaStaticMemberProcessor.java

示例11: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
public Object[] getVariants() {
    List<LookupElement> variants = new ArrayList<>();

    Collection<ENCLOSED_TYPE> enclosedTypes = SmcPsiUtil.getElementsByTypeWithinParentType(myElement, enclosingTypeClass, enclosedTypeClass);
    for (final ENCLOSED_TYPE enclosed : enclosedTypes) {
        if (!StringUtil.isEmpty(enclosed.getName())) {
            variants.add(LookupElementBuilder.create(enclosed).
                    withIcon(getFile()).
                    withTypeText(enclosed.getContainingFile().getName())
            );
        }
    }
    return variants.toArray();
}
 
開發者ID:menshele,項目名稱:smcplugin,代碼行數:17,代碼來源:AbstractNamedLocalReference.java

示例12: addConstantsFromReferencedClassesInSwitch

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
private void addConstantsFromReferencedClassesInSwitch(final Consumer<LookupElement> results) {
  final Set<PsiField> fields = ReferenceExpressionCompletionContributor.findConstantsUsedInSwitch(myPlace);
  final Set<PsiClass> classes = new HashSet<PsiClass>();
  for (PsiField field : fields) {
    ContainerUtil.addIfNotNull(classes, field.getContainingClass());
  }
  for (PsiClass aClass : classes) {
    processMembers(new Consumer<LookupElement>() {
      @Override
      public void consume(LookupElement element) {
        //noinspection SuspiciousMethodCalls
        if (!fields.contains(element.getObject())) {
          results.consume(TailTypeDecorator.withTail(element, TailType.CASE_COLON));
        }
      }
    }, aClass, true, false);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:JavaMembersGetter.java

示例13: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
protected List<LookupElement> getVariants(@NotNull final DataNode<ProjectData> projectDataNode, @NotNull final String modulePath) {
  final DataNode<ModuleData> moduleDataNode = findModuleDataNode(projectDataNode, modulePath);
  if (moduleDataNode == null) {
    return Collections.emptyList();
  }

  final ModuleData moduleData = moduleDataNode.getData();
  final boolean isRoot = projectDataNode.getData().getLinkedExternalProjectPath().equals(moduleData.getLinkedExternalProjectPath());
  final Collection<DataNode<TaskData>> tasks = ExternalSystemApiUtil.getChildren(moduleDataNode, ProjectKeys.TASK);
  List<LookupElement> elements = ContainerUtil.newArrayListWithCapacity(tasks.size());

  for (DataNode<TaskData> taskDataNode : tasks) {
    final TaskData taskData = taskDataNode.getData();
    elements.add(LookupElementBuilder.create(taskData.getName()).withIcon(ExternalSystemIcons.Task));
    if (!taskData.isInherited()) {
      elements.add(LookupElementBuilder.create((isRoot ? ':' : moduleData.getId() + ':') + taskData.getName())
                     .withIcon(ExternalSystemIcons.Task));
    }
  }
  return elements;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:GradleArgumentsCompletionProvider.java

示例14: getVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
@NotNull
@Override
public Object[] getVariants() {
  final Project project = myElement.getProject();
  PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(project);
  final List<LookupElement> variants = new ArrayList<LookupElement>();
  referenceManager.processPropertiesFiles(GlobalSearchScopesCore.projectProductionScope(project), new PropertiesFileProcessor() {
    public boolean process(String baseName, PropertiesFile propertiesFile) {
      final Icon icon = propertiesFile.getContainingFile().getIcon(Iconable.ICON_FLAG_READ_STATUS);
      final String relativePath = ProjectUtil.calcRelativeToProjectPath(propertiesFile.getVirtualFile(), project);
      variants.add(LookupElementBuilder.create(propertiesFile, baseName)
                     .withIcon(icon)
                     .withTailText(" (" + relativePath + ")", true));
      return true;
    }
  }, this);
  return variants.toArray(new LookupElement[variants.size()]);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:I18nReferenceContributor.java

示例15: addWordCompletionVariants

import com.intellij.codeInsight.lookup.LookupElement; //導入依賴的package包/類
public static void addWordCompletionVariants(CompletionResultSet result, final CompletionParameters parameters, Set<String> excludes) {
  final Set<String> realExcludes = new HashSet<String>(excludes);
  for (String exclude : excludes) {
    String[] words = exclude.split("[ \\.-]");
    if (words.length > 0 && StringUtil.isNotEmpty(words[0])) {
      realExcludes.add(words[0]);
    }
  }
  
  int startOffset = parameters.getOffset();
  final PsiElement position = parameters.getPosition();
  final CompletionResultSet javaResultSet = result.withPrefixMatcher(CompletionUtil.findJavaIdentifierPrefix(parameters));
  final CompletionResultSet plainResultSet = result.withPrefixMatcher(CompletionUtil.findAlphanumericPrefix(parameters));
  for (final String word : getAllWords(position, startOffset)) {
    if (!realExcludes.contains(word)) {
      final LookupElement item = LookupElementBuilder.create(word);
      javaResultSet.addElement(item);
      plainResultSet.addElement(item);
    }
  }

  addValuesFromOtherStringLiterals(result, parameters, realExcludes, position);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:WordCompletionContributor.java


注:本文中的com.intellij.codeInsight.lookup.LookupElement類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。