本文整理汇总了Java中org.jetbrains.yaml.psi.YAMLKeyValue.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java YAMLKeyValue.getKey方法的具体用法?Java YAMLKeyValue.getKey怎么用?Java YAMLKeyValue.getKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.yaml.psi.YAMLKeyValue
的用法示例。
在下文中一共展示了YAMLKeyValue.getKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: annotate
import org.jetbrains.yaml.psi.YAMLKeyValue; //导入方法依赖的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());
}
}
}
}
}
}
示例2: annotate
import org.jetbrains.yaml.psi.YAMLKeyValue; //导入方法依赖的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());
}
}
}
}
示例3: apply
import org.jetbrains.yaml.psi.YAMLKeyValue; //导入方法依赖的package包/类
@Override
public void apply(@NotNull PsiFile file, List<RuntimeException> annotationResult, @NotNull AnnotationHolder holder) {
if (file instanceof YAMLFile) {
YAMLFile yamlFile = (YAMLFile) file;
if (!yamlFile.getDocuments().isEmpty()) {
YAMLDocument yamlDocument = yamlFile.getDocuments().get(0);
PsiElement found = findChildRecursively(yamlDocument, new String[]{"flow", "operation", "decision"});
if (found instanceof YAMLKeyValue) {
YAMLKeyValue keyValue = (YAMLKeyValue) found;
found = keyValue.getKey();
} else {
found = yamlDocument;
}
createErrorAnnotations(found, yamlFile, holder, annotationResult);
createWarningsForMissingElementsInDescription(yamlDocument, yamlFile, holder);
}
if (!annotationResult.isEmpty()) {
HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
.descriptionAndTooltip("Found " + annotationResult.size() + " errors")
.range(file).create();
if (highlightInfo != null) {
Problem problem = new ProblemImpl(file.getVirtualFile(), highlightInfo, true);
WolfTheProblemSolver theProblemSolver = WolfTheProblemSolver.getInstance(file.getProject());
theProblemSolver.reportProblems(file.getVirtualFile(), Collections.singletonList(problem));
}
}
}
}