com.intellij.patterns.StandardPatterns Java Examples

The following examples show how to use com.intellij.patterns.StandardPatterns. 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: 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 #2
Source File: YiiReferenceContributor.java    From yiistorm with MIT License 6 votes vote down vote up
@Override
public void registerReferenceProviders(PsiReferenceRegistrar registrar) {
    registrar.registerReferenceProvider(StandardPatterns.instanceOf(PhpPsiElement.class), new YiiPsiReferenceProvider());
    registrar.registerReferenceProvider(
            PlatformPatterns.psiElement(PsiElement.class).withParent(isParamListInMethodWithName(".+?widget\\(.+"))
            , new WidgetCallReferenceProvider());
    //View-to-view
    registrar.registerReferenceProvider(
            PlatformPatterns.psiElement(PhpPsiElement.class)
                    .withParent(isParamListInMethodWithName(".+?render(Partial)*\\(.+"))
                    .andNot(inFile(PlatformPatterns.string().endsWith("Controller.php")))
            , new ViewRenderViewReferenceProvider());
    //Controller-to-view
    registrar.registerReferenceProvider(
            PlatformPatterns.psiElement(PhpPsiElement.class)
                    .withParent(isParamListInMethodWithName("(?sim).+?render(Partial)*\\(.+"))
                    .and(inFile(PlatformPatterns.string().endsWith("Controller.php")))
            , new ControllerRenderViewReferenceProvider());
}
 
Example #3
Source File: ShaderLabCGCompletionContributor.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
public ShaderLabCGCompletionContributor()
{
	extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
	{
		@RequiredReadAction
		@Override
		public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull final CompletionResultSet result)
		{
			Place shreds = InjectedLanguageUtil.getShreds(parameters.getOriginalFile());

			for(PsiLanguageInjectionHost.Shred shred : shreds)
			{
				PsiLanguageInjectionHost host = shred.getHost();
				if(host instanceof ShaderCGScript)
				{
					ShaderLabFile containingFile = (ShaderLabFile) host.getContainingFile();
					ShaderReference.consumeProperties(containingFile, result::addElement);
				}
			}
		}
	});
}
 
Example #4
Source File: CGCompletionContributor.java    From consulo-unity3d with Apache License 2.0 6 votes vote down vote up
public CGCompletionContributor()
{
	extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
	{
		@RequiredReadAction
		@Override
		public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull CompletionResultSet result)
		{
			for(String keyword : CGKeywords.KEYWORDS)
			{
				result.addElement(LookupElementBuilder.create(keyword).bold());
			}

			for(String m : ourMethods)
			{
				result.addElement(LookupElementBuilder.create(m + "()").withIcon((Image) AllIcons.Nodes.Method).withInsertHandler(ParenthesesInsertHandler.getInstance(true)));
			}
		}
	});
}
 
Example #5
Source File: YiiAppCompletionContributor.java    From yiistorm with MIT License 6 votes vote down vote up
public static PsiElementPattern.Capture appFieldPattern() {
    return PlatformPatterns.psiElement()
            .withParent(PlatformPatterns.psiElement().withElementType(PhpElementTypes.FIELD_REFERENCE)
                    .withChild(
                            PlatformPatterns.psiElement().withElementType(PhpElementTypes.METHOD_REFERENCE)
                                    .referencing(
                                            PhpPatterns.psiElement().withElementType(PhpElementTypes.CLASS_METHOD)
                                                    .withName("app").withParent(
                                                    PhpPatterns.psiElement()
                                                            .withElementType(PhpElementTypes.CLASS)
                                                            .withName(StandardPatterns.string().oneOf("Yii", "YiiBase"))
                                            )
                                    )
                    )
            ).withLanguage(PhpLanguage.INSTANCE);

}
 
