gpt4 book ai didi

fr.adrienbrault.idea.symfony2plugin.config.yaml.YamlElementPatternHelper类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 13:43:31 24 4
gpt4 key购买 nike

本文整理了Java中fr.adrienbrault.idea.symfony2plugin.config.yaml.YamlElementPatternHelper类的一些代码示例,展示了YamlElementPatternHelper类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlElementPatternHelper类的具体详情如下:
包路径:fr.adrienbrault.idea.symfony2plugin.config.yaml.YamlElementPatternHelper
类名称:YamlElementPatternHelper

YamlElementPatternHelper介绍

暂无

代码示例

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

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);
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
  public void visitElement(PsiElement psiElement) {
    // @TODO: support key itself
    if (YamlElementPatternHelper.getServiceDefinition().accepts(psiElement) && YamlElementPatternHelper.getInsideServiceKeyPattern().accepts(psiElement)) {
      // @foo, @=foo, @?foo
      String serviceText = PsiElementUtils.trimQuote(psiElement.getText());
      if (isValidService(serviceText)) {
        String serviceName = YamlHelper.trimSpecialSyntaxServiceName(serviceText);
        // dont mark "@", "@?", "@@" escaping and expressions
        if (StringUtils.isNotBlank(serviceName) && !serviceName.equals(serviceName.toLowerCase()) && !YamlHelper.isClassServiceId(serviceName)) {
          holder.registerProblem(psiElement, SYMFONY_LOWERCASE_LETTERS_FOR_SERVICE, ProblemHighlightType.WEAK_WARNING);
        }
      }
    }
    super.visitElement(psiElement);
  }
});

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
  public void visitElement(PsiElement psiElement) {
    if(YamlElementPatternHelper.getServiceParameterDefinition().accepts(psiElement) && YamlElementPatternHelper.getInsideServiceKeyPattern().accepts(psiElement)) {
      invoke(psiElement, holder);
    }
    super.visitElement(psiElement);
  }
};

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

