gpt4 book ai didi

fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper.trimSpecialSyntaxServiceName()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 14:33:31 25 4
gpt4 key购买 nike

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

YamlHelper.trimSpecialSyntaxServiceName介绍

暂无

代码示例

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

private static String getServiceName(PsiElement psiElement) {
    return YamlHelper.trimSpecialSyntaxServiceName(PsiElementUtils.getText(psiElement));
  }
}

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

/**
 * Resolve "@service" to its class + proxy ServiceCollector for iteration
 */
@Nullable
public static PhpClass getServiceClass(@NotNull Project project, @NotNull String serviceName, @NotNull ContainerCollectionResolver.ServiceCollector collector) {
  serviceName = YamlHelper.trimSpecialSyntaxServiceName(serviceName);
  if(serviceName.length() == 0) {
    return null;
  }
  String resolve = collector.resolve(serviceName);
  if(resolve == null) {
    return null;
  }
  return PhpElementsUtil.getClassInterface(project, resolve);
}

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

/**
 * Resolve "@service" to its class
 */
@Nullable
public static PhpClass getServiceClass(@NotNull Project project, @NotNull String serviceName) {
  serviceName = YamlHelper.trimSpecialSyntaxServiceName(serviceName);
  if(serviceName.length() == 0) {
    return null;
  }
  ContainerService containerService = ContainerCollectionResolver.getService(project, serviceName);
  if(containerService == null) {
    return null;
  }
  String serviceClass = containerService.getClassName();
  if(serviceClass == null) {
    return null;
  }
  return PhpElementsUtil.getClassInterface(project, serviceClass);
}

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

@NotNull
private Collection<PsiElement> serviceGoToDeclaration(@NotNull PsiElement psiElement, @NotNull String serviceId) {
  serviceId = YamlHelper.trimSpecialSyntaxServiceName(serviceId).toLowerCase();
  String serviceClass = ContainerCollectionResolver.resolveService(psiElement.getProject(), serviceId);
  if (serviceClass != null) {
    Collection<PhpClass> phpClasses = PhpIndex.getInstance(psiElement.getProject()).getAnyByFQN(serviceClass);
    if(phpClasses.size() > 0) {
      return new ArrayList<>(phpClasses);
    }
  }
  // get container target on indexes
  return ServiceIndexUtil.findServiceDefinitions(psiElement.getProject(), serviceId);
}

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

@NotNull
  private static Map<String, PsiVariable> getGlobalsInner(@NotNull Project project) {
    Map<String, PsiVariable> variableMap = new HashMap<>();

    for (VirtualFile virtualFile : ConfigUtil.getConfigurations(project, "twig")) {
      PsiFile file = PsiManager.getInstance(project).findFile(virtualFile);
      if(!(file instanceof YAMLFile)) {
        continue;
      }

      for (Map.Entry<String, String> entry : TwigUtil.getTwigGlobalsFromYamlConfig((YAMLFile) file).entrySet()) {
        String value = entry.getValue();

        String serviceClass = ContainerCollectionResolver.resolveService(
          project,
          YamlHelper.trimSpecialSyntaxServiceName(value)
        );

        if(serviceClass != null) {
          variableMap.put(entry.getKey(), new PsiVariable("\\" + serviceClass));
        } else {
          variableMap.put(entry.getKey(), new PsiVariable(new HashSet<>()));
        }
      }
    }

    return variableMap;
  }
}

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

@Test
public void testTrimSpecialSyntaxServiceName() {
  assertEquals("logger", YamlHelper.trimSpecialSyntaxServiceName("@?logger="));
  assertEquals("logger", YamlHelper.trimSpecialSyntaxServiceName("?logger="));
  assertEquals("logger", YamlHelper.trimSpecialSyntaxServiceName("?logger"));
  assertEquals("logger", YamlHelper.trimSpecialSyntaxServiceName("logger="));
  assertEquals("", YamlHelper.trimSpecialSyntaxServiceName("?"));
  assertEquals("", YamlHelper.trimSpecialSyntaxServiceName("="));
}

代码示例来源: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

if(value instanceof YAMLSequence) {
  for (String id : YamlHelper.getYamlArrayValuesAsList((YAMLSequence) value)) {
    String idClean = YamlHelper.trimSpecialSyntaxServiceName(id);
    if(StringUtils.isNotBlank(idClean)) {
      services.putIfAbsent(idClean, 0);
                String textValue = ((YAMLScalar) value2).getTextValue();
                String idClean = YamlHelper.trimSpecialSyntaxServiceName(textValue);
                if(StringUtils.isNotBlank(idClean)) {
                  services.putIfAbsent(idClean, 0);

代码示例来源: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 element) {
    if(element.getLanguage() == PhpLanguage.INSTANCE) {
      // PHP
      MethodReference methodReference = PsiElementUtils.getMethodReferenceWithFirstStringParameter(element);
      if (methodReference != null && PhpElementsUtil.isMethodReferenceInstanceOf(methodReference, ServiceContainerUtil.SERVICE_GET_SIGNATURES)) {
        String serviceName = PhpElementsUtil.getFirstArgumentStringValue(methodReference);
        if(serviceName != null && StringUtils.isNotBlank(serviceName)) {
          if(!ContainerCollectionResolver.hasServiceNames(element.getProject(), serviceName)) {
            holder.registerProblem(element, INSPECTION_MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
          }
        }
      }
    } else if(element.getLanguage() == YAMLLanguage.INSTANCE) {
      // yaml
      if(YamlElementPatternHelper.getServiceDefinition().accepts(element) && YamlElementPatternHelper.getInsideServiceKeyPattern().accepts(element)) {
        String serviceName = YamlHelper.trimSpecialSyntaxServiceName(PsiElementUtils.getText(element));
        // dont mark "@", "@?", "@@" escaping and expressions
        if(serviceName.length() > 2 && !serviceName.startsWith("=") && !serviceName.startsWith("@")) {
          if(!ContainerCollectionResolver.hasServiceNames(element.getProject(), serviceName)) {
            holder.registerProblem(element, INSPECTION_MESSAGE, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
          }
        }
      }
    }
    super.visitElement(element);
  }
}

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