Example #6
Source File: EventMethodCallInspection.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
private void annotateCallMethod(@NotNull final PsiElement psiElement, @NotNull ProblemsHolder holder, ContainerCollectionResolver.LazyServiceCollector collector) {

        if(StandardPatterns.and(
            YamlElementPatternHelper.getInsideKeyValue("tags"),
            YamlElementPatternHelper.getSingleLineScalarKey("method")
        ).accepts(psiElement)) {
            visitYamlMethodTagKey(psiElement, holder, collector);
        }

        if((PlatformPatterns.psiElement(YAMLTokenTypes.TEXT).accepts(psiElement)
            || PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_DSTRING).accepts(psiElement)))
        {
            visitYamlMethod(psiElement, holder, collector);
        }

    }
 
Example #7
Source File: SyntaxCompletionContributor.java    From idea-gitignore with MIT License 6 votes vote down vote up
/** Constructor. */
public SyntaxCompletionContributor() {
    extend(CompletionType.BASIC,
            StandardPatterns.instanceOf(PsiElement.class),
            new CompletionProvider<CompletionParameters>() {
                @Override
                protected void addCompletions(@NotNull CompletionParameters parameters,
                                              @NotNull ProcessingContext context,
                                              @NotNull CompletionResultSet result) {
                    PsiElement current = parameters.getPosition();
                    if (current.getParent() instanceof IgnoreSyntax && current.getPrevSibling() != null) {
                        result.addAllElements(SYNTAX_ELEMENTS);
                    }
                }
            }
    );
}
 
Example #8
Source File: PostfixTemplateCompletionContributor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public PostfixTemplateCompletionContributor() {
  extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider() {
    @RequiredReadAction
    @Override
    public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull CompletionResultSet result) {
      Editor editor = parameters.getEditor();
      if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
          editor.getCaretModel().getCaretCount() != 1) {
        /**
         * disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
         */
        return;
      }

      PsiFile originalFile = parameters.getOriginalFile();
      PostfixLiveTemplate postfixLiveTemplate = PostfixTemplateCompletionContributor.getPostfixLiveTemplate(originalFile, editor);
      if (postfixLiveTemplate != null) {
        postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
        String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(new CustomTemplateCallback(editor, originalFile));
        if (possibleKey != null) {
          result = result.withPrefixMatcher(possibleKey);
          result.restartCompletionOnPrefixChange(
                  StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(originalFile, parameters.getOffset())));
        }
      }
    }
  });
}
 
Example #9
Source File: JsonReferenceContributor.java    From intellij-swagger with MIT License 5 votes vote down vote up
private PsiElementPattern.Capture<JsonLiteral> localDefinitionsPattern() {
  return psiElement(JsonLiteral.class)
      .andOr(
          psiElement()
              .withParent(psiElement(JsonProperty.class).withName(SwaggerConstants.REF_KEY)),
          psiElement().withSuperParent(3, psiElement(JsonProperty.class).withName("mapping")))
      .withText(StandardPatterns.string().contains(SwaggerConstants.REFERENCE_PREFIX))
      .withoutText(FILE_NAME_PATTERN)
      .withoutText(URL_PATTERN)
      .withLanguage(JsonLanguage.INSTANCE);
}
 
Example #10
Source File: CompletionLookupArrangerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void trimToLimit(ProcessingContext context) {
  if (myItems.size() < myLimit) return;

  List<LookupElement> items = getMatchingItems();
  Iterator<LookupElement> iterator = sortByRelevance(groupItemsBySorter(items)).iterator();

  final Set<LookupElement> retainedSet = ContainerUtil.newIdentityTroveSet();
  retainedSet.addAll(getPrefixItems(true));
  retainedSet.addAll(getPrefixItems(false));
  retainedSet.addAll(myFrozenItems);
  while (retainedSet.size() < myLimit / 2 && iterator.hasNext()) {
    retainedSet.add(iterator.next());
  }

  if (!iterator.hasNext()) return;

  List<LookupElement> removed = retainItems(retainedSet);
  for (LookupElement element : removed) {
    removeItem(element, context);
  }

  if (!myOverflow) {
    myOverflow = true;
    myProcess.addAdvertisement(OVERFLOW_MESSAGE, null);

    // restart completion on any prefix change
    myProcess.addWatchedPrefix(0, StandardPatterns.string());

    if (ApplicationManager.getApplication().isUnitTestMode()) printTestWarning();
  }
}
 
