本文整理汇总了Java中org.jetbrains.yaml.psi.YAMLMapping类的典型用法代码示例。如果您正苦于以下问题:Java YAMLMapping类的具体用法?Java YAMLMapping怎么用?Java YAMLMapping使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
YAMLMapping类属于org.jetbrains.yaml.psi包,在下文中一共展示了YAMLMapping类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: annotate
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element,
@NotNull final AnnotationHolder annotationHolder) {
if (element instanceof YAMLMapping) {
// TODO: Fix
// final YAMLMapping mapping = (YAMLMapping) element;
// final Collection<YAMLKeyValue> keyValues = mapping.getKeyValues();
// final Set<String> existingKeys = new HashSet<>(keyValues.size());
// for (final YAMLKeyValue keyValue : keyValues) {
// if (keyValue.getKey() != null && !existingKeys.add(keyValue.getKeyText().trim())) {
// annotationHolder.createErrorAnnotation(keyValue.getKey(),
// "Duplicated PROPERTY '" + keyValue.getKeyText() + "'")
// .registerFix(new DeletePropertyIntentionAction());
// }
// }
}
}
开发者ID:1tontech,项目名称:intellij-spring-assistant,代码行数:18,代码来源:DuplicateKeyAnnotator.java
示例2: getHelpersInFile
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
public static HashMap<String, String> getHelpersInFile(@NotNull PsiFile psiFile) {
YAMLKeyValue defaultContext = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, "Neos", "Fusion", "defaultContext");
if (defaultContext == null) {
defaultContext = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, "TYPO3", "TypoScript", "defaultContext");
}
HashMap<String, String> result = new HashMap<>();
if (defaultContext != null) {
PsiElement mapping = defaultContext.getLastChild();
if (mapping instanceof YAMLMapping) {
for (PsiElement mappingElement : mapping.getChildren()) {
if (mappingElement instanceof YAMLKeyValue) {
YAMLKeyValue keyValue = (YAMLKeyValue) mappingElement;
result.put(keyValue.getKeyText(), keyValue.getValueText());
NeosProjectComponent.getLogger().debug(keyValue.getKeyText() + ": " + keyValue.getValueText());
}
}
}
}
return result;
}
开发者ID:cvette,项目名称:intellij-neos,代码行数:24,代码来源:EelHelperUtil.java
示例3: annotate
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@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 Model model = KubernetesYamlPsiUtil.modelForKey(modelProvider, resourceKey, keyValue);
if (keyValue.getValue() instanceof YAMLMapping && model != null) {
final YAMLMapping mapping = (YAMLMapping) keyValue.getValue();
final Set<String> expectedProperties = model.getProperties().keySet();
//noinspection ConstantConditions
mapping.getKeyValues()
.stream()
.filter(k -> !expectedProperties.contains(k.getKeyText().trim()))
.forEach(k -> annotationHolder.createWarningAnnotation(k.getKey(), "Property '" + k.getKeyText() + "' is not expected here.").registerFix(new DeletePropertyIntentionAction()));
}
}
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:22,代码来源:PropertyNotInModelAnnotator.java
示例4: annotate
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@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 Model model = KubernetesYamlPsiUtil.modelForKey(modelProvider, resourceKey, keyValue);
if (model != null && keyValue.getKey() != null) {
if (keyValue.getValue() instanceof YAMLMapping) {
final YAMLMapping mapping = (YAMLMapping) keyValue.getValue();
addErrors(annotationHolder, model, keyValue.getKey(), mapping);
} else if (keyValue.getValue() instanceof YAMLSequence) {
final YAMLSequence sequence = (YAMLSequence) keyValue.getValue();
for (final YAMLSequenceItem item : sequence.getItems()) {
if (item.getValue() instanceof YAMLMapping) {
addErrors(annotationHolder, model, item.getFirstChild(), (YAMLMapping) item.getValue());
}
}
}
}
}
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:26,代码来源:MissingRequiredPropertiesAnnotator.java
示例5: annotate
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@Override
public void annotate(@NotNull final PsiElement element, @NotNull final AnnotationHolder annotationHolder) {
if (!KubernetesYamlPsiUtil.isKubernetesFile(element)) {
return;
}
if (element instanceof YAMLMapping) {
final YAMLMapping mapping = (YAMLMapping) element;
final Collection<YAMLKeyValue> keyValues = mapping.getKeyValues();
final Set<String> existingKeys = new HashSet<>(keyValues.size());
for (final YAMLKeyValue keyValue : keyValues) {
if (keyValue.getKey() != null && !existingKeys.add(keyValue.getKeyText().trim())) {
annotationHolder.createErrorAnnotation(keyValue.getKey(), "Duplicated property '" + keyValue.getKeyText() + "'").registerFix(new DeletePropertyIntentionAction());
}
}
}
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:17,代码来源:DuplicateKeyAnnotator.java
示例6: getCompoundKeys0
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
void getCompoundKeys0(YAMLKeyValue keyValue, String compKey, List<String> keysList, ConcurrentHashMap<String, Collection<YAMLKeyValue>> dataMap, String lang) {
if (!(keyValue.getValue() instanceof YAMLMapping)) {
keysList.add(compKey);
dataMap.get(lang).add(keyValue);
} else {
Collection<YAMLKeyValue> collection = ((YAMLBlockMappingImpl) keyValue.getValue()).getKeyValues();
for (YAMLKeyValue each : collection) {
getCompoundKeys0(each, compKey + "." + each.getKeyText(), keysList, dataMap, lang);
}
}
}
开发者ID:PioBeat,项目名称:GravSupport,代码行数:13,代码来源:FileEditorStrategy.java
示例7: collectSlowLineMarkers
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@Override
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
for (PsiElement el : elements) {
if (!NeosProjectComponent.isEnabled(el)) {
return;
}
if (!el.getContainingFile().getVirtualFile().getName().startsWith("NodeTypes.")) {
continue;
}
if (!(el instanceof YAMLKeyValue)) {
continue;
}
YAMLMapping parentMapping = ((YAMLKeyValue) el).getParentMapping();
if (parentMapping != null && parentMapping.getParent() instanceof YAMLDocument) {
String nodeType = ((YAMLKeyValue) el).getKeyText();
String[] nodeTypeSplit = nodeType.split(":");
if (nodeTypeSplit.length < 2) {
continue;
}
List<PsiElement> targets = ResolveEngine.getPrototypeDefinitions(el.getProject(), nodeTypeSplit[1], nodeTypeSplit[0]);
if (!targets.isEmpty()) {
RelatedItemLineMarkerInfo info = NavigationGutterIconBuilder
.create(FusionIcons.PROTOTYPE)
.setTargets(targets)
.setTooltipText("Go to Fusion prototype")
.createLineMarkerInfo(el);
result.add(info);
}
}
}
}
开发者ID:cvette,项目名称:intellij-neos,代码行数:37,代码来源:PrototypeLineMarkerProvider.java
示例8: getNextObjectParent
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
private PsiElement getNextObjectParent(final PsiElement psiElement) {
if (psiElement == null) {
return null;
}
if (psiElement instanceof JsonObject ||
(psiElement instanceof YAMLKeyValue || psiElement instanceof YAMLMapping) &&
!(psiElement instanceof JsonStringLiteral)) {
return psiElement;
}
return getNextObjectParent(psiElement.getParent());
}
开发者ID:zalando,项目名称:intellij-swagger,代码行数:14,代码来源:PathFinder.java
示例9: addErrors
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
private void addErrors(final @NotNull AnnotationHolder annotationHolder, final Model model, final PsiElement errorTarget, final YAMLMapping mapping) {
final Set<String> existingKeys = mapping.getKeyValues().stream().map(YAMLKeyValue::getKeyText).collect(Collectors.toSet());
// Find out the keys that are needed, and remove any which have been defined
// The resulting set are the properties required but not added
final Set<String> requiredProperties = new HashSet<>(model.getRequiredProperties());
requiredProperties.removeAll(existingKeys);
if (!requiredProperties.isEmpty()) {
annotationHolder.createWarningAnnotation(errorTarget, "Missing required properties on " + model.getId() + ": " + String.join(", ", requiredProperties))
.registerFix(new CreateMissingPropertiesIntentionAction(requiredProperties, mapping));
}
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:14,代码来源:MissingRequiredPropertiesAnnotator.java
示例10: annotate
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@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;
}
}
}
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:28,代码来源:DataTypeCheckerAnnotator.java
示例11: findResourceKey
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
/**
* Find the {@link ResourceTypeKey} for the current document.
*
* @param element an element within the document to check.
* @return the resource type key, or {@code null} if the "apiVersion" and "kind" fields are not present.
*/
@Nullable
public static ResourceTypeKey findResourceKey(final PsiElement element) {
// Get the top-level mapping
final YAMLMapping topLevelMapping = getTopLevelMapping(element);
final String apiVersion = getValueText(topLevelMapping, "apiVersion");
final String kind = getValueText(topLevelMapping, "kind");
if (apiVersion != null && kind != null) {
return new ResourceTypeKey(apiVersion, kind);
} else {
return null;
}
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:19,代码来源:KubernetesYamlPsiUtil.java
示例12: getTopLevelMapping
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
/**
* 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;
}
开发者ID:tinselspoon,项目名称:intellij-kubernetes,代码行数:18,代码来源:KubernetesYamlPsiUtil.java
示例13: findGUIDFromFile
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
public static String findGUIDFromFile(@NotNull 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;
}
开发者ID:consulo,项目名称:consulo-unity3d,代码行数:16,代码来源:Unity3dMetaIndexExtension.java
示例14: findClassForElement
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@Nullable
@Override
public String findClassForElement(@NotNull PsiElement psiElement) {
YAMLMapping parentOfType = PsiTreeUtil.getParentOfType(psiElement, YAMLMapping.class);
if(parentOfType == null) {
return null;
}
return YamlHelper.getYamlKeyValueAsString(parentOfType, "class");
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:11,代码来源:YamlGotoCompletionRegistrar.java
示例15: findIdForElement
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
@Nullable
@Override
public String findIdForElement(@NotNull PsiElement psiElement) {
YAMLMapping parentOfType = PsiTreeUtil.getParentOfType(psiElement, YAMLMapping.class);
if(parentOfType == null) {
return null;
}
return YamlHelper.getYamlKeyValueAsString(parentOfType, "id");
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:11,代码来源:YamlGotoCompletionRegistrar.java
示例16: visitRoot
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
protected void visitRoot(PsiFile psiFile, String rootName, @NotNull ProblemsHolder holder) {
if(!(psiFile instanceof YAMLFile)) {
return;
}
YAMLKeyValue yamlKeyValue = YAMLUtil.getQualifiedKeyInFile((YAMLFile) psiFile, rootName);
if(yamlKeyValue == null) {
return;
}
YAMLCompoundValue yaml = PsiTreeUtil.findChildOfType(yamlKeyValue, YAMLMapping.class);
if(yaml != null) {
YamlHelper.attachDuplicateKeyInspection(yaml, holder);
}
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:16,代码来源:YamlDuplicateServiceKeyInspection.java
示例17: getGlobalServiceStringPattern
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
/**
* foo: b<caret>ar
* foo: [ b<caret>ar ]
* foo: { b<caret>ar }
* foo:
* - b<caret>ar
*/
private PsiElementPattern.Capture<PsiElement> getGlobalServiceStringPattern() {
return PlatformPatterns.psiElement().withParent(
PlatformPatterns.psiElement(YAMLScalar.class).withParent(PlatformPatterns.or(
PlatformPatterns.psiElement(YAMLKeyValue.class),
PlatformPatterns.psiElement(YAMLSequenceItem.class),
PlatformPatterns.psiElement(YAMLMapping.class)
)));
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:16,代码来源:YamlGoToDeclarationHandler.java
示例18: isValidService
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
private boolean isValidService(ServiceActionUtil.ServiceYamlContainer serviceYamlContainer) {
YAMLKeyValue serviceKey = serviceYamlContainer.getServiceKey();
Set<String> keySet = YamlHelper.getKeySet(serviceKey);
if(keySet == null) {
return true;
}
for(String s: INVALID_KEYS) {
if(keySet.contains(s)) {
return false;
}
}
// check autowire scope
Boolean serviceAutowire = YamlHelper.getYamlKeyValueAsBoolean(serviceKey, "autowire");
if(serviceAutowire != null) {
// use service scope for autowire
if(serviceAutowire) {
return false;
}
} else {
// find file scope defaults
// defaults: [autowire: true]
YAMLMapping key = serviceKey.getParentMapping();
if(key != null) {
YAMLKeyValue defaults = YamlHelper.getYamlKeyValue(key, "_defaults");
if(defaults != null) {
Boolean autowire = YamlHelper.getYamlKeyValueAsBoolean(defaults, "autowire");
if(autowire != null && autowire) {
return false;
}
}
}
}
return true;
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:39,代码来源:YamlServiceArgumentInspection.java
示例19: testYmlTagAttributeExtraction
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
public void testYmlTagAttributeExtraction() {
YAMLHashImpl fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLHashImpl.class, "{ name: routing.loader, method: foo }");
YamlServiceTag tag = new YamlServiceTag("foo", "routing.loader", (YAMLMapping) fromText);
assertEquals("foo", tag.getAttribute("method"));
assertEquals("routing.loader", tag.getAttribute("name"));
}
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:8,代码来源:YamlServiceTagTest.java
示例20: isKey
import org.jetbrains.yaml.psi.YAMLMapping; //导入依赖的package包/类
private boolean isKey(PsiElement position) {
PsiElement parentContext = position.getParent().getContext();
PsiElement leftContext = Optional.ofNullable(position.getContext()).map(PsiElement::getPrevSibling).orElse(null);
return parentContext instanceof YAMLMapping || parentContext instanceof YAMLDocument || leftContext != null && ((LeafPsiElement) leftContext).getElementType() == YAMLTokenTypes.INDENT;
}
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:6,代码来源:CoffigCompletionContributor.java
注:本文中的org.jetbrains.yaml.psi.YAMLMapping类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论