org.jetbrains.yaml.psi.YAMLValue Java Examples
The following examples show how to use
org.jetbrains.yaml.psi.YAMLValue.
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: DuplicateLocalRouteInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public void visitFile(PsiFile file) { // @TODO: detection of routing files in right way // routing.yml // comment.routing.yml // routing/foo.yml if(!YamlHelper.isRoutingFile(file)) { return; } YAMLDocument document = PsiTreeUtil.findChildOfType(file, YAMLDocument.class); if(document == null) { return; } YAMLValue topLevelValue = document.getTopLevelValue(); if(topLevelValue != null) { YamlHelper.attachDuplicateKeyInspection(topLevelValue, holder); } }
Example #2
Source File: ValueReferenceContributor.java From intellij-neos with GNU General Public License v3.0 | 5 votes |
@Override public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider( PlatformPatterns.psiElement(YAMLValue.class), new ValueReferenceProvider() ); }
Example #3
Source File: ValueReferenceContributor.java From intellij-neos with GNU General Public License v3.0 | 5 votes |
@NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if(!NeosProjectService.isEnabled(element)) { return new PsiReference[0]; } YAMLValue yamlElement = (YAMLValue) element; return new PsiReference[] { new ValueReference(yamlElement) }; }
Example #4
Source File: YamlReferenceInspection.java From intellij-swagger with MIT License | 5 votes |
@NotNull @Override public PsiElementVisitor buildVisitor( @NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { final PsiFile file = holder.getFile(); final VirtualFile virtualFile = file.getVirtualFile(); final Project project = holder.getProject(); boolean checkRefs = indexFacade.isMainSpecFile(virtualFile, project) || indexFacade.isPartialSpecFile(virtualFile, project); return new YamlPsiElementVisitor() { @Override public void visitKeyValue(@NotNull YAMLKeyValue keyValue) { if (!checkRefs) { return; } if ("$ref".equals(keyValue.getKeyText())) { YAMLValue value = keyValue.getValue(); if (!(value instanceof YAMLScalar)) { return; } final String unquotedValue = StringUtil.unquoteString(value.getText()); if (!unquotedValue.startsWith("http")) { doCheck(holder, value, new CreateYamlReferenceIntentionAction(unquotedValue)); } } super.visitKeyValue(keyValue); } }; }
Example #5
Source File: DataTypeCheckerAnnotator.java From intellij-kubernetes with Apache License 2.0 | 5 votes |
@Override public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) { if (!KubernetesYamlPsiUtil.isKubernetesFile(element)) { return; } final ModelProvider modelProvider = ModelProvider.INSTANCE; final ResourceTypeKey resourceKey = KubernetesYamlPsiUtil.findResourceKey(element); if (resourceKey != null && element instanceof YAMLKeyValue) { final YAMLKeyValue keyValue = (YAMLKeyValue) element; final Property property = KubernetesYamlPsiUtil.propertyForKey(modelProvider, resourceKey, keyValue); final YAMLValue value = keyValue.getValue(); if (property != null && property.getType() != null && value != null) { switch (property.getType()) { case ARRAY: if (!(value instanceof YAMLSequence)) { annotationHolder.createErrorAnnotation(value, "The content of " + keyValue.getKeyText() + " should be an array."); } break; case OBJECT: if (!(value instanceof YAMLMapping)) { annotationHolder.createErrorAnnotation(value, "The content of " + keyValue.getKeyText() + " should be an object."); } break; } } } }
Example #6
Source File: KubernetesYamlPsiUtil.java From intellij-kubernetes with Apache License 2.0 | 5 votes |
/** * Gets the top-level mapping in the document, if present. * * @param element an element within the document. * @return the top-level mapping, or {@code null} if one is not defined (e.g. in an empty document). */ @Nullable public static YAMLMapping getTopLevelMapping(final PsiElement element) { final YAMLDocument document = PsiTreeUtil.getParentOfType(element, YAMLDocument.class); if (document != null) { final YAMLValue topLevelValue = document.getTopLevelValue(); if (topLevelValue instanceof YAMLMapping) { return (YAMLMapping) topLevelValue; } } return null; }
Example #7
Source File: Unity3dMetaIndexExtension.java From consulo-unity3d with Apache License 2.0 | 5 votes |
public static String findGUIDFromFile(@Nonnull YAMLFile psiFile) { String guid = null; List<YAMLDocument> documents = psiFile.getDocuments(); for(YAMLDocument document : documents) { YAMLValue topLevelValue = document.getTopLevelValue(); if(topLevelValue instanceof YAMLMapping) { YAMLKeyValue guidValue = ((YAMLMapping) topLevelValue).getKeyValueByKey(Unity3dMetaManager.GUID_KEY); guid = guidValue == null ? null : guidValue.getValueText(); } } return guid; }
Example #8
Source File: Unity3dAssetGUIDReference.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@RequiredReadAction @Nonnull @Override public TextRange getRangeInElement() { YAMLValue value = myKeyValue.getValue(); if(value == null) { return super.getRangeInElement(); } int startOffsetInParent = value.getStartOffsetInParent(); return new TextRange(startOffsetInParent, startOffsetInParent + value.getTextLength()); }
Example #9
Source File: ValueReference.java From intellij-neos with GNU General Public License v3.0 | 4 votes |
public ValueReference(YAMLValue yamlElement) { // the "textRange" is used for highlighting the source element super(yamlElement, new TextRange(0, yamlElement.getTextLength())); this.yamlElement = yamlElement; }
Example #10
Source File: YamlReferenceContributor.java From intellij-swagger with MIT License | 4 votes |
private PsiElementPattern.Capture<YAMLValue> filePattern() { return psiElement(YAMLValue.class) .withText(FILE_NAME_PATTERN) .withoutText(URL_PATTERN) .withLanguage(YAMLLanguage.INSTANCE); }