Example #11
Source File: PsiReferenceProviderBean.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public ElementPattern<PsiElement> createElementPattern() {
  if (patterns.length > 1) {
    List<ElementPattern<? extends PsiElement>> list = ContainerUtil.mapNotNull(patterns, PATTERN_NULLABLE_FUNCTION);
    //noinspection unchecked
    return StandardPatterns.or(list.toArray(new ElementPattern[list.size()]));
  }
  else if (patterns.length == 1) {
    return patterns[0].compilePattern();
  }
  else {
    LOG.error("At least one pattern should be specified");
    return null;
  }
}
 
Example #12
Source File: YiiReferenceContributor.java    From yiistorm with MIT License 5 votes vote down vote up
/**
 * Check element is param is parameterList in method reference
 *
 * @param name
 * @return
 */
private PsiElementPattern.Capture<PsiElement> isParamListInMethodWithName(String name) {
    return PlatformPatterns.psiElement(PhpElementTypes.PARAMETER_LIST)
            .withParent(
                    PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE)
                            .withText(StandardPatterns.string().matches(name))
            );
}
 
Example #13
Source File: I18nReferenceContributor.java    From yiistorm with MIT License 5 votes vote down vote up
public PsiElementPattern.Capture categoryPattern() {
    return PlatformPatterns.psiElement(PsiElement.class)
            .withElementType(PhpElementTypes.STRING)
            .withParent(YiiContibutorHelper.methodParamsList("t", StandardPatterns.string().oneOf("Yii", "YiiBase")))
            .insideStarting(
                    PlatformPatterns.psiElement().withElementType(PhpElementTypes.PARAMETER_LIST)
            )
            .withLanguage(PhpLanguage.INSTANCE);
}
 
Example #14
Source File: ViewCompletionContributor.java    From yiistorm with MIT License 5 votes vote down vote up
public static PsiElementPattern.Capture viewsPattern() {
    PsiElementPattern.Capture<PsiElement> $patterns = PlatformPatterns
            .psiElement(PsiElement.class)
            .withParent(
                    PlatformPatterns.or(
                            PlatformPatterns.psiElement(StringLiteralExpression.class)
                                    .withParent(
                                            PlatformPatterns.psiElement(PhpElementTypes.PARAMETER_LIST)
                                                    .withParent(
                                                            PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE)
                                                                    .withText(StandardPatterns.string().contains("renderPartial("))
                                                    )

                                    ),

                            PlatformPatterns.psiElement(StringLiteralExpression.class)
                                    .withParent(
                                            PlatformPatterns.psiElement(PhpElementTypes.PARAMETER_LIST)
                                                    .withParent(
                                                            PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE)
                                                                    .withText(StandardPatterns.string().contains("render("))
                                                    )

                                    )
                    )
            )
            .withLanguage(PhpLanguage.INSTANCE);
    return $patterns;
}
 
Example #15
Source File: AnnotationGoToDeclarationHandler.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Editor editor) {
    // @Test(<foo>=)
    List<PsiElement> psiElements = new ArrayList<>();
    if(AnnotationPattern.getDocAttribute().accepts(psiElement)) {
        this.addPropertyGoto(psiElement, psiElements);
    }

    // <@Test>
    // <@Test\Test>
    if (PlatformPatterns.psiElement(PhpDocElementTypes.DOC_TAG_NAME).withText(StandardPatterns.string().startsWith("@")).withLanguage(PhpLanguage.INSTANCE).accepts(psiElement)) {
        this.addDocTagNameGoto(psiElement, psiElements);
    }

    // @Route(name=<ClassName>::FOO)
    if (PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER).beforeLeaf(AnnotationPattern.getDocStaticPattern()).withLanguage(PhpLanguage.INSTANCE).accepts(psiElement)) {
        this.addStaticClassTargets(psiElement, psiElements);
    }

    // @Route(name=ClassName::<FOO>)
    if (AnnotationPattern.getClassConstant().accepts(psiElement)) {
        this.addStaticClassConstTargets(psiElement, psiElements);
    }

    return psiElements.toArray(new PsiElement[psiElements.size()]);
}
 
