Java Code Examples for fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getTopLevelKeyValues()
The following examples show how to use
fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getTopLevelKeyValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MenuIndex.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return inputData -> { Map<String, Void> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".menu.yml")) { return map; } for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) { String keyText = yamlKeyValue.getKeyText(); if(StringUtils.isBlank(keyText)) { continue; } map.put(keyText, null); } return map; }; }
Example 2
Source File: PermissionIndex.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
@NotNull @Override public DataIndexer<String, Void, FileContent> getIndexer() { return inputData -> { Map<String, Void> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!(psiFile instanceof YAMLFile) || !psiFile.getName().endsWith(".permissions.yml")) { return map; } for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) { String keyText = yamlKeyValue.getKeyText(); if(StringUtils.isBlank(keyText)) { continue; } map.put(keyText, null); } return map; }; }
Example 3
Source File: DoctrineYamlMappingDriver.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Nullable public DoctrineMetadataModel getMetadata(@NotNull DoctrineMappingDriverArguments args) { PsiFile psiFile = args.getPsiFile(); if(!(psiFile instanceof YAMLFile)) { return null; } Collection<DoctrineModelField> fields = new ArrayList<>(); DoctrineMetadataModel model = new DoctrineMetadataModel(fields); for (YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) { // first line is class name; check of we are right if(args.isEqualClass(YamlHelper.getYamlKeyName(yamlKeyValue))) { model.setTable(YamlHelper.getYamlKeyValueAsString(yamlKeyValue, "table")); fields.addAll(EntityHelper.getModelFieldsSet(yamlKeyValue)); } } if(model.isEmpty()) { return null; } return model; }
Example 4
Source File: FileResourceVisitorUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * 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))); } }
Example 5
Source File: ConfigSchemaIndex.java From idea-php-drupal-symfony2-bridge with MIT License | 5 votes |
@NotNull @Override public DataIndexer<String, Set<String>, FileContent> getIndexer() { return inputData -> { Map<String, Set<String>> map = new THashMap<>(); PsiFile psiFile = inputData.getPsiFile(); if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) { return map; } if(!(psiFile instanceof YAMLFile) || !isValidForIndex(psiFile)) { return map; } for(YAMLKeyValue yamlKeyValue: YamlHelper.getTopLevelKeyValues((YAMLFile) psiFile)) { String key = PsiElementUtils.trimQuote(yamlKeyValue.getKeyText()); if(StringUtils.isBlank(key) || key.contains("*")) { continue; } Set<String> mappings = new HashSet<>(); YAMLKeyValue mapping = YamlHelper.getYamlKeyValue(yamlKeyValue, "mapping"); if(mapping == null) { continue; } Set<String> keySet = YamlHelper.getKeySet(mapping); if(keySet != null) { mappings.addAll(keySet); } map.put(key, mappings); } return map; }; }
Example 6
Source File: RouteHelper.java From idea-php-symfony2-plugin with MIT License | 4 votes |
@NotNull public static Collection<StubIndexedRoute> getYamlRouteDefinitions(@NotNull YAMLDocument yamlDocument) { Collection<StubIndexedRoute> indexedRoutes = new ArrayList<>(); for(YAMLKeyValue yamlKeyValue : YamlHelper.getTopLevelKeyValues((YAMLFile) yamlDocument.getContainingFile())) { YAMLValue element = yamlKeyValue.getValue(); YAMLKeyValue path = YAMLUtil.findKeyInProbablyMapping(element, "path"); // Symfony bc if(path == null) { path = YAMLUtil.findKeyInProbablyMapping(element, "pattern"); } if(path == null) { continue; } // cleanup: 'foo', "foo" String keyText = StringUtils.strip(StringUtils.strip(yamlKeyValue.getKeyText(), "'"), "\""); if(StringUtils.isBlank(keyText)) { continue; } StubIndexedRoute route = new StubIndexedRoute(keyText); String routePath = path.getValueText(); if(StringUtils.isNotBlank(routePath)) { route.setPath(routePath); } String methods = YamlHelper.getStringValueOfKeyInProbablyMapping(element, "methods"); if(methods != null) { // value: [GET, POST, String[] split = methods.replace("[", "").replace("]", "").replaceAll(" +", "").toLowerCase().split(","); if(split.length > 0) { route.addMethod(split); } } String controller = getYamlController(yamlKeyValue); if(controller != null) { route.setController(normalizeRouteController(controller)); } indexedRoutes.add(route); } return indexedRoutes; }
Example 7
Source File: YamlTranslationVisitor.java From idea-php-symfony2-plugin with MIT License | 4 votes |
public static void collectFileTranslations(@NotNull YAMLFile yamlFile, @NotNull YamlTranslationCollector translationCollector) { for(YAMLKeyValue yamlKeyValue: YamlHelper.getTopLevelKeyValues(yamlFile)) { collectItems(yamlKeyValue, translationCollector); } }