本文整理汇总了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));
}
}
});
}
示例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;
}
});
}
示例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;
}
示例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())));
}
}
}
示例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);
}
示例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);
}
示例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()));
}
}
});
}
示例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)
);
}
示例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);
}
}
}
});
}
示例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)));
}
}
});
}
示例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);
}
}
}
);
}
示例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);
}
}
示例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);
}
示例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());
}
示例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);
}