com.intellij.codeInsight.lookup.LookupElementBuilder Java Examples

The following examples show how to use com.intellij.codeInsight.lookup.LookupElementBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private LookupElementBuilder getNodeAttributeLookupElement(Node node, Map<String, String> nodeVars, boolean isShortcut) {

        String nodeName = getNodeName(node);
        LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(nodeName).withIcon(Symfony2Icons.CONFIG_VALUE);

        String textContent = node.getTextContent();
        if(StringUtils.isNotBlank(textContent)) {
            lookupElementBuilder = lookupElementBuilder.withTailText("(" + textContent + ")", true);
        }

        if(nodeVars.containsKey(nodeName)) {
            lookupElementBuilder = lookupElementBuilder.withTypeText(StringUtil.shortenTextWithEllipsis(nodeVars.get(nodeName), 100, 0), true);
        }

        if(isShortcut) {
            lookupElementBuilder = lookupElementBuilder.withIcon(Symfony2Icons.CONFIG_VALUE_SHORTCUT);
        }

        return lookupElementBuilder;
    }
 
Example #2
Source File: LatteCompletionContributor.java    From intellij-latte with MIT License 6 votes vote down vote up
private LookupElementBuilder createBuilderForMacro(LatteTagSettings tag, boolean isEndTag) {
	String name = (isEndTag ? "/" : "") + tag.getMacroName();
	LookupElementBuilder builder = LookupElementBuilder.create(name);
	builder = builder.withInsertHandler(MacroInsertHandler.getInstance());
	if (!isEndTag) {
		String appendText = tag.getType() == LatteTagSettings.Type.PAIR ? (" … {/" + tag.getMacroName() + "}") : "";
		String arguments = tag.getArgumentsInfo();
		if (arguments.length() > 0) {
			builder = builder.withTailText(" " + arguments + "}" + appendText);
		} else {
			builder = builder.withTailText("}" + appendText);
		}
	} else {
		builder = builder.withTailText("}");
	}

	if (tag.isDeprecated()) {
		builder = builder.withStrikeoutness(true);
	}
	builder = builder.withPresentableText("{" + name);
	return builder.withIcon(LatteIcons.MACRO);
}
 
Example #3
Source File: PhpIndexAbstractProviderAbstract.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
@NotNull
public Collection<LookupElement> getLookupElements(@NotNull PhpToolboxCompletionContributorParameter parameter) {
    PhpIndex instance = PhpIndex.getInstance(parameter.getProject());

    Collection<LookupElement> lookupElements = new ArrayList<>();
    for (String className : getClasses(parameter)) {
        // strip double backslash
        className = className.replaceAll("\\\\+", "\\\\");

        for (PhpClass phpClass : getPhpClassesForLookup(instance, className)) {
            lookupElements.add(
                LookupElementBuilder.create(phpClass.getPresentableFQN()).withIcon(phpClass.getIcon())
            );
        }
    }

    return lookupElements;
}
 
Example #4
Source File: TextFieldWithAutoCompletionListProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
public LookupElementBuilder createLookupBuilder(@Nonnull final T item) {
  LookupElementBuilder builder = LookupElementBuilder.create(item, getLookupString(item))
    .withIcon(getIcon(item));

  final InsertHandler<LookupElement> handler = createInsertHandler(item);
  if (handler != null) {
    builder = builder.withInsertHandler(handler);
  }

  final String tailText = getTailText(item);
  if (tailText != null) {
    builder = builder.withTailText(tailText, true);
  }

  final String typeText = getTypeText(item);
  if (typeText != null) {
    builder = builder.withTypeText(typeText);
  }
  return builder;
}
 
Example #5
Source File: CamelJavaBeanReferenceSmartCompletion.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
@NotNull
private LookupElement buildLookupElement(PsiMethod method, String presentableMethod) {
    LookupElementBuilder builder = LookupElementBuilder.create(method);
    builder = builder.withPresentableText(presentableMethod);
    builder = builder.withTypeText(method.getContainingClass().getName(), true);
    builder = builder.withIcon(AllIcons.Nodes.Method);
    if (getCamelIdeaUtils().isAnnotatedWithHandler(method)) {
        //@Handle methods are marked with
        builder = builder.withBoldness(true);
    }
    if (method.isDeprecated()) {
        // mark as deprecated
        builder = builder.withStrikeoutness(true);
    }
    return  builder.withAutoCompletionPolicy(AutoCompletionPolicy.GIVE_CHANCE_TO_OVERWRITE);
}
 
