本文整理汇总了Java中com.intellij.patterns.PsiElementPattern类的典型用法代码示例。如果您正苦于以下问题:Java PsiElementPattern类的具体用法?Java PsiElementPattern怎么用?Java PsiElementPattern使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiElementPattern类属于com.intellij.patterns包,在下文中一共展示了PsiElementPattern类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tagAttributePattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
public static PsiElementPattern.Capture<PsiElement> tagAttributePattern(
String tag,
String attributeName,
String fileName
) {
return XmlPatterns
.psiElement()
.inside(XmlPatterns
.xmlAttributeValue()
.inside(XmlPatterns
.xmlAttribute()
.withName(attributeName)
.withParent(XmlPatterns
.xmlTag()
.withName(tag)
)
)
).inFile(getXmlFilePattern(fileName));
}
示例2: topLevel
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
private static PsiElementPattern.Capture<PsiElement> topLevel() {
return psiElement()
.withLanguage(ImpexLanguage.getInstance())
.andNot(psiElement()
// FIXME bad code, but working
.andOr(
psiElement(ImpexTypes.HEADER_TYPE),
psiElement(ImpexTypes.MACRO_NAME_DECLARATION),
psiElement(ImpexTypes.ROOT_MACRO_USAGE),
psiElement(ImpexTypes.MACRO_DECLARATION),
psiElement(ImpexTypes.ASSIGN_VALUE),
psiElement(ImpexTypes.MACRO_VALUE),
psiElement(ImpexTypes.ATTRIBUTE),
psiElement(ImpexTypes.HEADER_TYPE_NAME),
psiElement(ImpexTypes.HEADER_PARAMETER_NAME),
psiElement(ImpexTypes.ATTRIBUTE_NAME),
psiElement(ImpexTypes.FIELD_VALUE),
psiElement(ImpexTypes.ATTRIBUTE_VALUE)
)
);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:ImpexCompletionContributor.java
示例3: addStatements
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
private void addStatements() {
PsiElementPattern.Capture<PsiElement> inStatement = psiElement()
.withLanguage(PythonLanguage.getInstance())
.and(IN_BEGIN_STMT)
.andNot(IN_IMPORT_STMT)
.andNot(IN_PARAM_LIST)
.andNot(IN_ARG_LIST)
.andNot(BEFORE_COND)
.andNot(AFTER_QUALIFIER);
extend(
CompletionType.BASIC,
inStatement,
new CompletionProvider<CompletionParameters>() {
protected void addCompletions(
@NotNull final CompletionParameters parameters, final ProcessingContext context, @NotNull final CompletionResultSet result
) {
putKeywords(result, TailType.SPACE, PyNames.ASSERT, PyNames.DEL, PyNames.EXEC, PyNames.FROM, PyNames.IMPORT, PyNames.RAISE);
putKeywords(result, TailType.NONE, PyNames.PASS);
}
}
);
extend(CompletionType.BASIC, inStatement.andNot(PY3K), new PyKeywordCompletionProvider(TailType.SPACE, PyNames.PRINT));
}
示例4: getAttributeInsideTagPattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* Not all tags are known, we need some custom syntax check
*
* {oxmultilang ident="FOO"}
* { oxmultilang ident="FOO"}
*/
public static PsiElementPattern.Capture<PsiElement> getAttributeInsideTagPattern(@NotNull String attribute, @NotNull String tag) {
return PlatformPatterns.psiElement(SmartyTokenTypes.STRING_LITERAL).afterLeafSkipping(
PlatformPatterns.or(
PlatformPatterns.psiElement(SmartyTokenTypes.DOUBLE_QUOTE),
PlatformPatterns.psiElement(SmartyTokenTypes.SINGLE_QUOTE),
PlatformPatterns.psiElement(SmartyTokenTypes.EQ),
PlatformPatterns.psiElement(SmartyTokenTypes.WHITE_SPACE),
PlatformPatterns.psiElement(PsiWhiteSpace.class)
),
PlatformPatterns.psiElement(SmartyTokenTypes.IDENTIFIER).withText(attribute)
).withParent(
PlatformPatterns.psiElement(SmartyTag.class).withText(
PlatformPatterns.string().matches("\\{\\s*" + tag + ".*")
)
);
}
示例5: getAfterPropertyAndInsideArrayObjectPattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* foo:[{"key": "<caret>"}]
*/
public PsiElementPattern.Capture<PsiElement> getAfterPropertyAndInsideArrayObjectPattern(@NotNull String key) {
return PlatformPatterns.psiElement().inFile(getMetadataFilePattern()).withParent(
PlatformPatterns.psiElement(JsonStringLiteral.class).with(FirstItemInTreePatternCondition.getInstance()).withParent(
PlatformPatterns.psiElement(JsonProperty.class).withParent(
PlatformPatterns.psiElement(JsonObject.class).withParent(
PlatformPatterns.psiElement(JsonArray.class).withParent(
PlatformPatterns.psiElement(JsonProperty.class).withFirstChild(
PlatformPatterns.psiElement(JsonStringLiteral.class).withText("\"" + key + "\"")
)
)
)
)
)
);
}
示例6: getAfterPropertyAndInsideObjectPattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* foo:{"key": "<caret>"}
*/
public PsiElementPattern.Capture<PsiElement> getAfterPropertyAndInsideObjectPattern(@NotNull String key) {
return PlatformPatterns.psiElement().inFile(getMetadataFilePattern()).withParent(
PlatformPatterns.psiElement(JsonStringLiteral.class).with(FirstItemInTreePatternCondition.getInstance()).withParent(
PlatformPatterns.psiElement(JsonProperty.class).withParent(
PlatformPatterns.psiElement(JsonObject.class).withParent(
PlatformPatterns.psiElement(JsonProperty.class).withFirstChild(
PlatformPatterns.psiElement(JsonStringLiteral.class).withText("\"" + key + "\"")
)
)
)
)
);
}
示例7: getPattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* [$this, '']
* array($this, '')
*/
@NotNull
@Override
public PsiElementPattern.Capture<PsiElement> getPattern() {
return PlatformPatterns.psiElement().withParent(
PlatformPatterns.psiElement(StringLiteralExpression.class).withParent(
PlatformPatterns.psiElement().withElementType(PhpElementTypes.ARRAY_VALUE).afterLeafSkipping(
PlatformPatterns.psiElement(PsiWhiteSpace.class),
PlatformPatterns.psiElement().withText(",")
).afterSiblingSkipping(
PlatformPatterns.psiElement(PsiWhiteSpace.class),
PlatformPatterns.psiElement().withElementType(PhpElementTypes.ARRAY_VALUE).withFirstNonWhitespaceChild(
PlatformPatterns.psiElement(Variable.class)
).afterLeafSkipping(
PlatformPatterns.psiElement(PsiWhiteSpace.class),
PlatformPatterns.psiElement().withText(PlatformPatterns.string().oneOf("[", "("))
)
)
)
);
}
示例8: Yaml
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
public Yaml()
{
PsiElementPattern.Capture<PsiElement> templateElementPattern = getViewElementMatcher("template");
extend(CompletionType.BASIC, templateElementPattern, new Templates());
PsiElementPattern.Capture<PsiElement> controllerElementPattern = getViewElementMatcher("controller");
extend(CompletionType.BASIC, controllerElementPattern, new Controller());
PsiElementPattern.Capture<PsiElement> matchElementPattern = getViewElementMatcher("match");
extend(CompletionType.BASIC, matchElementPattern, new MatchTypes());
PsiElementPattern.Capture<PsiElement> keyNamesMatcher = PlatformPatterns.psiElement().with(new Completions.Yaml.Matchers.KeyNames());
extend(CompletionType.BASIC, keyNamesMatcher, new KeyNames());
PsiElementPattern.Capture<PsiElement> valueMatcher = PlatformPatterns.psiElement().with(new Completions.Yaml.Matchers.MatchValues());
extend(CompletionType.BASIC, valueMatcher, new MatchValues());
}
示例9: getDirectiveNamePattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* "@foobar"
*/
private static PsiElementPattern.Capture<BladePsiDirectiveParameter> getDirectiveNamePattern(@NotNull final String[] directives) {
return PlatformPatterns.psiElement(BladePsiDirectiveParameter.class).withParent(
PlatformPatterns.psiElement(BladePsiDirective.class).with(new PatternCondition<BladePsiDirective>("Directive Name") {
@Override
public boolean accepts(@NotNull BladePsiDirective bladePsiDirective, ProcessingContext processingContext) {
for (String directive : directives) {
if(("@" + directive).equals(bladePsiDirective.getName())) {
return true;
}
}
return false;
}
})
);
}
示例10: getArrayParameterDirectiveForElementType
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* "@foobar(['<caret>'])"
*
* whereas "foobar" is registered a directive
*/
public static PsiElementPattern.Capture<PsiElement> getArrayParameterDirectiveForElementType(@NotNull IElementType... elementType) {
return PlatformPatterns.psiElement()
.withParent(
PlatformPatterns.psiElement(StringLiteralExpression.class)
.withParent(
PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE).withParent(
PlatformPatterns.psiElement(ArrayCreationExpression.class)
.withParent(ParameterList.class)
)
)
.with(
new MyDirectiveInjectionElementPatternCondition(elementType)
)
)
.withLanguage(PhpLanguage.INSTANCE);
}
示例11: register
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
PsiElementPattern.Capture<PsiElement> menuPattern = PlatformPatterns.psiElement().inFile(PlatformPatterns.psiFile().withName(PlatformPatterns.string().endsWith(".menu.yml")));
registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getSingleLineScalarKey("parent"), menuPattern), psiElement -> {
if(!DrupalProjectComponent.isEnabled(psiElement)) {
return null;
}
return new ParentMenu(psiElement);
});
registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getWithFirstRootKey(), menuPattern), psiElement -> {
if(!DrupalProjectComponent.isEnabled(psiElement)) {
return null;
}
return new MenuKeys(psiElement);
});
}
示例12: register
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
PsiElementPattern.Capture<PsiElement> filePattern = PlatformPatterns.psiElement().inFile(PlatformPatterns.psiFile().withName(PlatformPatterns.string().endsWith(".routing.yml")));
registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getParentKeyName("defaults"), filePattern), psiElement -> {
if(!DrupalProjectComponent.isEnabled(psiElement)) {
return null;
}
return new DefaultRoutes(psiElement);
});
registrar.register(PlatformPatterns.and(YamlElementPatternHelper.getParentKeyName("requirements"), filePattern), psiElement -> {
if(!DrupalProjectComponent.isEnabled(psiElement)) {
return null;
}
return new EntityAccessRoutes(psiElement);
});
}
示例13: literalInProperty
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
private static PsiElementPattern.Capture<JSLiteralExpression> literalInProperty(final String propertyName) {
return PlatformPatterns.psiElement(JSLiteralExpression.class).and(new FilterPattern(new ElementFilter() {
@Override
public boolean isAcceptable(Object element, @Nullable PsiElement context) {
if (element instanceof JSLiteralExpression) {
final JSLiteralExpression literal = (JSLiteralExpression)element;
if (literal.isQuotedLiteral()) {
final PsiElement parent = literal.getParent();
if (parent instanceof JSProperty && propertyName.equals(((JSProperty)parent).getName())) {
return EmberIndexUtil.hasEmberJS(literal.getProject());
}
}
}
return false;
}
@Override
public boolean isClassAcceptable(Class hintClass) {
return true;
}
}));
}
示例14: getParameterListArrayValuePattern
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
/**
* Provide array key pattern. we need incomplete array key support, too.
*
* foo(['<caret>'])
* foo(['<caret>' => 'foobar'])
*/
@NotNull
public static PsiElementPattern.Capture<PsiElement> getParameterListArrayValuePattern() {
return PlatformPatterns.psiElement()
.withParent(PlatformPatterns.psiElement(StringLiteralExpression.class).withParent(
PlatformPatterns.or(
PlatformPatterns.psiElement().withElementType(PhpElementTypes.ARRAY_VALUE)
.withParent(PlatformPatterns.psiElement(ArrayCreationExpression.class)
.withParent(ParameterList.class)
),
PlatformPatterns.psiElement().withElementType(PhpElementTypes.ARRAY_KEY)
.withParent(PlatformPatterns.psiElement(ArrayHashElement.class)
.withParent(PlatformPatterns.psiElement(ArrayCreationExpression.class)
.withParent(ParameterList.class)
)
)
))
);
}
示例15: methodParamsList
import com.intellij.patterns.PsiElementPattern; //导入依赖的package包/类
public static PsiElementPattern.Capture<PsiElement> methodParamsList(String methodName,
StringPattern className) {
return PlatformPatterns.psiElement().withElementType(PhpElementTypes.PARAMETER_LIST)
.withParent(
PlatformPatterns.psiElement()
.withElementType(PhpElementTypes.METHOD_REFERENCE)
.referencing(
PhpPatterns.psiElement().withElementType(
PhpElementTypes.CLASS_METHOD
).withName(methodName)
.withParent(
PhpPatterns.psiElement().withName(
className
))
)
);
}