Example #16
Source File: CSharpPatterns.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static PsiElementPattern.Capture<PsiElement> fieldStart()
{
	return StandardPatterns.psiElement().withElementType(CSharpTokens.IDENTIFIER).withSuperParent(3, CSharpFieldDeclaration.class).with(new PatternCondition<PsiElement>("field-type-no-qualifier")
	{
		@Override
		@RequiredReadAction
		public boolean accepts(@Nonnull PsiElement element, ProcessingContext context)
		{
			CSharpFieldDeclaration declaration = PsiTreeUtil.getParentOfType(element, CSharpFieldDeclaration.class);
			if(declaration == null)
			{
				return false;
			}
			DotNetType type = declaration.getType();
			if(!(type instanceof CSharpUserType))
			{
				return false;
			}
			CSharpReferenceExpression referenceExpression = ((CSharpUserType) type).getReferenceExpression();
			if(referenceExpression.getQualifier() != null)
			{
				return false;
			}
			return true;
		}
	});
}
 
Example #17
Source File: CSharpDocCompletionContributor.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
public CSharpDocCompletionContributor()
{
	extend(CompletionType.BASIC, StandardPatterns.psiElement(CSharpDocTokenType.XML_NAME), new CompletionProvider()
	{
		@RequiredReadAction
		@Override
		public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull CompletionResultSet result)
		{
			PsiElement parent = parameters.getPosition().getParent();
			if(parent instanceof CSharpDocTagImpl)
			{
				Collection<CSharpDocTagInfo> tags = CSharpDocTagManager.getInstance().getTags();
				for(CSharpDocTagInfo tag : tags)
				{
					result.addElement(LookupElementBuilder.create(tag.getName()));
				}
			}
			else if(parent instanceof CSharpDocAttribute)
			{
				CSharpDocTagInfo tagInfo = ((CSharpDocAttribute) parent).getTagInfo();
				if(tagInfo == null)
				{
					return;
				}
				for(CSharpDocAttributeInfo attributeInfo : tagInfo.getAttributes())
				{
					result.addElement(LookupElementBuilder.create(attributeInfo.getName()));
				}
			}
		}
	});
}
 
Example #18
Source File: CommandNameCompletionProvider.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
void addTo(CompletionContributor contributor) {
    BashPsiPattern internal = new BashPsiPattern().withParent(BashInternalCommand.class);
    BashPsiPattern generic = new BashPsiPattern().withParent(BashGenericCommand.class);
    ElementPattern<PsiElement> internalOrGeneric = StandardPatterns.or(internal, generic);

    BashPsiPattern pattern = new BashPsiPattern().withParent(internalOrGeneric);

    contributor.extend(CompletionType.BASIC, pattern, this);
}
 
Example #19
Source File: GraphQLCompletionContributor.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
private void completeFieldDefinitionOutputTypeName() {
    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());
            final GraphQLSchema schema = GraphQLTypeDefinitionRegistryServiceImpl.getService(completionElement.getProject()).getSchema(completionElement);
            if (registry != null && schema != null) {
                registry.scalars().values().forEach(scalar -> {
                    result.addElement(LookupElementBuilder.create(scalar.getName()));
                });
                final String queryName = schema.getQueryType() != null ? schema.getQueryType().getName() : "Query";
                final String mutationName = schema.getMutationType() != null ? schema.getMutationType().getName() : "Mutation";
                final String subscriptionName = schema.getSubscriptionType() != null ? schema.getSubscriptionType().getName() : "Subscription";
                final Set<String> nonOutputTypes = Sets.newLinkedHashSet(Lists.newArrayList(queryName, mutationName, subscriptionName));
                registry.types().values().forEach(type -> {
                    if (!(type instanceof InputObjectTypeDefinition) && !nonOutputTypes.contains(type.getName())) {
                        result.addElement(LookupElementBuilder.create(type.getName()));
                    }
                });
            }
        }
    };
    extend(CompletionType.BASIC,
            PlatformPatterns.and(
                    psiElement(GraphQLElementTypes.NAME).afterLeafSkipping(
                            // skip
                            PlatformPatterns.or(psiComment(), psiElement(TokenType.WHITE_SPACE), psiElement().withText("[")),
                            // until field type colon occurs
                            psiElement().withText(":")
                    ).inside(GraphQLFieldDefinition.class),
                    StandardPatterns.not(psiElement().inside(GraphQLArgumentsDefinition.class)), // field def arguments
                    StandardPatterns.not(psiElement().inside(GraphQLArguments.class)) // directive argument
            ), provider);
}
 