Example #6
Source File: AdditionalLanguagesCompletionContributor.java    From intellij with Apache License 2.0 6 votes vote down vote up
public AdditionalLanguagesCompletionContributor() {
  extend(
      CompletionType.BASIC,
      psiElement()
          .withLanguage(ProjectViewLanguage.INSTANCE)
          .inside(
              psiElement(ProjectViewPsiListSection.class)
                  .withText(
                      StandardPatterns.string()
                          .startsWith(AdditionalLanguagesSection.KEY.getName()))),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            CompletionParameters parameters,
            ProcessingContext context,
            CompletionResultSet result) {
          for (LanguageClass type :
              availableAdditionalLanguages(parameters.getEditor().getProject())) {
            result.addElement(LookupElementBuilder.create(type.getName()));
          }
        }
      });
}
 
Example #7
Source File: RouterReference.java    From Thinkphp5-Plugin with MIT License 6 votes vote down vote up
/**
 * 获取提示信息
 *
 * @return 返回提示集合
 */
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {

    final Collection<LookupElement> lookupElements = new ArrayList<>();

    CollectProjectUniqueKeys ymlProjectProcessor = new CollectProjectUniqueKeys(getProject(), RouteValStubIndex.KEY);
    //扫描文件获取key, 放入ymlProjectProcessor
    FileBasedIndex.getInstance().processAllKeys(RouteValStubIndex.KEY, ymlProjectProcessor, getProject());
    for (String key : ymlProjectProcessor.getResult()) {    //从ymlProjectProcessor中获取结果
        lookupElements.add(LookupElementBuilder.create(key).withIcon(LaravelIcons.ROUTE));
    }

    return lookupElements;
}
 
Example #8
Source File: ToolboxJsonCompletionContributor.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
private void addKnownIconClasses(@NotNull CompletionResultSet resultSet) {
    String[] strings = {
        "icons.TwigIcons",
        "com.jetbrains.php.PhpIcons",
        "fr.adrienbrault.idea.symfony2plugin.Symfony2Icons",
        "com.intellij.icons.AllIcons",
        "com.intellij.util.PlatformIcons",
        "de.espend.idea.php.toolbox.PhpToolboxIcons",
    };

    for (String clazz : strings) {
        try {
            Class.forName(clazz);
        } catch (ClassNotFoundException e) {
            continue;
        }

        resultSet.addElement(LookupElementBuilder.create(clazz).withIcon(PhpToolboxIcons.TOOLBOX));
    }
}
 
Example #9
Source File: ViewReferences2.java    From Thinkphp5-Plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {

    final Collection<LookupElement> lookupElements = new ArrayList<>();

    ViewCollector.visitFile(getProject(), new ViewCollector.ViewVisitor() {
                @Override
                public void visit(@NotNull VirtualFile virtualFile, @NotNull String name) {
                    lookupElements.add(LookupElementBuilder.create(name).withIcon(virtualFile.getFileType().getIcon()));
                }
            }
    );

    // @TODO: no filesystem access in test; fake item
    if (ApplicationManager.getApplication().isUnitTestMode()) {
        lookupElements.add(LookupElementBuilder.create("test_view"));
    }

    return lookupElements;
}
 
Example #10
Source File: HaxeClassNameCompletionContributor.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
private static void addVariantsFromImports(final CompletionResultSet resultSet,
                                           final PsiFile targetFile) {
  targetFile.acceptChildren(new HaxeRecursiveVisitor() {
    @Override
    public void visitImportStatement(@NotNull HaxeImportStatement importStatement) {
      final List<HaxeModel> exposedMembers = importStatement.getModel().getExposedMembers();
      final String alias = importStatement.getAlias() != null ? importStatement.getAlias().getText() : null;

      for (HaxeModel member : exposedMembers) {
        LookupElementBuilder lookupElement = HaxeLookupElementFactory.create(member, alias);
        if (lookupElement != null) resultSet.addElement(lookupElement);
        if (alias != null) return;
      }
    }
  });
}
 
