@Nullable public static String getYamlKeyValueAsString(@NotNull YAMLMapping yamlHash, @NotNull String keyName) { YAMLKeyValue yamlKeyValue = getYamlKeyValue(yamlHash, keyName, false); if(yamlKeyValue == null) { return null; } final String valueText = yamlKeyValue.getValueText(); if(StringUtils.isBlank(valueText)) { return null; } return valueText; }
@Nullable public static String getYamlKeyValueAsString(@Nullable YAMLCompoundValue yamlCompoundValue, String keyName, boolean ignoreCase) { YAMLKeyValue yamlKeyValue1 = getYamlKeyValue(yamlCompoundValue, keyName, ignoreCase); if(yamlKeyValue1 == null) { return null; } String valueText = yamlKeyValue1.getValueText(); if (StringUtils.isBlank(valueText)) { return null; } return valueText; }
String valueText = ((YAMLKeyValue) element).getValueText(); if(StringUtils.isBlank(valueText)) { continue;
public static void attachYamlFieldTypeName(String keyName, DoctrineModelField doctrineModelField, YAMLKeyValue yamlKeyValue) { if("fields".equals(keyName) || "id".equals(keyName)) { YAMLKeyValue yamlType = YamlHelper.getYamlKeyValue(yamlKeyValue, "type"); if(yamlType != null) { doctrineModelField.setTypeName(yamlType.getValueText()); } YAMLKeyValue yamlColumn = YamlHelper.getYamlKeyValue(yamlKeyValue, "column"); if(yamlColumn != null) { doctrineModelField.setColumn(yamlColumn.getValueText()); } return; } if(RELATIONS.contains(keyName.toLowerCase())) { YAMLKeyValue targetEntity = YamlHelper.getYamlKeyValue(yamlKeyValue, "targetEntity"); if(targetEntity != null) { doctrineModelField.setRelationType(keyName); doctrineModelField.setRelation(getOrmClass(yamlKeyValue.getContainingFile(), targetEntity.getValueText())); } } }
/** * Find controller definition in yaml structure * * foo: * defaults: { _controller: "Bundle:Foo:Bar" } * defaults: * _controller: "Bundle:Foo:Bar" * controller: "Bundle:Foo:Bar" */ @Nullable public static String getYamlController(@NotNull YAMLKeyValue psiElement) { YAMLKeyValue yamlKeyValue = YamlHelper.getYamlKeyValue(psiElement, "defaults"); if(yamlKeyValue != null) { final YAMLValue container = yamlKeyValue.getValue(); if(container instanceof YAMLMapping) { YAMLKeyValue yamlKeyValueController = YamlHelper.getYamlKeyValue(container, "_controller", true); if(yamlKeyValueController != null) { String valueText = yamlKeyValueController.getValueText(); if(StringUtils.isNotBlank(valueText)) { return valueText; } } } } String controller = YamlHelper.getYamlKeyValueAsString(psiElement, "controller"); if(controller != null && StringUtils.isNotBlank(controller)) { return controller; } return null; }
/** * Symfony 3.3: "class" is optional; use service name for its it * * Foo\Bar: * arguments: ~ */ @Nullable public static String getServiceClassFromServiceMapping(@NotNull YAMLMapping yamlMapping) { YAMLKeyValue classKeyValue = yamlMapping.getKeyValueByKey("class"); // Symfony 3.3: "class" is optional; use service id for class // Foo\Bar: // arguments: ~ if(classKeyValue != null) { return classKeyValue.getValueText(); } PsiElement parent = yamlMapping.getParent(); if(parent instanceof YAMLKeyValue) { String keyText = ((YAMLKeyValue) parent).getKeyText(); if(YamlHelper.isClassServiceId(keyText)) { return keyText; } } return null; }
@Override public void visitElement(final PsiElement element) { if (element instanceof YAMLKeyValue) { final YAMLKeyValue yamlKeyValue = (YAMLKeyValue) element; if (OpenApiConstants.REF_KEY.equals(yamlKeyValue.getKeyText())) { final String refValue = StringUtils.removeAllQuotes(yamlKeyValue.getValueText()); if (isYamlFile(refValue)) { result.add( extractFileNameFromFileRefValue(refValue) + DELIMITER + getOpenApiFileTypeFromRefElement(yamlKeyValue.getValue(), refValue)); } } } super.visitElement(element); }
@Override public void visitElement(final PsiElement element) { if (element instanceof YAMLKeyValue) { final YAMLKeyValue yamlKeyValue = (YAMLKeyValue) element; if (SwaggerConstants.REF_KEY.equals(yamlKeyValue.getKeyText())) { final String refValue = StringUtils.removeAllQuotes(yamlKeyValue.getValueText()); if (isYamlFile(refValue)) { result.add( extractFileNameFromFileRefValue(refValue) + DELIMITER + getSwaggerFileType(yamlKeyValue.getValue(), refValue)); } } } super.visitElement(element); }
/** * foo: * resources: 'FOO' */ private static void visitYamlFile(@NotNull YAMLFile yamlFile, @NotNull Consumer<FileResourceConsumer> consumer) { for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues(yamlFile)) { YAMLKeyValue resourceKey = YamlHelper.getYamlKeyValue(yamlKeyValue, "resource", true); if(resourceKey == null) { continue; } String resource = PsiElementUtils.trimQuote(resourceKey.getValueText()); if(StringUtils.isBlank(resource)) { continue; } consumer.consume(new FileResourceConsumer(resourceKey, yamlKeyValue, normalize(resource))); } }
private static void addYamlClassMethods(@Nullable PsiElement psiElement, CompletionResultSet completionResultSet, String classTag) { if(psiElement == null) { return; } YAMLKeyValue classKeyValue = PsiElementUtils.getChildrenOfType(psiElement, PlatformPatterns.psiElement(YAMLKeyValue.class).withName(classTag)); if(classKeyValue == null) { return; } PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), classKeyValue.getValueText()); if(phpClass != null) { PhpElementsUtil.addClassPublicMethodCompletion(completionResultSet, phpClass); } }
YAMLKeyValue classKeyValue = parentMapping.getKeyValueByKey("class"); if (classKeyValue != null) { String valueText = classKeyValue.getValueText(); if (StringUtils.isNotBlank(valueText)) { return valueText;
valueText = ((YAMLKeyValue) element).getValueText(); } else {
String routePath = path.getValueText(); if(StringUtils.isNotBlank(routePath)) { route.setPath(routePath);
String valueText = ((YAMLKeyValue) yamlKeyValue).getValueText(); if(StringUtils.isBlank(valueText)) { return;
if(classKeyValue != null) { String valueText = classKeyValue.getValueText(); if(StringUtils.isNotBlank(valueText)) { consumer.consume(valueText);