Example #20
Source File: YamlReferenceContributor.java    From intellij-swagger with MIT License 5 votes vote down vote up
private PsiElementPattern.Capture<YAMLQuotedText> mappingSchemaNamePattern() {
  return psiElement(YAMLQuotedText.class)
      .withSuperParent(3, psiElement(YAMLKeyValue.class).withName("mapping"))
      .withoutText(StandardPatterns.string().contains(SwaggerConstants.REFERENCE_PREFIX))
      .withoutText(FILE_NAME_PATTERN)
      .withoutText(URL_PATTERN)
      .withLanguage(YAMLLanguage.INSTANCE);
}
 
Example #21
Source File: YamlReferenceContributor.java    From intellij-swagger with MIT License 5 votes vote down vote up
private PsiElementPattern.Capture<YAMLQuotedText> localDefinitionsPattern() {
  return psiElement(YAMLQuotedText.class)
      .andOr(
          psiElement()
              .withParent(psiElement(YAMLKeyValue.class).withName(SwaggerConstants.REF_KEY)),
          psiElement().withSuperParent(3, psiElement(YAMLKeyValue.class).withName("mapping")))
      .withText(StandardPatterns.string().contains(SwaggerConstants.REFERENCE_PREFIX))
      .withoutText(FILE_NAME_PATTERN)
      .withoutText(URL_PATTERN)
      .withLanguage(YAMLLanguage.INSTANCE);
}
 
Example #22
Source File: JsonReferenceContributor.java    From intellij-swagger with MIT License 5 votes vote down vote up
private PsiElementPattern.Capture<JsonLiteral> mappingSchemaNamePattern() {
  return psiElement(JsonLiteral.class)
      .withSuperParent(3, psiElement(JsonProperty.class).withName("mapping"))
      .withoutText(StandardPatterns.string().contains(SwaggerConstants.REFERENCE_PREFIX))
      .withoutText(FILE_NAME_PATTERN)
      .withoutText(URL_PATTERN)
      .withLanguage(JsonLanguage.INSTANCE);
}
 