Example #11
Source File: JsonParseUtil.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
@NotNull
public static LookupElementBuilder getDecoratedLookupElementBuilder(@NotNull LookupElementBuilder lookupElement, @Nullable JsonRawLookupElement jsonLookup) {
    if(jsonLookup == null) {
        return lookupElement;
    }

    if(jsonLookup.getTailText() != null) {
        lookupElement = lookupElement.withTailText(jsonLookup.getTailText(), true);
    }

    if(jsonLookup.getTypeText() != null) {
        lookupElement = lookupElement.withTypeText(jsonLookup.getTypeText(), true);
    }

    String iconString = jsonLookup.getIcon();
    if(iconString != null) {
        Icon icon = getLookupIconOnString(iconString);
        if(icon != null) {
            lookupElement = lookupElement.withIcon(icon);
        }
    }

    return lookupElement;
}
 
Example #12
Source File: CompletionAdders.java    From arma-intellij-plugin with MIT License 6 votes vote down vote up
public static void addVariables(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result,
								@NotNull PsiElement cursor, boolean forLocalVars) {
	HashSet<String> putVars = new HashSet<>();
	PsiUtil.traverseDepthFirstSearch(parameters.getOriginalFile().getNode(), astNode -> {
		PsiElement nodeAsElement = astNode.getPsi();
		if (nodeAsElement == cursor) {
			return false;
		}
		if (!(nodeAsElement instanceof SQFVariable)) {
			return false;
		}
		SQFVariable var = (SQFVariable) nodeAsElement;
		if (((var.isLocal() && forLocalVars) || (!var.isLocal() && !forLocalVars)) && !putVars.contains(var.getVarName().toLowerCase())) {
			putVars.add(var.getVarName().toLowerCase());
			result.addElement(PrioritizedLookupElement.withPriority(
					LookupElementBuilder.createWithSmartPointer(var.getVarName(), var)
							.withTailText(var.isMagicVar() ? " (Magic Var)" : (
											forLocalVars ? " (Local Variable)" : " (Global Variable)"
									)
							)
							.withIcon(var.isMagicVar() ? ArmaPluginIcons.ICON_SQF_MAGIC_VARIABLE : ArmaPluginIcons.ICON_SQF_VARIABLE), VAR_PRIORITY)
			);
		}
		return false;
	});
}
 
Example #13
Source File: JsonParseUtil.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
@NotNull
public static LookupElementBuilder getDecoratedLookupElementBuilder(@NotNull LookupElementBuilder lookupElement, @Nullable JsonRawLookupElement jsonLookup) {
    if(jsonLookup == null) {
        return lookupElement;
    }

    if(jsonLookup.getTailText() != null) {
        lookupElement = lookupElement.withTailText(jsonLookup.getTailText(), true);
    }

    if(jsonLookup.getTypeText() != null) {
        lookupElement = lookupElement.withTypeText(jsonLookup.getTypeText(), true);
    }

    String iconString = jsonLookup.getIcon();
    if(iconString != null) {
        Icon icon = getLookupIconOnString(iconString);
        if(icon != null) {
            lookupElement = lookupElement.withIcon(icon);
        }
    }

    return lookupElement;
}
 
Example #14
Source File: VariableCollector.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private LookupElement createLookupElement(XQueryVarName psiElement, String key) {
    Icon icon = XQueryIcons.VARIABLE_ICON;
    String typeText = "item()*";
    if (psiElement.getParent() instanceof XQueryParam) {
        icon = AllIcons.Nodes.Parameter;
        XQueryParam param = (XQueryParam) psiElement.getParent();
        if (param.getTypeDeclaration() != null) {
            typeText = param.getTypeDeclaration().getSequenceType().getText();
        }
    }
    if (psiElement.getParent() instanceof XQueryVarDecl) {
        icon = AllIcons.Nodes.Field;
        XQueryVarDecl varDecl = (XQueryVarDecl) psiElement.getParent();
        if (varDecl.getTypeDeclaration() != null) {
            typeText = varDecl.getTypeDeclaration().getSequenceType().getText();
        }
    }
    return LookupElementBuilder.create(psiElement, key)
            .withIcon(icon)
            .withTypeText(typeText)
            .withInsertHandler(new VariableInsertHandler())
            .withLookupString(psiElement.getVarLocalName().getText())
            ;
}
 
