com.intellij.util.xml.highlighting.DomHighlightingHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dom-openapi Show documentation
Show all versions of dom-openapi Show documentation
A packaging of the IntelliJ Community Edition dom-openapi library.
This is release number 1 of trunk branch 142.
The newest version!
/*
* Copyright 2000-2009 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.util.xml.highlighting;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.util.SmartList;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.GenericDomValue;
import org.jetbrains.annotations.NotNull;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.List;
/**
* @author peter
*/
public abstract class DomHighlightingHelper {
private final DomCustomAnnotationChecker[] myCustomCheckers = Extensions.getExtensions(DomCustomAnnotationChecker.EP_NAME);
@NotNull
public abstract List checkRequired(DomElement element, DomElementAnnotationHolder holder);
@NotNull
public abstract List checkResolveProblems(GenericDomValue element, DomElementAnnotationHolder holder);
@NotNull
public abstract List checkNameIdentity(DomElement element, DomElementAnnotationHolder holder);
public abstract void runAnnotators(DomElement element, DomElementAnnotationHolder holder, Class extends DomElement> rootClass);
/**
* Runs all registered {@link DomCustomAnnotationChecker}s.
*
* @param element Dom element to check.
* @param holder Holder instance.
* @return Collected problem descriptors.
*/
@NotNull
public List checkCustomAnnotations(final DomElement element, final DomElementAnnotationHolder holder) {
List result = null;
for (final DomCustomAnnotationChecker> checker : myCustomCheckers) {
final List list = checkAnno(element, checker, holder);
if (!list.isEmpty()) {
if (result == null) result = new SmartList();
result.addAll(list);
}
}
return result == null ? Collections.emptyList() : result;
}
private List checkAnno(final DomElement element, final DomCustomAnnotationChecker checker, DomElementAnnotationHolder holder) {
final T annotation = element.getAnnotation(checker.getAnnotationClass());
return annotation != null ? checker.checkForProblems(annotation, element, holder, this) : Collections.emptyList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy