当前位置: 首页>>代码示例>>Java>>正文


Java StandardPatterns类代码示例

本文整理汇总了Java中com.intellij.patterns.StandardPatterns的典型用法代码示例。如果您正苦于以下问题:Java StandardPatterns类的具体用法?Java StandardPatterns怎么用?Java StandardPatterns使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StandardPatterns类属于com.intellij.patterns包,在下文中一共展示了StandardPatterns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: KeywordCompletionContributor

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
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));
            }
          }
        });
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:25,代码来源:KeywordCompletionContributor.java

示例2: registerReferenceProviders

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    registrar.registerReferenceProvider(StandardPatterns.instanceOf(DotIdImpl.class), new PsiReferenceProvider() {
        @NotNull
        @Override
        public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
            if (element instanceof DotId) {
                List<PsiReference> l = new ArrayList<>();
                for(PsiElement e: DotPSITreeUtil.findDotIds(element.getProject(), ((DotId) element).getName())){
                    String value = e.getText();
                    if (value != null) {
                        l.add(new DotReference(element, new TextRange(0, value.length() + 1)));
                    }
                }
                PsiReference[] arr = new PsiReference[l.size()];
                return l.toArray(arr);
            }
            return PsiReference.EMPTY_ARRAY;
        }
    });
}
 
开发者ID:bzixilu,项目名称:dotplugin,代码行数:22,代码来源:DotReferenceContributor.java

示例3: recursionFilter

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
@Nullable
static ElementFilter recursionFilter(PsiElement element) {
  if (PsiJavaPatterns.psiElement().afterLeaf(PsiKeyword.RETURN).inside(PsiReturnStatement.class).accepts(element)) {
    return new ExcludeDeclaredFilter(ElementClassFilter.METHOD);
  }

  if (PsiJavaPatterns.psiElement().inside(
    StandardPatterns.or(
      PsiJavaPatterns.psiElement(PsiAssignmentExpression.class),
      PsiJavaPatterns.psiElement(PsiVariable.class))).
      andNot(PsiJavaPatterns.psiElement().afterLeaf(".")).accepts(element)) {
    return new AndFilter(new ExcludeSillyAssignment(),
                                                 new ExcludeDeclaredFilter(new ClassFilter(PsiVariable.class)));
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RecursionWeigher.java

示例4: addCompletions

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull 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 = 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())));
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PostfixTemplatesCompletionProvider.java

示例5: registerXmlAttributeValueReferenceProvider

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
public static void registerXmlAttributeValueReferenceProvider(PsiReferenceRegistrar registrar,
                                                              @Nullable @NonNls String[] attributeNames,
                                                              @Nullable ElementFilter elementFilter,
                                                              boolean caseSensitive,
                                                              @NotNull PsiReferenceProvider provider,
                                                              double priority) {
  if (attributeNames == null) {
    registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().and(new FilterPattern(elementFilter)), provider, priority);
    return;
  }

  final StringPattern namePattern = caseSensitive
                                    ? StandardPatterns.string().oneOf(attributeNames)
                                    : StandardPatterns.string().oneOfIgnoreCase(attributeNames);
  registrar
    .registerReferenceProvider(XmlPatterns.xmlAttributeValue().withLocalName(namePattern).and(new FilterPattern(elementFilter)), provider,
                               priority);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XmlUtil.java

示例6: registerXmlTagReferenceProvider

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
public static void registerXmlTagReferenceProvider(PsiReferenceRegistrar registrar,
                                                   @NonNls String[] names,
                                                   @Nullable ElementFilter elementFilter,
                                                   boolean caseSensitive,
                                                   @NotNull PsiReferenceProvider provider) {
  if (names == null) {
    registrar.registerReferenceProvider(XmlPatterns.xmlTag().and(new FilterPattern(elementFilter)), provider,
                                        PsiReferenceRegistrar.DEFAULT_PRIORITY);
    return;
  }


  final StringPattern namePattern =
    caseSensitive ? StandardPatterns.string().oneOf(names) : StandardPatterns.string().oneOfIgnoreCase(names);
  registrar.registerReferenceProvider(XmlPatterns.xmlTag().withLocalName(namePattern).and(new FilterPattern(elementFilter)), provider,
                                      PsiReferenceRegistrar.DEFAULT_PRIORITY);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:XmlUtil.java

示例7: AdditionalLanguagesCompletionContributor

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
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()));
          }
        }
      });
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:AdditionalLanguagesCompletionContributor.java