Example #15
Source File: TwigTemplateCompletionContributor.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext processingContext, @NotNull CompletionResultSet resultSet) {
    PsiElement position = parameters.getPosition();
    if(!Symfony2ProjectComponent.isEnabled(position)) {
        return;
    }

    TwigUtil.visitTokenParsers(position.getProject(), pair ->
        resultSet.addElement(LookupElementBuilder.create(pair.getFirst()).withIcon(Symfony2Icons.SYMFONY))
    );

    // add special tag ending, provide a static list. there no suitable safe way to extract them
    // search able via: "return $token->test(array('end"
    for (String s : new String[]{"endtranschoice", "endtrans"}) {
        resultSet.addElement(LookupElementBuilder.create(s).withIcon(Symfony2Icons.SYMFONY));
    }
}
 
Example #16
Source File: ThriftKeywordCompletionContributor.java    From intellij-thrift with Apache License 2.0 6 votes vote down vote up
public ThriftKeywordCompletionContributor() {
  extend(CompletionType.BASIC,
         psiElement().andOr(psiElement(ThriftTokenTypes.IDENTIFIER), psiElement(ThriftTokenTypes.STIDENTIFIER)),
         new CompletionProvider<CompletionParameters>() {
           @Override
           protected void addCompletions(@NotNull CompletionParameters parameters,
                                         ProcessingContext context,
                                         @NotNull CompletionResultSet result) {
             final Collection<String> suggestedKeywords = suggestKeywords(parameters.getPosition());
             suggestedKeywords.retainAll(ThriftUtils.getKeywords());
             for (String keyword : suggestedKeywords) {
               result.addElement(LookupElementBuilder.create(keyword));
             }
           }
         });
}
 
Example #17
Source File: SubClassesSourceContributor.java    From idea-php-toolbox with MIT License 6 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements(@NotNull SourceContributorParameter parameter) {
    String sourceParameter = parameter.getSourceParameter();
    if(sourceParameter == null) {
        return Collections.emptyList();
    }

    Collection<LookupElement> lookupElements = new ArrayList<>();
    for (PhpClass phpClass : PhpIndex.getInstance(parameter.getProject()).getAllSubclasses(sourceParameter)) {
        lookupElements.add(
            LookupElementBuilder.create(phpClass.getPresentableFQN()).withIcon(phpClass.getIcon())
        );
    }

    return lookupElements;
}
 
Example #18
Source File: SoyCompletionContributor.java    From bamboo-soy with Apache License 2.0 6 votes vote down vote up
/**
 * Complete the "visibility" and "stricthtml" keywords in template definition open tags.
 */
private void extendWithTemplateDefinitionLevelKeywords() {
  extend(
      CompletionType.BASIC,
      psiElement().andOr(psiElement().inside(SoyBeginTemplate.class)),
      new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(
            @NotNull CompletionParameters completionParameters,
            ProcessingContext processingContext,
            @NotNull CompletionResultSet completionResultSet) {
          if (isPrecededBy(
              completionParameters.getPosition(),
              elt -> elt instanceof SoyTemplateDefinitionIdentifier)) {
            completionResultSet.addElement(LookupElementBuilder.create("visibility=\"private\""));
            completionResultSet.addElement(LookupElementBuilder.create("stricthtml=\"true\""));
          }
        }
      });
}
 
Example #19
Source File: MuleElementCompletionProvider.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    final Project project = completionParameters.getOriginalFile().getProject();
    final MuleElementDefinitionService instance = MuleElementDefinitionService.getInstance(project);
    final List<MuleModuleDefinition> definitions = instance.getDefinitions();
    for (MuleModuleDefinition definition : definitions) {
        final List<MuleElementDefinition> elementDefinitions = definition.getElementDefinitions();
        for (MuleElementDefinition elementDefinition : elementDefinitions) {
            final LookupElementBuilder lookupElement =
                    LookupElementBuilder.create(elementDefinition.getName())
                            .withCaseSensitivity(false)
                            .withLookupString(definition.getName() + ":" + elementDefinition.getName())
                            .withTypeText("\t" + StringUtil.capitalizeWords(elementDefinition.getType().name().toLowerCase(), "_", true, false), true)
                            .withPresentableText(definition.getName() + ":" + elementDefinition.getName())
                            .withInsertHandler(new MuleElementInsertHandler(elementDefinition.getName(), definition.getName(), definition.getNamespace(), definition.getLocationLookup()));
            completionResultSet.addElement(lookupElement);
        }
    }
    completionResultSet.stopHere();
}
 
