Java Code Examples for com.intellij.codeInsight.lookup.LookupElementBuilder

The following examples show how to use com.intellij.codeInsight.lookup.LookupElementBuilder. These examples are extracted from open source projects. 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
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 2
Source Project: Thinkphp5-Plugin   Source File: ViewReferences2.java    License: 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 3
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 4
Source Project: Thinkphp5-Plugin   Source File: RouterReference.java    License: 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 5
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 6
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 7
Source Project: idea-php-toolbox   Source File: JsonParseUtil.java    License: 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 8
Source Project: intellij-xquery   Source File: VariableCollector.java    License: 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 9
@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 10
Source Project: consulo-csharp   Source File: CSharpLookupElementBuilder.java    License: 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 11
@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 12
Source Project: BashSupport   Source File: CompletionProviderUtils.java    License: 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 13
Source Project: idea-php-laravel-plugin   Source File: ViewReferences.java    License: 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 14
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 15
Source Project: bamboo-soy   Source File: SoyCompletionContributor.java    License: 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 16
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 17
Source Project: idea-php-toolbox   Source File: SubClassesSourceContributor.java    License: 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
@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 19
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 20
@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 21
Source Project: arma-intellij-plugin   Source File: CompletionAdders.java    License: 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 22
Source Project: intellij-latte   Source File: LatteCompletionContributor.java    License: 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 23
@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 24
Source Project: idea-php-toolbox   Source File: JsonParseUtil.java    License: 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 25
Source Project: intellij-latte   Source File: LatteVariableCompletionProvider.java    License: 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 26
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 27
Source Project: consulo   Source File: FileInfoManager.java    License: Apache License 2.0 5 votes vote down vote up
public LookupElementBuilder _getLookupItem(@Nonnull final PsiFile file, String name, Icon icon) {
  LookupElementBuilder builder = LookupElementBuilder.create(file, name).withIcon(icon);

  final String info = _getInfo(file);
  if (info != null) {
    return builder.withTailText(String.format(" (%s)", info), true);
  }

  return builder;
}
 
Example 28
Source Project: Thinkphp5-Plugin   Source File: ProviderGotoCompletion.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public Collection<LookupElement> getLookupElements() {

    return PhpIndex.getInstance(getProject()).getAllSubclasses("\\Illuminate\\Support\\ServiceProvider")
            .stream()
            .map(phpClass -> LookupElementBuilder.create(phpClass.getPresentableFQN())
                    .withIcon(phpClass.getIcon())).collect(Collectors.toCollection(ArrayList::new)
            );
}
 
Example 29
Source Project: idea-php-symfony2-plugin   Source File: FormOptionsUtil.java    License: MIT License 5 votes vote down vote up
/**
 * Build completion lookup element for form options
 * Reformat class name to make it more readable
 *
 * @param formOption Extension or a default option
 * @return lookup element
 */
private static LookupElement getOptionLookupElement(FormOption formOption) {
    String typeText = formOption.getFormClass().getPhpClass().getPresentableFQN();

    if(typeText.lastIndexOf("\\") != -1) {
        typeText = typeText.substring(typeText.lastIndexOf("\\") + 1);
        if(typeText.endsWith("Extension")) {
            typeText = typeText.substring(0, typeText.length() - 9);
        }
    }

    return LookupElementBuilder.create(formOption.getOption())
        .withTypeText(typeText, true)
        .withIcon(formOption.getFormClass().isWeak() ? Symfony2Icons.FORM_EXTENSION_WEAK : Symfony2Icons.FORM_EXTENSION);
}
 
Example 30
private LookupElementBuilder withAutoImport(LookupElementBuilder element, JSGraphQLEndpointTypeResult typeResult, boolean autoImport) {
	if(autoImport && typeResult.fileToImport != null) {
		element = element.withInsertHandler(new JSGraphQLEndpointAutoImportInsertHandler(typeResult.fileToImport));
		element = element.withTypeText(typeResult.fileToImport.getName(), true);
	}
	return element;
}