CompletionType.BASIC, YamlElementPatternHelper.getServiceDefinition(),
  new ServiceCompletionProvider()
);
  CompletionType.BASIC, YamlElementPatternHelper.getConfigKeyPattern(),
  new ConfigCompletionProvider()
);
  CompletionType.BASIC, YamlElementPatternHelper.getAfterCommaPattern(),
  new FactoryMethodCompletionProvider()
);
  CompletionType.BASIC, YamlElementPatternHelper.getSingleLineScalarKey("factory"),
  new MyFactoryStringMethodCompletionProvider()
);
  CompletionType.BASIC, YamlElementPatternHelper.getServiceParameterDefinition(),
  new CompletionProvider<CompletionParameters>() {
    public void addCompletions(@NotNull CompletionParameters parameters,
extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("unique"), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getNullAble()));
extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("nullable"), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getNullAble()));
extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmSingleLineScalarKey("associationKey"), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getNullAble()));
extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmParentLookup("joinColumn"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\JoinColumn"));
extend(CompletionType.BASIC, YamlElementPatternHelper.getFilterOnPrevParent("joinColumns"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\JoinColumn"));
extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmParentLookup("joinTable"), new DoctrineYamlAnnotationLookupBuilder("\\Doctrine\\ORM\\Mapping\\JoinTable"));
extend(CompletionType.BASIC, YamlElementPatternHelper.getOrmRoot(), new YamlCompletionProvider(new DoctrineStaticTypeLookupBuilder().getRootItems()));

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

if (YamlElementPatternHelper.getBindArgumentPattern().accepts(psiElement)) {
      targets.addAll(namedDefaultBindArgumentGoto(psiElement, psiText));
if(YamlElementPatternHelper.getSingleLineScalarKey("_controller", "controller").accepts(psiElement)) {
  targets.addAll(getControllerGoto(psiElement));
if(YamlElementPatternHelper.getSingleLineScalarKey("class").accepts(psiElement)) {
  targets.addAll(getClassGoto(psiElement));
if(YamlElementPatternHelper.getSingleLineScalarKey("resource").accepts(psiElement)) {
  targets.addAll(attachResourceBundleGoto(psiElement));
  targets.addAll(attachResourceOnPathGoto(psiElement));
  YamlElementPatternHelper.getInsideKeyValue("tags"),
  YamlElementPatternHelper.getSingleLineScalarKey("name")
).accepts(psiElement)) {
  targets.addAll(getTagClassesGoto(psiElement));
if(YamlElementPatternHelper.getTagsAsSequencePattern().accepts(psiElement)) {
  targets.addAll(getTagClassesGoto(psiElement));
  YamlElementPatternHelper.getInsideKeyValue("tags"),
  YamlElementPatternHelper.getSingleLineScalarKey("event")
).accepts(psiElement)) {
  targets.addAll(getEventGoto(psiElement));
  YamlElementPatternHelper.getInsideKeyValue("calls")
).accepts(psiElement)) {
  targets.addAll(getMethodGoto(psiElement));

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
  public void visitElement(PsiElement psiElement) {
    if ((YamlElementPatternHelper.getSingleLineScalarKey("class", "factory_class").accepts(psiElement) || YamlElementPatternHelper.getParameterClassPattern().accepts(psiElement)) && YamlElementPatternHelper.getInsideServiceKeyPattern().accepts(psiElement)) {
      // foobar.foo:
      //   class: Foobar\Foo
      invoke(psiElement, holder);
    } else if (psiElement.getNode().getElementType() == YAMLTokenTypes.SCALAR_KEY && YamlElementPatternHelper.getServiceIdKeyValuePattern().accepts(psiElement.getParent())) {
      // Foobar\Foo: ~
      String text = PsiElementUtils.getText(psiElement);
      if (StringUtils.isNotBlank(text) && YamlHelper.isClassServiceId(text) && text.contains("\\")) {
        PsiElement yamlKeyValue = psiElement.getParent();
        if (yamlKeyValue instanceof YAMLKeyValue && YamlHelper.getYamlKeyValue((YAMLKeyValue) yamlKeyValue, "resource") == null && YamlHelper.getYamlKeyValue((YAMLKeyValue) yamlKeyValue, "exclude") == null) {
          invoke(psiElement, holder);
        }
      }
    }
    super.visitElement(psiElement);
  }
};

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
  // defaults:
  //   route: <caret>
  registrar.register(
    YamlElementPatternHelper.getSingleLineScalarKey("route"),
    RouteGotoCompletionProvider::new
  );
  // defaults:
  //   template: <caret>
  registrar.register(
    YamlElementPatternHelper.getSingleLineScalarKey("template"),
    TemplateGotoCompletionRegistrar::new
  );
  // foo.service:
  //   decorates: <caret>
  registrar.register(
    YamlElementPatternHelper.getSingleLineScalarKey("decorates"),
    MyDecoratedServiceCompletionProvider::new
  );
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public static PsiElementPattern.Capture<PsiElement> getInsideServiceKeyPattern() {
  return getInsideKeyValue("services", "parameters");
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * Possible config key completion
 * In document root or key value context
 */
public static ElementPattern<PsiElement> getConfigKeyPattern() {
  return PlatformPatterns.psiElement().withParent(PlatformPatterns.or(
    PlatformPatterns.psiElement(YAMLDocument.class),
    PlatformPatterns.psiElement(YAMLScalar.class),
    PlatformPatterns.psiElement(YAMLKeyValue.class)
  )).inFile(
    // not should fire this in all yaml files
    getConfigFileNamePattern()
  );
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetServiceParameterDefinition() {
  String[] strings = {
    "%fo<caret>o%",
    "'%fo<caret>o%'",
    "\"%fo<caret>o%\"",
  };
  for (String s : strings) {
    assertTrue(YamlElementPatternHelper.getServiceParameterDefinition().accepts(createCaretElement(
      "argument: " + s, "foo.orm.yml"
    )));
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetServiceDefinition() {
  String[] strings = {
    "@f<caret>oo",
    "'@f<caret>oo'",
    "\"@f<caret>oo\"",
  };
  for (String s : strings) {
    assertTrue(YamlElementPatternHelper.getServiceDefinition().accepts(createCaretElement(
      "argument: " + s, "foo.orm.yml"
    )));
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetFilterOnPrevParent() {
  assertTrue(YamlElementPatternHelper.getFilterOnPrevParent("services").accepts(createCaretElement(
    "services:\n" +
    "   foo:\n" +
    "       <caret>a: foo\n"
    , "foo.orm.yml"))
  );
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetOrmRoot() {
  for (String s : dataProviders()) {
    assertTrue(YamlElementPatternHelper.getOrmRoot().accepts(createCaretElement(
      "class\\Foo:\n" + s, "foo.orm.yml"))
    );
    assertFalse(YamlElementPatternHelper.getOrmRoot().accepts(createCaretElement(
      "class\\Foo:\n" + s, "foo.aaa.yml"))
    );
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetParentKeyName() {
  for (String s : dataProviders()) {
    assertTrue(YamlElementPatternHelper.getParentKeyName("requirements").accepts(createCaretElement(
      "requirements:\n" + s, "foo.orm.yml"))
    );
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetOrmParentLookup() {
  for (String s : dataProviders()) {
    assertTrue(YamlElementPatternHelper.getOrmParentLookup("requirements").accepts(createCaretElement(
      "requirements:\n" + s, "foo.orm.yml"))
    );
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

public void testGetSuperParentArrayKey() {
  assertTrue(YamlElementPatternHelper.getSuperParentArrayKey("services").accepts(createCaretElement(
    "services:\n" +
    "   foo:\n" +
  )));
  assertTrue(YamlElementPatternHelper.getSuperParentArrayKey("services").accepts(createCaretElement(
    "services:\n" +
      "   foo:\n" +
  )));
  assertTrue(YamlElementPatternHelper.getSuperParentArrayKey("services").accepts(createCaretElement(
    "services:\n" +
      "   foo:\n" +
  assertTrue(YamlElementPatternHelper.getSuperParentArrayKey("services").accepts(createCaretElement(
    "services:\n" +
      "   foo:\n" +
  assertTrue(YamlElementPatternHelper.getSuperParentArrayKey("services").accepts(createCaretElement(
    "services:\n" +
      "   foo:\n" +
  assertFalse(YamlElementPatternHelper.getSuperParentArrayKey("services").accepts(createCaretElement(
    "service:\n" +
      "   foo:\n" +

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
  public void visitElement(PsiElement element) {
    if(YamlElementPatternHelper.getSingleLineScalarKey("_controller", "controller").accepts(element)) {
      String text = PsiElementUtils.trimQuote(element.getText());
      if(StringUtils.isNotBlank(text)) {
        InspectionUtil.inspectController(element, text, holder, new YamlLazyRouteName(element));
      }
    }
    super.visitElement(element);
  }
});

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

private void visitYamlMethod(PsiElement psiElement, ProblemsHolder holder, ContainerCollectionResolver.LazyServiceCollector collector) {
  if(YamlElementPatternHelper.getInsideKeyValue("calls").accepts(psiElement)) {
    PsiElement parent = psiElement.getParent();
    if ((parent instanceof YAMLScalar)) {
      YamlHelper.visitServiceCall((YAMLScalar) parent, s ->
        registerMethodProblem(psiElement, holder, YamlHelper.trimSpecialSyntaxServiceName(s), collector)
      );
    }
  }
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

/**
 * PsiFile / Document:
 *   serv<caret>ices: ~
 */
public static PsiElementPattern.Capture<PsiElement> getRootConfigKeyPattern() {
  return PlatformPatterns.psiElement(YAMLTokenTypes.SCALAR_KEY).withParent(
    PlatformPatterns.psiElement(YAMLKeyValue.class).withParent(
      PlatformPatterns.psiElement(YAMLMapping.class).withParent(
        PlatformPatterns.psiElement(YAMLDocument.class)
      )
    )
  ).inFile(getConfigFileNamePattern());
}

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

@Override
  public void visitElement(PsiElement element) {
    if(YamlElementPatternHelper.getSingleLineScalarKey("class").accepts(element)) {
      // class: '\Foo'
      String text = PsiElementUtils.trimQuote(element.getText());
      if(StringUtils.isNotBlank(text)) {
        this.problemRegistrar.attachDeprecatedProblem(element, text, holder);
      }
    } else if(element.getNode().getElementType() == YAMLTokenTypes.TEXT) {
      // @service
      String text = element.getText();
      if(StringUtils.isNotBlank(text) && text.startsWith("@")) {
        this.problemRegistrar.attachDeprecatedProblem(element, text.substring(1), holder);
        this.problemRegistrar.attachServiceDeprecatedProblem(element, text.substring(1), holder);
      }
    }
    super.visitElement(element);
  }
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com