Example #20
Source File: ConfigCompletionProvider.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void attachRootConfig(CompletionResultSet completionResultSet, PsiElement element) {

        Document document = getConfigTemplate(ProjectUtil.getProjectDir(element));
        if(document == null) {
            return;
        }

        try {

            // attach config aliases
            NodeList nodeList  = (NodeList) XPathFactory.newInstance().newXPath().compile("//config/*").evaluate(document, XPathConstants.NODESET);
            for (int i = 0; i < nodeList.getLength(); i++) {
                completionResultSet.addElement(LookupElementBuilder.create(getNodeName(nodeList.item(i))).withIcon(Symfony2Icons.CONFIG_VALUE));
            }

        } catch (XPathExpressionException ignored) {
        }

    }
 
Example #21
Source File: GraphQLCompletionContributor.java    From js-graphql-intellij-plugin with MIT License 6 votes vote down vote up
private void completeOperationTypeNamesInSchemaDefinition() {
    CompletionProvider<CompletionParameters> provider = new CompletionProvider<CompletionParameters>() {
        @Override
        protected void addCompletions(@NotNull final CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
            final PsiElement completionElement = parameters.getPosition();
            final TypeDefinitionRegistry registry = GraphQLTypeDefinitionRegistryServiceImpl.getService(completionElement.getProject()).getRegistry(parameters.getOriginalFile());
            if (registry != null) {
                final Collection<GraphQLTypeName> currentTypes = PsiTreeUtil.findChildrenOfType(PsiTreeUtil.getTopmostParentOfType(completionElement, GraphQLElement.class), GraphQLTypeName.class);
                final Set<String> currentTypeNames = currentTypes.stream().map(PsiNamedElement::getName).collect(Collectors.toSet());
                registry.types().values().forEach(type -> {
                    if (type instanceof ObjectTypeDefinition && !currentTypeNames.contains(type.getName())) {
                        result.addElement(LookupElementBuilder.create(type.getName()));
                    }
                });
            }
        }
    };
    extend(CompletionType.BASIC, psiElement(GraphQLElementTypes.NAME).afterLeaf(":").inside(GraphQLOperationTypeDefinition.class), provider);
}
 
Example #22
Source File: ViewReferences.java    From idea-php-laravel-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {

    final Collection<LookupElement> lookupElements = new ArrayList<>();

    ViewCollector.visitFile(getProject(), (virtualFile, name) ->
        lookupElements.add(LookupElementBuilder.create(name).withIcon(virtualFile.getFileType().getIcon()))
    );

    // @TODO: no filesystem access in test; fake item
    if(ApplicationManager.getApplication().isUnitTestMode()) {
        lookupElements.add(LookupElementBuilder.create("test_view"));
    }

    return lookupElements;
}
 
Example #23
Source File: CompletionProviderUtils.java    From BashSupport with Apache License 2.0 6 votes vote down vote up
static Collection<LookupElement> createItems(Collection<String> lookupStrings, final Icon icon, boolean trimLookupString, Integer groupId) {
    return lookupStrings
            .stream()
            .map(item -> {
                LookupElementBuilder elementBuilder = LookupElementBuilder.create(item).withCaseSensitivity(true);
                if (icon != null) {
                    elementBuilder = elementBuilder.withIcon(icon);
                }

                if (trimLookupString) {
                    elementBuilder = elementBuilder.withLookupString(item.replace("_", ""));
                }

                if (groupId != null) {
                    return PrioritizedLookupElement.withGrouping(elementBuilder, groupId);
                }
                return elementBuilder;
            })
            .collect(Collectors.toList());
}
 
Example #24
Source File: StaticArgCompletionProvider.java    From Intellij-Plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) {
    String prefix = getPrefix(parameters);
    resultSet = resultSet.withPrefixMatcher(new PlainPrefixMatcher(prefix));
    PsiFile specFile = parameters.getOriginalFile();
    SpecDetail specDetail = PsiTreeUtil.getChildOfType(specFile, SpecDetail.class);
    List<SpecStep> stepsInFile = new ArrayList<>();
    addContextSteps(specDetail, stepsInFile);
    addStepsInScenarios(specFile, stepsInFile);

    Set<String> staticArgs = getArgsFromSteps(stepsInFile);
    for (String arg : staticArgs) {
        if (arg != null) {
            LookupElementBuilder item = LookupElementBuilder.create(arg);
            resultSet.addElement(item);
        }
    }
}
 