Example #23
Source File: CSharpPatterns.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static PsiElementPattern.Capture<PsiElement> statementStart()
{
	return StandardPatterns.psiElement().withElementType(CSharpTokens.IDENTIFIER).with(new PatternCondition<PsiElement>("statement-validator")
	{
		@Override
		@RequiredReadAction
		public boolean accepts(@Nonnull PsiElement element, ProcessingContext processingContext)
		{
			PsiElement parent = element.getParent();
			PsiElement parent2 = parent == null ? null : parent.getParent();
			PsiElement parent3 = parent2 == null ? null : parent2.getParent();
			if(parent3 instanceof CSharpLocalVariable)
			{
				return validateLocalVariable((CSharpLocalVariable) parent3);
			}

			if(parent instanceof CSharpReferenceExpression && parent2 instanceof CSharpExpressionStatementImpl)
			{
				return validateReferenceExpression((CSharpReferenceExpression) parent);
			}
			return false;
		}

		@RequiredReadAction
		private boolean validateReferenceExpression(CSharpReferenceExpression expression)
		{
			if(expression.getQualifier() != null)
			{
				return false;
			}
			CSharpReferenceExpression.ResolveToKind kind = expression.kind();
			return kind == CSharpReferenceExpression.ResolveToKind.ANY_MEMBER;
		}

		@RequiredReadAction
		private boolean validateLocalVariable(CSharpLocalVariable localVariable)
		{
			// we cant use it when 'const <exp>'
			if(localVariable == null || localVariable.isConstant())
			{
				return false;
			}
			// disable it inside non local decl statement, like catch
			if(!(localVariable.getParent() instanceof CSharpLocalVariableDeclarationStatement))
			{
				return false;
			}
			DotNetType type = localVariable.getType();
			if(!(type instanceof CSharpUserType))
			{
				return false;
			}
			CSharpReferenceExpression referenceExpression = ((CSharpUserType) type).getReferenceExpression();
			if(referenceExpression.getQualifier() != null)
			{
				return false;
			}
			return CSharpPsiUtilImpl.isNullOrEmpty(localVariable);
		}
	});
	/*return StandardPatterns.psiElement().withElementType(CSharpTokens.IDENTIFIER).withSuperParent(3, CSharpLocalVariable.class).with(new PatternCondition<PsiElement>
	("null-identifier-local-var")

	{
		@Override
		@RequiredReadAction
		public boolean accepts(@NotNull PsiElement element, ProcessingContext context)
		{
			CSharpLocalVariable localVariable = PsiTreeUtil.getParentOfType(element, CSharpLocalVariable.class);
			// we cant use it when 'const <exp>'
			if(localVariable == null || localVariable.isConstant())
			{
				return false;
			}
			// disable it inside non local decl statement, like catch
			if(!(localVariable.getParent() instanceof CSharpLocalVariableDeclarationStatement))
			{
				return false;
			}
			DotNetType type = localVariable.getType();
			if(!(type instanceof CSharpUserType))
			{
				return false;
			}
			CSharpReferenceExpression referenceExpression = ((CSharpUserType) type).getReferenceExpression();
			if(referenceExpression.getQualifier() != null)
			{
				return false;
			}
			return CSharpPsiUtilImpl.isNullOrEmpty(localVariable);
		}
	}); */
}
 
Example #24
Source File: RequirejsPsiReferenceContributor.java    From WebStormRequireJsPlugin with MIT License 4 votes vote down vote up
@Override
public void registerReferenceProviders(PsiReferenceRegistrar psiReferenceRegistrar) {
    RequirejsPsiReferenceProvider provider = new RequirejsPsiReferenceProvider();

    psiReferenceRegistrar.registerReferenceProvider(StandardPatterns.instanceOf(JSLiteralExpression.class), provider);
}
 
Example #25
Source File: YiiContibutorHelper.java    From yiistorm with MIT License 4 votes vote down vote up
public static PsiElementPattern.Capture firstStringInYiiMethod(String methodName) {
    return firstStringInMethod(methodName, StandardPatterns.string().oneOf("Yii", "YiiBase"));
}
 
Example #26
Source File: YiiContibutorHelper.java    From yiistorm with MIT License 4 votes vote down vote up
public static PsiElementPattern.Capture stringInYiiMethod(String methodName) {
    return stringInMethod(methodName, StandardPatterns.string().oneOf("Yii", "YiiBase"));
}
 
Example #27
Source File: AbsolutePathCompletionProvider.java    From BashSupport with Apache License 2.0 4 votes vote down vote up
@Override
void addTo(CompletionContributor contributor) {
    //not in composed words, these will be completed by the DynamicPathCompletionProvider
    contributor.extend(CompletionType.BASIC, StandardPatterns.instanceOf(PsiElement.class), this);
}
 
Example #28
Source File: MindMapFacetDetector.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ElementPattern<FileContent> createSuitableFilePattern() {
  return FileContentPattern.fileContent().withName(StandardPatterns.string().endsWith(".mmd"));
}
 
Example #29
Source File: CompletionResultSet.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Request that the completion contributors be run again when the user changes the prefix so that it becomes equal to the one given.
 */
public void restartCompletionOnPrefixChange(String prefix) {
  restartCompletionOnPrefixChange(StandardPatterns.string().equalTo(prefix));
}
 
Example #30
Source File: CompletionResultSet.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Request that the completion contributors be run again when the user changes the prefix in any way.
 */
public void restartCompletionOnAnyPrefixChange() {
  restartCompletionOnPrefixChange(StandardPatterns.string());
}