示例8: getUriDefinition

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
public static ElementPattern<PsiElement> getUriDefinition() {

        return PlatformPatterns.or(
                PlatformPatterns
                        .psiElement()
                        .withText(
                                StandardPatterns.string().startsWith("app://")
                        )
                        .withLanguage(PhpLanguage.INSTANCE)
                ,
                PlatformPatterns
                        .psiElement()
                        .withText(
                                StandardPatterns.string().startsWith("page://")
                        )
                        .withLanguage(PhpLanguage.INSTANCE)
        );
    }
 
开发者ID:kuma-guy,项目名称:idea-php-bear-sunday-plugin,代码行数:19,代码来源:UriElementPatternHelper.java

示例9: ShaderLabCGCompletionContributor

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
public ShaderLabCGCompletionContributor()
{
	extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
	{
		@RequiredReadAction
		@Override
		public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull 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);
				}
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:23,代码来源:ShaderLabCGCompletionContributor.java

示例10: CGCompletionContributor

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
public CGCompletionContributor()
{
	extend(CompletionType.BASIC, StandardPatterns.psiElement().withLanguage(CGLanguage.INSTANCE), new CompletionProvider()
	{
		@RequiredReadAction
		@Override
		public void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result)
		{
			for(String keyword : CGKeywords.KEYWORDS)
			{
				result.addElement(LookupElementBuilder.create(keyword).bold());
			}

			for(String m : ourMethods)
			{
				result.addElement(LookupElementBuilder.create(m + "()").withIcon(AllIcons.Nodes.Method).withInsertHandler(ParenthesesInsertHandler.getInstance(true)));
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:21,代码来源:CGCompletionContributor.java

示例11: SyntaxCompletionContributor

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
/** Constructor. */
public SyntaxCompletionContributor() {
    extend(CompletionType.BASIC,
            StandardPatterns.instanceOf(PsiElement.class),
            new CompletionProvider<CompletionParameters>() {
                @Override
                protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context,
                                              @NotNull CompletionResultSet result) {
                    PsiElement current = parameters.getPosition();
                    if (current.getParent() instanceof IgnoreSyntax && current.getPrevSibling() != null) {
                        result.addAllElements(SYNTAX_ELEMENTS);
                    }
                }
            }
    );
}
 
开发者ID:hsz,项目名称:idea-gitignore,代码行数:17,代码来源:SyntaxCompletionContributor.java

示例12: annotateCallMethod

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
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);
        }

    }
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:17,代码来源:EventMethodCallInspection.java

示例13: appFieldPattern

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
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);

}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:18,代码来源:YiiAppCompletionContributor.java

示例14: registerReferenceProviders

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
@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());
}
 
开发者ID:cmazx,项目名称:yiistorm,代码行数:20,代码来源:YiiReferenceContributor.java

示例15: registerXmlAttributeValueReferenceProvider

import com.intellij.patterns.StandardPatterns; //导入依赖的package包/类
public static void registerXmlAttributeValueReferenceProvider(PsiReferenceRegistrar registrar,
		@Nullable @NonNls String[] attributeNames,
		@Nullable ElementFilter elementFilter,
		boolean caseSensitive,
		@NotNull PsiReferenceProvider provider,
		double priority)
{
	if(attributeNames == null)
	{
		registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().and(new FilterPattern(elementFilter)), provider, priority);
		return;
	}

	final StringPattern namePattern = caseSensitive ? StandardPatterns.string().oneOf(attributeNames) : StandardPatterns.string().oneOfIgnoreCase(attributeNames);
	registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withLocalName(namePattern).and(new FilterPattern(elementFilter)), provider, priority);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:17,代码来源:XmlUtil.java


注:本文中的com.intellij.patterns.StandardPatterns类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。