本文整理汇总了Java中com.intellij.patterns.PatternCondition类的典型用法代码示例。如果您正苦于以下问题:Java PatternCondition类的具体用法?Java PatternCondition怎么用?Java PatternCondition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PatternCondition类属于com.intellij.patterns包,在下文中一共展示了PatternCondition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInContext
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
@Override
public boolean isInContext(@NotNull PsiFile file, int offset) {
if (!super.isInContext(file, offset)) {
return false;
}
final ElementPattern<PsiElement> illegalPattern = or(psiElement().inside(JsonStringLiteral.class),
psiElement().inside(psiElement(JsonValue.class)
.with(new PatternCondition<PsiElement>("insidePropertyKey") {
@Override
public boolean accepts(@NotNull PsiElement element,
ProcessingContext context) {
return JsonPsiUtil.isPropertyKey(element);
}
})));
return !illegalPattern.accepts(file.findElementAt(offset));
}
示例2: withArguments
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyMethodCallPattern withArguments(final ElementPattern<? extends GrExpression>... arguments) {
return with(new PatternCondition<GrCallExpression>("withArguments") {
@Override
public boolean accepts(@NotNull GrCallExpression callExpression, ProcessingContext context) {
final GrArgumentList argumentList = callExpression.getArgumentList();
if (argumentList == null) return false;
final GrExpression[] actualArguments = argumentList.getExpressionArguments();
if (arguments.length != actualArguments.length) {
return false;
}
for (int i = 0; i < actualArguments.length; i++) {
if (!arguments[i].accepts(actualArguments[i], context)) {
return false;
}
}
return true;
}
});
}
示例3: withAppEngineFlexYamlContent
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
private AppEngineFlexPattern withAppEngineFlexYamlContent() {
return with(
new PatternCondition<FileContent>("with-appengine-java-flexible") {
@Override
public boolean accepts(@NotNull FileContent fileContent, ProcessingContext context) {
// checks for flex engine file names and then checks for required configuration line
// inside.
boolean nameMatch = APP_ENGINE_FLEX_CONFIG_FILES.contains(fileContent.getFileName());
if (nameMatch) {
Scanner scanner = new Scanner(fileContent.getContentAsText().toString());
while (scanner.hasNextLine()) {
if (scanner.nextLine().startsWith(APP_ENGINE_FLEX_REQUIRED_YAML_CONTENT)) {
return true;
}
}
}
return false;
}
});
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:21,代码来源:AppEngineFlexibleFrameworkDetector.java
示例4: getDirectiveNamePattern
import com.intellij.patterns.PatternCondition; //导入依赖的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;
}
})
);
}
示例5: testThatRoutePermissionCompletesAndNavigates
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public void testThatRoutePermissionCompletesAndNavigates() {
assertCompletionContains(YAMLFileType.YML, "" +
"config.import_full:\n" +
" requirements:\n" +
" _permission: '<caret>'",
"synchronize configuration"
);
assertNavigationMatch(YAMLFileType.YML, "" +
"config.import_full:\n" +
" requirements:\n" +
" _permission: 'synchronize<caret> configuration'",
PlatformPatterns.psiElement(YAMLKeyValue.class).with(new PatternCondition<YAMLKeyValue>("key") {
@Override
public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
return "synchronize configuration".equals(yamlKeyValue.getKeyText());
}
})
);
}
开发者ID:Haehnchen,项目名称:idea-php-drupal-symfony2-bridge,代码行数:21,代码来源:YamlPermissionGotoCompletionTest.java
示例6: testYamlServiceLineMarker
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public void testYamlServiceLineMarker() {
myFixture.configureByText(YAMLFileType.YML,
"services:\n" +
" foo:\n" +
" class: Service\\YamlBar"
);
assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" +
"namespace Service{\n" +
" class YamlBar{}\n" +
"}"
), new LineMarker.TargetAcceptsPattern("Navigate to definition", PlatformPatterns.psiElement(YAMLKeyValue.class).with(new PatternCondition<YAMLKeyValue>("KeyText") {
@Override
public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
return yamlKeyValue.getKeyText().equals("foo");
}
})));
}
示例7: testYamlServiceLineMarkerForClassName
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public void testYamlServiceLineMarkerForClassName() {
myFixture.configureByText(YAMLFileType.YML,
"services:\n" +
" Service\\YamlBar: ~\n"
);
assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" +
"namespace Service{\n" +
" class YamlBar{}\n" +
"}"
), new LineMarker.TargetAcceptsPattern("Navigate to definition", PlatformPatterns.psiElement(YAMLKeyValue.class).with(new PatternCondition<YAMLKeyValue>("KeyText") {
@Override
public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) {
return yamlKeyValue.getKeyText().equals("Service\\YamlBar");
}
})));
}
示例8: registerTopLevelSem
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public <T extends PsiModifierListOwner> void registerTopLevelSem(SemRegistrar registrar, final ElementPattern<? extends T> parentPattern, final JamMemberMeta<T,?> parentMeta) {
final boolean isPackage = parentMeta instanceof JamPackageMeta;
final PsiAnnotationPattern annoPattern = myAnnoNamePattern.withSuperParent(
2, isPackage ? PACKAGE_STATEMENT.with(new PatternCondition<PsiPackageStatement>("package") {
@Override
public boolean accepts(@NotNull PsiPackageStatement psiPackageStatement, ProcessingContext context) {
return parentPattern.accepts(psiPackageStatement.getPackageReference().resolve(), context);
}
}) : parentPattern);
registrar.registerSemElementProvider(myMetaKey, annoPattern, annotation -> {
final PsiElement parent = annotation.getParent().getParent();
final T element = (isPackage && parent instanceof PsiPackageStatement? (T)((PsiPackageStatement)parent).getPackageReference().resolve() : (T)parent);
if (element != null && SemService.getSemService(annotation.getProject()).getSemElement(parentMeta.getMetaKey(), element) == parentMeta) {
return this;
}
return null;
});
registerChildren(registrar, annoPattern);
}
示例9: getElementPattern
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
private static PsiJavaElementPattern.Capture<PsiLiteralExpression> getElementPattern(String annotationParamName) {
return PsiJavaPatterns.literalExpression().
annotationParam(annotationParamName, PsiJavaPatterns.psiAnnotation().with(new PatternCondition<PsiAnnotation>("isTestNGAnnotation") {
@Override
public boolean accepts(@NotNull PsiAnnotation annotation, ProcessingContext context) {
return TestNGUtil.isTestNGAnnotation(annotation);
}
}));
}
示例10: left
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyBinaryExpressionPattern left(@NotNull final ElementPattern pattern) {
return with(new PatternCondition<GrBinaryExpression>("left") {
@Override
public boolean accepts(@NotNull final GrBinaryExpression psiBinaryExpression, final ProcessingContext context) {
return pattern.accepts(psiBinaryExpression.getLeftOperand(), context);
}
});
}
示例11: right
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyBinaryExpressionPattern right(@NotNull final ElementPattern pattern) {
return with(new PatternCondition<GrBinaryExpression>("right") {
@Override
public boolean accepts(@NotNull final GrBinaryExpression psiBinaryExpression, final ProcessingContext context) {
return pattern.accepts(psiBinaryExpression.getRightOperand(), context);
}
});
}
示例12: operation
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyBinaryExpressionPattern operation(final ElementPattern pattern) {
return with(new PatternCondition<GrBinaryExpression>("operation") {
@Override
public boolean accepts(@NotNull final GrBinaryExpression psiBinaryExpression, final ProcessingContext context) {
return pattern.accepts(psiBinaryExpression.getOperationTokenType(), context);
}
});
}
示例13: withLabel
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyNamedArgumentPattern withLabel(@NotNull final String label) {
return with(new PatternCondition<GrNamedArgument>("left") {
@Override
public boolean accepts(@NotNull GrNamedArgument namedArgument, final ProcessingContext context) {
return label.equals(namedArgument.getLabelName());
}
});
}
示例14: withExpression
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyNamedArgumentPattern withExpression(@NotNull final ElementPattern pattern) {
return with(new PatternCondition<GrNamedArgument>("left") {
@Override
public boolean accepts(@NotNull GrNamedArgument namedArgument, final ProcessingContext context) {
return pattern.accepts(namedArgument.getExpression(), context);
}
});
}
示例15: isParameterOfMethodCall
import com.intellij.patterns.PatternCondition; //导入依赖的package包/类
public GroovyNamedArgumentPattern isParameterOfMethodCall(@Nullable final ElementPattern<? extends GrCall> methodCall) {
return with(new PatternCondition<GrNamedArgument>("left") {
@Override
public boolean accepts(@NotNull GrNamedArgument namedArgument, final ProcessingContext context) {
GrCall call = PsiUtil.getCallByNamedParameter(namedArgument);
return call != null && (methodCall == null || methodCall.accepts(call, context));
}
});
}