@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement caller = parameters.getPosition().getPrevSibling().getPrevSibling(); String ns = TSUtil.getElementNamespace(caller); //All global functions Project project = parameters.getOriginalFile().getProject(); Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project); for (TSFnDeclStmt function : functions) { if (function.getFunctionType() == TSFunctionType.GLOBAL) continue; result.addElement( LookupElementBuilder.create(function.getFunctionName()) .withCaseSensitivity(false) .withPresentableText(function.getNamespace() + "." + function.getFunctionName()) .withBoldness(ns != null && function.getNamespace().equalsIgnoreCase(ns)) .withTailText(function.getArgList()) .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE) ); } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { List<TSVarExpr> variables = new ArrayList<>(); for (PsiElement current = parameters.getPosition().getPrevSibling(); current != null; current = current.getPrevSibling()) { if (current.getNode().getElementType().equals(TSTypes.FUNCTION)) break; if (current.getNode().getElementType().equals(TSTypes.LOCALVAR)) { String prefixless = current.getText().substring(1); result.addElement( LookupElementBuilder.create(prefixless) .withPresentableText(current.getText()) .withCaseSensitivity(false) ); } } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { String namespace = parameters.getPosition().getPrevSibling().getPrevSibling().getText(); Project project = parameters.getOriginalFile().getProject(); Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project); for (TSFnDeclStmt function : functions) { if (function.getFunctionType() == TSFunctionType.GLOBAL) continue; if (namespace != null && !function.getNamespace().equalsIgnoreCase(namespace)) continue; result.addElement( LookupElementBuilder.create(function.getFunctionName()) .withCaseSensitivity(false) .withPresentableText(function.getNamespace() + "::" + function.getFunctionName()) .withTailText(function.getArgList()) .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE) ); } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { //All global functions Project project = parameters.getOriginalFile().getProject(); Collection<TSFnDeclStmt> functions = TSUtil.getFunctionList(project); for (TSFnDeclStmt function : functions) { if (function.getFunctionType() != TSFunctionType.GLOBAL) continue; result.addElement( LookupElementBuilder.create(function) .withCaseSensitivity(false) .withTailText(function.getArgList()) .withInsertHandler(TSCaseCorrectingInsertHandler.INSTANCE) ); } }
public KeywordCompletionContributor() { extend(CompletionType.BASIC, psiElement().inFile(StandardPatterns.instanceOf(AppleScriptFile.class)), new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { PsiFile file = completionParameters.getOriginalFile(); if (!(file instanceof AppleScriptFile)) return; PsiElement position = completionParameters.getPosition(); if (position instanceof PsiComment) return; ASTNode node = position.getNode(); if (node.getElementType() == AppleScriptTypes.STRING_LITERAL) return; for (IElementType kwElem : AppleScriptTokenTypesSets.KEYWORDS.getTypes()) { completionResultSet.addElement(LookupElementBuilder .create(kwElem.toString().toLowerCase().replaceAll("_", " ")).bold() .withTypeText("keyword", true)); } } }); }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet resultSet) { MerlinService merlin = ApplicationManager.getApplication().getComponent(MerlinService.class); PsiFile originalFile = parameters.getOriginalFile(); String text = originalFile.getText(); LineNumbering lineNumbering = new LineNumbering(text); String suitablePrefix = findSuitablePrefix(parameters, text); MerlinPosition position = lineNumbering.offsetToPosition(parameters.getOffset()); MerlinCompletion completion = merlin.completions(originalFile.getName(), text, position, suitablePrefix); for (MerlinCompletionEntry entry : completion.entries) { resultSet.addElement(LookupElementBuilder. create(entry.name). withIcon(getIcon(entry)). withTypeText(entry.desc)); } }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { // follow, redirect registrar.registerReferenceProvider( PlatformPatterns.psiElement(StringLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (!(element instanceof StringLiteralExpression)) { return new PsiReference[0]; } StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) element; String methodName = PhpLangUtil.getMethodName(element); int parameterPosition = PhpLangUtil.getParameterPosition(stringLiteralExpression); if (methodName != null && isDirectingActionName(methodName) && parameterPosition == 0) { return new PsiReference[]{new ControllerActionReference(stringLiteralExpression)}; } return new PsiReference[0]; } } ); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider( PlatformPatterns.psiElement(StringLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (isGenerator(element)) { return new PsiReference[]{new RouteReference((StringLiteralExpression) element)}; } return new PsiReference[0]; } } ); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { // "EXT:" strings registrar.registerReferenceProvider( PlatformPatterns.psiElement(StringLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { StringLiteralExpression stringLiteralExpression = (StringLiteralExpression)element; if (!stringLiteralExpression.getContents().startsWith("EXT:")) { return new PsiReference[0]; } return new PsiReference[]{new ResourceReference(stringLiteralExpression)}; } } ); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(StringLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (!(element instanceof StringLiteralExpression)) { return new PsiReference[0]; } StringLiteralExpression stringLiteralExpression = (StringLiteralExpression) element; if (!stringLiteralExpression.getContents().startsWith("LLL:")) { return new PsiReference[0]; } return new PsiReference[]{new TranslationReference(stringLiteralExpression)}; } }); }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null || !(position instanceof XmlElement)) { return; } DiIndex diIndex = DiIndex.getInstance(position.getProject()); PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) position); if (phpClass != null) { Method constructor = phpClass.getConstructor(); if (constructor != null) { for (Parameter parameter : constructor.getParameters()) { result.addElement( LookupElementBuilder .create(parameter.getName()) .withIcon(parameter.getIcon()) ); } } } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null) { return; } Collection<String> keys = LayoutIndex.getAllKeys(ContainerNameIndex.KEY, position.getProject()); for (String key: keys) { result.addElement( LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON) ); } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null) { return; } String prefix = result.getPrefixMatcher().getPrefix(); Collection<String> moduleNames = FileBasedIndex.getInstance().getAllKeys(ModuleNameIndex.KEY, position.getProject()); moduleNames.removeIf(m -> !m.startsWith(prefix)); for (String moduleName : moduleNames) { result.addElement( LookupElementBuilder .create(moduleName) .withIcon(AllIcons.Modules.ModulesNode) ); } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null) { return; } Collection<String> keys = LayoutIndex.getAllKeys(BlockNameIndex.KEY, position.getProject()); for (String key: keys) { result.addElement( LookupElementBuilder.create(key).withIcon(PhpIcons.XML_TAG_ICON) ); } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null) { return; } String prefix = result.getPrefixMatcher().getPrefix(); DiIndex index = DiIndex.getInstance(position.getProject()); Collection<String> elements = index.getAllVirtualTypeElementNames(new PlainPrefixMatcher(prefix), position.getResolveScope()); for (String elementName:elements) { result.addElement( LookupElementBuilder .create(elementName) .withIcon(PhpIcons.CLASS_ICON) ); } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null) { return; } List<XmlFile> targets = LayoutIndex.getLayoutFiles(position.getProject()); if (targets.size() > 0) { for (XmlFile file : targets) { result.addElement( LookupElementBuilder .create(file.getVirtualFile().getNameWithoutExtension()) .withIcon(PhpIcons.XML_TAG_ICON) ); } } }
@Override protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition().getOriginalElement(); if (position == null) { return; } PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) position); if (phpClass != null) { for (Method method : phpClass.getMethods()) { result.addElement( LookupElementBuilder .create(method.getName()) .withIcon(method.getIcon()) ); } } }
@NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (!(element instanceof XmlElement)) { return PsiReference.EMPTY_ARRAY; } List<PsiReference> psiReferences = new ArrayList<>(); String methodName = StringUtil.unquoteString(element.getText()); PhpClass phpClass = DiIndex.getPhpClassOfServiceMethod((XmlElement) element); if (phpClass != null) { Collection<Method> methods = phpClass.getMethods(); methods.removeIf(m -> !m.getName().equalsIgnoreCase(methodName)); psiReferences.add(new PolyVariantReferenceBase(element, methods)); } return psiReferences.toArray(new PsiReference[psiReferences.size()]); }
@NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { String value = StringUtil.unquoteString(element.getText()); DiIndex index = DiIndex.getInstance(element.getProject()); Collection<PsiElement> targets = index.getVirtualTypeElements(value, element.getResolveScope()); if (!(targets.size() > 0)) { return PsiReference.EMPTY_ARRAY; } return new PsiReference[] { new PolyVariantReferenceBase(element, targets) }; }
@NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { String value = StringUtil.unquoteString(element.getText()); Collection<PsiElement> targets = EventIndex.getInstance(element.getProject()) .getEventElements( value, GlobalSearchScope.getScopeRestrictedByFileTypes( GlobalSearchScope.allScope(element.getProject()), XmlFileType.INSTANCE ) ); if (targets.size() > 0) { return new PsiReference[] {new PolyVariantReferenceBase(element, targets)}; } return PsiReference.EMPTY_ARRAY; }
@NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { String parameterName = StringUtil.unquoteString(element.getText()); if (parameterName.isEmpty() || !(element instanceof XmlElement)) { return PsiReference.EMPTY_ARRAY; } DiIndex diIndex = DiIndex.getInstance(element.getProject()); PhpClass phpClass = diIndex.getPhpClassOfArgument((XmlElement) element); if (phpClass != null) { Method constructor = phpClass.getConstructor(); if (constructor != null) { Collection<Parameter> parameterList = new THashSet<>(Arrays.asList(constructor.getParameters())); parameterList.removeIf(p -> !p.getName().contains(parameterName)); if (parameterList.size() > 0) { return new PsiReference[] {new PolyVariantReferenceBase(element, parameterList)}; } } } return PsiReference.EMPTY_ARRAY; }
@NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { String value = StringUtil.unquoteString(element.getText()); Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance() .getContainingFiles(EventNameIndex.KEY, value, GlobalSearchScope.getScopeRestrictedByFileTypes( GlobalSearchScope.allScope(element.getProject()), PhpFileType.INSTANCE ) ); PsiManager psiManager = PsiManager.getInstance(element.getProject()); for (VirtualFile virtualFile: containingFiles) { PhpFile phpFile = (PhpFile) psiManager.findFile(virtualFile); if (phpFile != null) { List<PsiElement> psiElements = new ArrayList<>(); recursiveFill(psiElements, phpFile, value); if (psiElements.size() > 0) { return new PsiReference[] {new PolyVariantReferenceBase(element, psiElements)}; } } } return PsiReference.EMPTY_ARRAY; }
/** * 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\"")); } } }); }
/** * Complete types in {@param ...} . */ private void extendWithParameterTypes() { // Complete types in @param. extend( CompletionType.BASIC, psiElement() .andOr( psiElement().inside(SoyAtParamSingle.class).afterLeaf(":"), psiElement().inside(SoyAtInjectSingle.class).afterLeaf(":"), // List type literal. psiElement().inside(SoyListType.class).afterLeaf("<"), // Map type literal. psiElement().inside(SoyMapType.class).afterLeaf("<"), psiElement().inside(SoyMapType.class).afterLeaf(",")), new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions( @NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { completionResultSet.addAllElements(soyTypeLiterals); } }); }
public EmojiResourceCompletionContributor() { extend(CompletionType.BASIC, PlatformPatterns.psiElement(PsiElement.class), new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) { Document document = completionParameters.getEditor().getDocument(); int lineStart = document.getLineStartOffset(document.getLineNumber(completionParameters.getOffset())); String lineText = document.getText(new TextRange(lineStart, completionParameters.getOffset())); if (includeCount(lineText) == 1) { for (Map.Entry<String, Icon> iconEntry : EmojiUtil.getEmojiMap().entrySet()) { completionResultSet.addElement(LookupElementBuilder.create(iconEntry.getKey(), ":" + iconEntry.getKey() + ":") .withIcon(iconEntry.getValue()) .withInsertHandler((insertionContext, lookupElement) -> { int startOffset = insertionContext.getStartOffset(); Document insertDocument = insertionContext.getDocument(); if (startOffset > 0 && insertDocument.getCharsSequence().charAt(startOffset - 1) == ':') { insertDocument.deleteString(startOffset - 1, startOffset); } })); } } } }); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { // TODO registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { PsiLiteralExpression literalExpression = (PsiLiteralExpression) element; String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null; if (value != null && value.startsWith("simple" + ":")) { return new PsiReference[]{ new CptReference(element, new TextRange(8, value.length() + 1))}; } return PsiReference.EMPTY_ARRAY; } }); }
@Override public void addCompletions( @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result ) { Validate.notNull(parameters); Validate.notNull(result); final Project project = this.getProject(parameters); if (null == project) { return; } final TSMetaModel typeSystemMeta = TSMetaModelAccess.getInstance(project).getTypeSystemMeta(); typeSystemMeta.getMetaClassesStream() .map(meta -> LookupElementBuilder.create(meta.getName()).withIcon(HybrisIcons.TYPE_SYSTEM)) .forEach(result::addElement); }
public ExtensionsNameContributor() { extend( CompletionType.BASIC, tagAttributePattern("extension", "name", null), new CompletionProvider<CompletionParameters>() { @Override protected void addCompletions( @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result ) { final HybrisProjectSettings hybrisProjectSettings = HybrisProjectSettingsComponent.getInstance(parameters.getOriginalFile().getProject()) .getState(); final Set<String> extensions = hybrisProjectSettings.getCompleteSetOfAvailableExtensionsInHybris(); extensions.forEach(name -> result.addElement(LookupElementBuilder.create(name))); } } ); }
@Override protected void addCompletions( @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result ) { final PsiFile originalFile = parameters.getOriginalFile(); final Collection<ImpexMacroDeclaration> macroDeclarations = PsiTreeUtil.findChildrenOfType( originalFile, ImpexMacroDeclaration.class ); if (macroDeclarations.isEmpty()) { return; } for (final ImpexMacroDeclaration macroDeclaration : macroDeclarations) { final PsiElement declaration = macroDeclaration.getFirstChild(); result.addElement(LookupElementBuilder.create(declaration.getText()) .withIcon(HybrisIcons.MACROS)); } }
@Override public void addCompletions( @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result ) { Validate.notNull(parameters); Validate.notNull(result); final Project project = this.getProject(parameters); if (null == project) { return; } final PsiElement psiElementUnderCaret = parameters.getPosition(); final ImpexHeaderTypeName headerTypeName = this.getHeaderTypeNamePsiElementOfAttribute(psiElementUnderCaret); if (headerTypeName != null) { fillDomAttributesCompletions(project, headerTypeName, result); } }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(YAMLScalar.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (isConfigFile(element)) { String valueText = ((YAMLScalar) element).getTextValue(); List<MacroResolver.Match> matches = new MacroResolver().resolve(valueText); List<PsiReference> references = new ArrayList<>(); matches.stream() .filter(match -> !match.isEscaped()) .map(match -> resolvePsiReferences(element, match.getReference(), (element instanceof YAMLQuotedText ? 1 : 0) + match.getStartPos())) .forEach(references::addAll); return references.toArray(new PsiReference[references.size()]); } return PsiReference.EMPTY_ARRAY; } }); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (isLiteralOfConfigurationAnnotation(element) || isCoffigMethod(element)) { PsiLiteralExpression literalExpression = (PsiLiteralExpression) element; String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null; List<PsiReference> psiReferences = resolvePsiReferences(element, value, 1); return psiReferences.toArray(new PsiReference[psiReferences.size()]); } return PsiReference.EMPTY_ARRAY; } }); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { PsiLiteralExpression literalExpression = (PsiLiteralExpression) element; String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null; if (value != null && value.startsWith("simple" + ":")) { return new PsiReference[]{ new CrystalReference(element, new TextRange(8, value.length() + 1))}; } return PsiReference.EMPTY_ARRAY; } }); }
@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(); }
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class), new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { PsiLiteralExpression literalExpression = (PsiLiteralExpression) element; final PsiElement parent = literalExpression.getParent(); final PsiElement granParent = parent.getParent(); if (granParent instanceof PsiMethodCallExpression) { final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression) granParent).getMethodExpression(); if (FLOW_REF_METHOD_NAMES.contains(methodExpression.getReferenceName())) { return new PsiReference[]{new StringLiteralPsiReference(literalExpression)}; } } return PsiReference.EMPTY_ARRAY; } }); }
@Override public void addElement(LookupElement added, ProcessingContext context) { myCount++; for (String string : CompletionUtil.iterateLookupStrings(added)) { if (string.length() == 0) continue; myElements.putValue(string, added); mySortedStrings.add(string); final NavigableSet<String> after = mySortedStrings.tailSet(string, false); for (String s : after) { if (!s.startsWith(string)) { break; } for (LookupElement longer : myElements.get(s)) { updateLongerItem(added, longer); } } } super.addElement(added, context); calculateToLift(added); }
@Override public boolean accepts(@NotNull PsiElement psiElement, ProcessingContext processingContext) { PsiElement currentElement = psiElement.getParent(); String expectedKey; int i = 0; int j = 0; while (currentElement != null) { if (i < Array.getLength(this.keys)) { if (YAMLKeyValue.class.isInstance(currentElement)) { expectedKey = this.keys[i++]; if (!expectedKey.equals("*") && !expectedKey.equals(((YAMLKeyValue) currentElement).getKeyText())) { return false; } } } else if (!this.rootTypes[j++].isInstance(currentElement)) { return false; } currentElement = currentElement.getParent(); } return !(i < Array.getLength(this.keys) || j < Array.getLength(this.rootTypes)); }
private void addPreColonStatements() { extend( CompletionType.BASIC, psiElement() .withLanguage(PythonLanguage.getInstance()) .and(FIRST_ON_LINE) //.andNot(RIGHT_AFTER_COLON) .andNot(IN_IMPORT_STMT) .andNot(IN_PARAM_LIST) .andNot(IN_ARG_LIST) .andNot(BEFORE_COND) .andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL) , new CompletionProvider<CompletionParameters>() { protected void addCompletions( @NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result ) { putKeywords(result, TailType.NONE, PyNames.DEF, PyNames.CLASS, PyNames.FOR, PyNames.IF, PyNames.WHILE, PyNames.WITH); putKeywords(result, TailType.CASE_COLON, PyNames.TRY); } } ); }
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())); } } }); }
public static DslPointcut<Object, String> name(final Object arg) { return new DslPointcut<Object, String>() { @Override List<String> matches(Object src, ProcessingContext context) { if (src instanceof GdslType) { return arg.equals(((GdslType)src).getName()) ? Arrays.asList((String)arg) : null; } if (src instanceof GdslMethod) { return arg.equals(((GdslMethod)src).getName()) ? Arrays.asList((String)arg) : null; } return Collections.emptyList(); } @Override boolean operatesOn(Class c) { return c == GdslType.class || c == GdslMethod.class; } }; }