Example #25
Source File: CSharpLookupElementBuilder.java    From consulo-csharp with Apache License 2.0 6 votes vote down vote up
private static LookupElementBuilder withGenericInsertHandler(PsiElement element, LookupElementBuilder builder)
{
	if(!(element instanceof DotNetGenericParameterListOwner))
	{
		return builder;
	}

	int genericParametersCount = ((DotNetGenericParameterListOwner) element).getGenericParametersCount();
	if(genericParametersCount == 0)
	{
		return builder;
	}

	builder = builder.withInsertHandler(LtGtInsertHandler.getInstance(true));
	return builder;
}
 
Example #26
Source File: LatteVariableCompletionProvider.java    From intellij-latte with MIT License 6 votes vote down vote up
private void attachTemplateTypeCompletions(@NotNull CompletionResultSet result, @NotNull Project project, @NotNull LatteFile file) {
	LattePhpType type = LatteUtil.findFirstLatteTemplateType(file);
	if (type == null) {
		return;
	}

	Collection<PhpClass> phpClasses = type.getPhpClasses(project);
	if (phpClasses != null) {
		for (PhpClass phpClass : phpClasses) {
			for (Field field : phpClass.getFields()) {
				if (!field.isConstant() && field.getModifier().isPublic()) {
					LookupElementBuilder builder = LookupElementBuilder.create(field, "$" + field.getName());
					builder = builder.withInsertHandler(PhpVariableInsertHandler.getInstance());
					builder = builder.withTypeText(LattePhpType.create(field.getType()).toString());
					builder = builder.withIcon(PhpIcons.VARIABLE);
					if (field.isDeprecated() || field.isInternal()) {
						builder = builder.withStrikeoutness(true);
					}
					result.addElement(builder);
				}
			}
		}
	}
}
 
Example #27
Source File: CompletionAdders.java    From arma-intellij-plugin with MIT License 5 votes vote down vote up
/**
 * Adds all SQF commands to the completion result
 */
public static void addCommands(@NotNull Project project, @NotNull CompletionResultSet result) {
	for (String command : SQFStatic.COMMANDS_SET) {
		SQFCommand cmd = PsiUtil.createElement(project, command, SQFFileType.INSTANCE, SQFCommand.class);
		if (cmd == null) {
			continue;
		}
		result.addElement(LookupElementBuilder.createWithSmartPointer(command, cmd)
				.withIcon(ArmaPluginIcons.ICON_SQF_COMMAND)
				.appendTailText(" (Command)", true)
		);
	}
}
 
Example #28
Source File: ValuesCompletionProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
protected LookupElement installInsertHandler(@Nonnull LookupElementBuilder builder) {
  InsertHandler<LookupElement> handler = builder.getInsertHandler();
  if (handler == null) return builder.withInsertHandler(myInsertHandler);
  return builder.withInsertHandler(new InsertHandler<LookupElement>() {
    @Override
    public void handleInsert(InsertionContext context, LookupElement item) {
      myInsertHandler.handleInsert(context, item);
      handler.handleInsert(context, item);
    }
  });
}
 
Example #29
Source File: HaxeMetaTagsCompletionContributor.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public HaxeMetaTagsCompletionContributor() {
  final List<HXMLCompletionItem> metaTags = HaxeHelpCache.getInstance().getMetaTags();
  extend(CompletionType.BASIC, PlatformPatterns.psiElement(HaxeTokenTypes.MACRO_ID), new CompletionProvider<CompletionParameters>() {
    @Override
    protected void addCompletions(@NotNull CompletionParameters parameters,
                                  ProcessingContext context,
                                  @NotNull CompletionResultSet result) {
      for (int i = 0; i < metaTags.size(); i++) {
        HXMLCompletionItem completionItem = metaTags.get(i);
        result.addElement(LookupElementBuilder.create(completionItem.name).withTailText(" " + completionItem.description, true));
      }
    }
  });
}
 
Example #30
Source File: Replacer.java    From translator with MIT License 5 votes vote down vote up
private LookupElement[] getProposeList(String text){
    Proposer proposer = ServiceManager.getService(Proposer.class);

    return proposer.propose(text, ServiceManager.getService(LanguageChecker.class)).stream()
            .map(LookupElementBuilder::create)
            .toArray(LookupElement[]::new);
}