mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
avoid deprecated methods
This commit is contained in:
@@ -78,7 +78,7 @@ public abstract class WebReferencesAnnotatorBase extends ExternalAnnotator<WebRe
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyInfo[] collectionInformation(@NotNull PsiFile file) {
|
||||
public MyInfo[] collectInformation(@NotNull PsiFile file) {
|
||||
final WebReference[] references = collectWebReferences(file);
|
||||
final MyInfo[] infos = new MyInfo[references.length];
|
||||
|
||||
|
||||
+4
-2
@@ -286,7 +286,8 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip
|
||||
final String contextName = context.getName();
|
||||
if (FxmlConstants.FX_ROOT.equals(contextName)) {
|
||||
if (context.getParentTag() != null) {
|
||||
host.addMessage(context.getNavigationElement(), "<fx:root> is valid only as the root node of an FXML document", ValidationHost.ERROR);
|
||||
host.addMessage(context.getNavigationElement(), "<fx:root> is valid only as the root node of an FXML document",
|
||||
ValidationHost.ErrorType.ERROR);
|
||||
}
|
||||
} else {
|
||||
final XmlTag referencedTag = getReferencedTag(context);
|
||||
@@ -310,7 +311,8 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip
|
||||
}
|
||||
}
|
||||
if (!copyConstructorFound) {
|
||||
host.addMessage(context.getNavigationElement(), "Copy constructor not found for \'" + psiClass.getName() + "\'", ValidationHost.ERROR);
|
||||
host.addMessage(context.getNavigationElement(), "Copy constructor not found for \'" + psiClass.getName() + "\'",
|
||||
ValidationHost.ErrorType.ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-15
@@ -675,15 +675,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
|
||||
|
||||
@Override
|
||||
public void addMessage(PsiElement context, String message, int type) {
|
||||
if (message != null && !message.isEmpty()) {
|
||||
if (context instanceof XmlTag && XmlExtension.getExtension(context.getContainingFile()).shouldBeHighlightedAsTag((XmlTag)context)) {
|
||||
HighlightInfoType infoType = type == ERROR ? HighlightInfoType.ERROR : type == WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;
|
||||
addElementsForTag((XmlTag)context, message, infoType, null);
|
||||
}
|
||||
else {
|
||||
addToResults(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(context).descriptionAndTooltip(message).create());
|
||||
}
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -692,7 +684,7 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, final IntentionAction... fixes) {
|
||||
public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, @NotNull final IntentionAction... fixes) {
|
||||
if (message != null && !message.isEmpty()) {
|
||||
final PsiFile containingFile = context.getContainingFile();
|
||||
final HighlightInfoType defaultInfoType = type == ErrorType.ERROR ? HighlightInfoType.ERROR : type == ErrorType.WARNING ? HighlightInfoType.WARNING : HighlightInfoType.WEAK_WARNING;
|
||||
@@ -713,11 +705,9 @@ public class XmlHighlightVisitor extends XmlElementVisitor implements HighlightV
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(context).descriptionAndTooltip(message).create();
|
||||
}
|
||||
|
||||
if (fixes != null) {
|
||||
for (final IntentionAction quickFixAction : fixes) {
|
||||
if (quickFixAction == null) continue;
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, quickFixAction);
|
||||
}
|
||||
for (final IntentionAction quickFixAction : fixes) {
|
||||
if (quickFixAction == null) continue;
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, quickFixAction);
|
||||
}
|
||||
addToResults(highlightInfo);
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package com.intellij.lang.xml;
|
||||
|
||||
import com.intellij.codeInsight.daemon.IdeValidationHost;
|
||||
import com.intellij.codeInsight.daemon.Validator;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.ExternalAnnotator;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.xml.XmlDocument;
|
||||
@@ -30,87 +30,114 @@ import com.intellij.psi.xml.XmlToken;
|
||||
import com.intellij.xml.XmlNSDescriptor;
|
||||
import com.intellij.xml.util.XmlTagUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ven
|
||||
*/
|
||||
public class XMLExternalAnnotator extends ExternalAnnotator {
|
||||
|
||||
public void annotate(PsiFile file, AnnotationHolder holder) {
|
||||
if (!(file instanceof XmlFile)) return;
|
||||
public class XMLExternalAnnotator extends ExternalAnnotator<XMLExternalAnnotator.MyHost, XMLExternalAnnotator.MyHost> {
|
||||
@Nullable
|
||||
@Override
|
||||
public MyHost collectInformation(@NotNull PsiFile file) {
|
||||
if (!(file instanceof XmlFile)) return null;
|
||||
final XmlDocument document = ((XmlFile)file).getDocument();
|
||||
if (document == null) return;
|
||||
if (document == null) return null;
|
||||
XmlTag rootTag = document.getRootTag();
|
||||
XmlNSDescriptor nsDescriptor = rootTag == null ? null : rootTag.getNSDescriptor(rootTag.getNamespace(), false);
|
||||
|
||||
if (nsDescriptor instanceof Validator) {
|
||||
//noinspection unchecked
|
||||
((Validator<XmlDocument>)nsDescriptor).validate(document, new MyHost(holder));
|
||||
//noinspection unchecked
|
||||
MyHost host = new MyHost();
|
||||
((Validator<XmlDocument>)nsDescriptor).validate(document, host);
|
||||
return host;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Validator.ValidationHost.ErrorType[] types = Validator.ValidationHost.ErrorType.values();
|
||||
@Nullable
|
||||
@Override
|
||||
public MyHost doAnnotate(MyHost collectedInfo) {
|
||||
return collectedInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(@NotNull PsiFile file, MyHost annotationResult, @NotNull AnnotationHolder holder) {
|
||||
annotationResult.apply(holder);
|
||||
}
|
||||
|
||||
private static void appendFixes(final Annotation annotation, final IntentionAction... actions) {
|
||||
if (actions != null) {
|
||||
for(IntentionAction action:actions) annotation.registerFix(action);
|
||||
for (IntentionAction action : actions) annotation.registerFix(action);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyHost implements IdeValidationHost {
|
||||
|
||||
private final AnnotationHolder myHolder;
|
||||
|
||||
public MyHost(AnnotationHolder holder) {
|
||||
|
||||
myHolder = holder;
|
||||
}
|
||||
static class MyHost implements Validator.ValidationHost {
|
||||
private final List<Trinity<PsiElement, String, ErrorType>> messages = new ArrayList<Trinity<PsiElement, String, ErrorType>>();
|
||||
|
||||
@Override
|
||||
public void addMessage(PsiElement context, String message, int type) {
|
||||
addMessage(context, message, types[type]);
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(PsiElement context, String message, @NotNull ErrorType type) {
|
||||
addMessageWithFixes(context, message, type);
|
||||
messages.add(Trinity.create(context, message, type));
|
||||
}
|
||||
|
||||
public void addMessageWithFixes(final PsiElement context, final String message, @NotNull final ErrorType type, final IntentionAction... fixes) {
|
||||
if (message != null && message.length() > 0) {
|
||||
if (context instanceof XmlTag) {
|
||||
addMessagesForTag((XmlTag)context, message, type, fixes);
|
||||
}
|
||||
else {
|
||||
if (type == Validator.ValidationHost.ErrorType.ERROR) {
|
||||
appendFixes(myHolder.createErrorAnnotation(context, message), fixes);
|
||||
} else {
|
||||
appendFixes(myHolder.createWarningAnnotation(context, message), fixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addMessagesForTag(XmlTag tag, String message, ErrorType type, IntentionAction... actions) {
|
||||
XmlToken childByRole = XmlTagUtil.getStartTagNameElement(tag);
|
||||
|
||||
addMessagesForTreeChild(childByRole, type, message, actions);
|
||||
|
||||
childByRole = XmlTagUtil.getEndTagNameElement(tag);
|
||||
addMessagesForTreeChild(childByRole, type, message, actions);
|
||||
}
|
||||
|
||||
private void addMessagesForTreeChild(final XmlToken childByRole, final ErrorType type, final String message, IntentionAction... actions) {
|
||||
if (childByRole != null) {
|
||||
Annotation annotation;
|
||||
if (type == ErrorType.ERROR) {
|
||||
annotation = myHolder.createErrorAnnotation(childByRole, message);
|
||||
}
|
||||
else {
|
||||
annotation = myHolder.createWarningAnnotation(childByRole, message);
|
||||
}
|
||||
|
||||
appendFixes(annotation, actions);
|
||||
void apply (AnnotationHolder holder) {
|
||||
for (Trinity<PsiElement, String, ErrorType> message : messages) {
|
||||
addMessageWithFixes(message.first, message.second, message.third, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void addMessageWithFixes(final PsiElement context,
|
||||
final String message,
|
||||
@NotNull final Validator.ValidationHost.ErrorType type,
|
||||
AnnotationHolder myHolder,
|
||||
@NotNull final IntentionAction... fixes) {
|
||||
if (message != null && !message.isEmpty()) {
|
||||
if (context instanceof XmlTag) {
|
||||
addMessagesForTag((XmlTag)context, message, type, myHolder, fixes);
|
||||
}
|
||||
else {
|
||||
if (type == Validator.ValidationHost.ErrorType.ERROR) {
|
||||
appendFixes(myHolder.createErrorAnnotation(context, message), fixes);
|
||||
}
|
||||
else {
|
||||
appendFixes(myHolder.createWarningAnnotation(context, message), fixes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addMessagesForTag(XmlTag tag, String message, Validator.ValidationHost.ErrorType type, AnnotationHolder myHolder, IntentionAction... actions) {
|
||||
XmlToken childByRole = XmlTagUtil.getStartTagNameElement(tag);
|
||||
|
||||
addMessagesForTreeChild(childByRole, type, message, myHolder, actions);
|
||||
|
||||
childByRole = XmlTagUtil.getEndTagNameElement(tag);
|
||||
addMessagesForTreeChild(childByRole, type, message, myHolder, actions);
|
||||
}
|
||||
|
||||
private static void addMessagesForTreeChild(final XmlToken childByRole,
|
||||
final Validator.ValidationHost.ErrorType type,
|
||||
final String message,
|
||||
AnnotationHolder myHolder, IntentionAction... actions) {
|
||||
if (childByRole != null) {
|
||||
Annotation annotation;
|
||||
if (type == Validator.ValidationHost.ErrorType.ERROR) {
|
||||
annotation = myHolder.createErrorAnnotation(childByRole, message);
|
||||
}
|
||||
else {
|
||||
annotation = myHolder.createWarningAnnotation(childByRole, message);
|
||||
}
|
||||
|
||||
appendFixes(annotation, actions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.StdFileTypes;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
@@ -37,57 +38,110 @@ import org.intellij.plugins.relaxNG.compact.RncFileType;
|
||||
import org.intellij.plugins.relaxNG.compact.psi.RncFile;
|
||||
import org.intellij.plugins.relaxNG.model.resolve.RelaxIncludeIndex;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: sweinreuter
|
||||
* Date: 18.07.2007
|
||||
*/
|
||||
public class RngSchemaValidator extends ExternalAnnotator {
|
||||
public class RngSchemaValidator extends ExternalAnnotator<RngSchemaValidator.MyValidationMessageConsumer,RngSchemaValidator.MyValidationMessageConsumer> {
|
||||
private static final Logger LOG = Logger.getInstance(RngSchemaValidator.class.getName());
|
||||
|
||||
public void annotate(final PsiFile file, final AnnotationHolder holder) {
|
||||
@Nullable
|
||||
@Override
|
||||
public MyValidationMessageConsumer collectInformation(@NotNull final PsiFile file) {
|
||||
final FileType type = file.getFileType();
|
||||
if (type != StdFileTypes.XML && type != RncFileType.getInstance()) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
final XmlFile xmlfile = (XmlFile)file;
|
||||
final XmlDocument document = xmlfile.getDocument();
|
||||
if (document == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (type == StdFileTypes.XML) {
|
||||
final XmlTag rootTag = document.getRootTag();
|
||||
if (rootTag == null) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
if (!ApplicationLoader.RNG_NAMESPACE.equals(rootTag.getNamespace())) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode() && MyErrorFinder.hasError(xmlfile)) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
final Document doc = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
|
||||
|
||||
final MyValidationMessageConsumer consumer = new MyValidationMessageConsumer();
|
||||
ErrorHandler eh = new DefaultHandler() {
|
||||
public void warning(SAXParseException e) throws SAXException {
|
||||
handleError(e, file, doc, new WarningMessageConsumer(holder));
|
||||
@Override
|
||||
public void warning(SAXParseException e) {
|
||||
handleError(e, file, doc, consumer.warning());
|
||||
}
|
||||
|
||||
public void error(SAXParseException e) throws SAXException {
|
||||
handleError(e, file, doc, new ErrorMessageConsumer(holder));
|
||||
@Override
|
||||
public void error(SAXParseException e) {
|
||||
handleError(e, file, doc, consumer.error());
|
||||
}
|
||||
};
|
||||
|
||||
RngParser.parsePattern(file, eh, true);
|
||||
return consumer;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MyValidationMessageConsumer doAnnotate(MyValidationMessageConsumer collectedInfo) {
|
||||
return collectedInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(@NotNull PsiFile file,
|
||||
MyValidationMessageConsumer annotationResult,
|
||||
@NotNull AnnotationHolder holder) {
|
||||
annotationResult.apply(holder);
|
||||
}
|
||||
|
||||
static class MyValidationMessageConsumer {
|
||||
List<Pair<PsiElement, String >> errors = new ArrayList<Pair<PsiElement, String>>();
|
||||
List<Pair<PsiElement, String >> warnings = new ArrayList<Pair<PsiElement, String>>();
|
||||
ValidationMessageConsumer error() {
|
||||
return new ValidationMessageConsumer() {
|
||||
@Override
|
||||
public void onMessage(PsiElement context, String message) {
|
||||
errors.add(Pair.create(context, message));
|
||||
}
|
||||
};
|
||||
}
|
||||
ValidationMessageConsumer warning() {
|
||||
return new ValidationMessageConsumer() {
|
||||
@Override
|
||||
public void onMessage(PsiElement context, String message) {
|
||||
warnings.add(Pair.create(context, message));
|
||||
}
|
||||
};
|
||||
}
|
||||
void apply(AnnotationHolder holder) {
|
||||
MessageConsumerImpl errorc = new ErrorMessageConsumer(holder);
|
||||
MessageConsumerImpl warningc = new WarningMessageConsumer(holder);
|
||||
for (Pair<PsiElement, String> error : errors) {
|
||||
errorc.onMessage(error.first, error.second);
|
||||
}
|
||||
for (Pair<PsiElement, String> warning : warnings) {
|
||||
warningc.onMessage(warning.first, warning.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleError(SAXParseException ex, PsiFile file, Document document, ValidationMessageConsumer consumer) {
|
||||
@@ -158,13 +212,14 @@ public class RngSchemaValidator extends ExternalAnnotator {
|
||||
void onMessage(PsiElement context, String message);
|
||||
}
|
||||
|
||||
private static abstract class MessageConsumerImpl implements ValidationMessageConsumer {
|
||||
private abstract static class MessageConsumerImpl implements ValidationMessageConsumer {
|
||||
protected final AnnotationHolder myHolder;
|
||||
|
||||
public MessageConsumerImpl(AnnotationHolder holder) {
|
||||
myHolder = holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(PsiElement host, String message) {
|
||||
final ASTNode node = host.getNode();
|
||||
assert node != null;
|
||||
@@ -199,6 +254,7 @@ public class RngSchemaValidator extends ExternalAnnotator {
|
||||
super(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createAnnotation(ASTNode node, String message) {
|
||||
if (MISSING_START_ELEMENT.equals(message)) {
|
||||
final PsiFile psiFile = node.getPsi().getContainingFile();
|
||||
@@ -225,6 +281,7 @@ public class RngSchemaValidator extends ExternalAnnotator {
|
||||
super(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createAnnotation(ASTNode node, String message) {
|
||||
myHolder.createWarningAnnotation(node, message);
|
||||
}
|
||||
@@ -237,6 +294,7 @@ public class RngSchemaValidator extends ExternalAnnotator {
|
||||
}
|
||||
private static final HasError FOUND = new HasError();
|
||||
|
||||
@Override
|
||||
public void visitErrorElement(PsiErrorElement element) {
|
||||
throw FOUND;
|
||||
}
|
||||
@@ -250,4 +308,5 @@ public class RngSchemaValidator extends ExternalAnnotator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -86,26 +86,32 @@ public class XmlInstanceValidator {
|
||||
myDocument = PsiDocumentManager.getInstance(myFile.getProject()).getDocument(myFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(SAXParseException exception) throws SAXException {
|
||||
RngSchemaValidator.handleError(exception, myFile, myDocument, new RngSchemaValidator.ValidationMessageConsumer() {
|
||||
@Override
|
||||
public void onMessage(PsiElement context, String message) {
|
||||
myHost.addMessage(context, message, Validator.ValidationHost.WARNING);
|
||||
myHost.addMessage(context, message, Validator.ValidationHost.ErrorType.WARNING);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(SAXParseException exception) throws SAXException {
|
||||
RngSchemaValidator.handleError(exception, myFile, myDocument, new RngSchemaValidator.ValidationMessageConsumer() {
|
||||
@Override
|
||||
public void onMessage(PsiElement context, String message) {
|
||||
myHost.addMessage(context, message, Validator.ValidationHost.ERROR);
|
||||
myHost.addMessage(context, message, Validator.ValidationHost.ErrorType.ERROR);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatalError(SAXParseException exception) throws SAXException {
|
||||
RngSchemaValidator.handleError(exception, myFile, myDocument, new RngSchemaValidator.ValidationMessageConsumer() {
|
||||
@Override
|
||||
public void onMessage(PsiElement context, String message) {
|
||||
myHost.addMessage(context, message, Validator.ValidationHost.ERROR);
|
||||
myHost.addMessage(context, message, Validator.ValidationHost.ErrorType.ERROR);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -84,9 +84,15 @@ public class ExternalDocumentValidator {
|
||||
private static final String ATTRIBUTE_MESSAGE_PREFIX = "cvc-attribute.";
|
||||
|
||||
private static class ValidationInfo {
|
||||
PsiElement element;
|
||||
String message;
|
||||
int type;
|
||||
final PsiElement element;
|
||||
final String message;
|
||||
final Validator.ValidationHost.ErrorType type;
|
||||
|
||||
private ValidationInfo(PsiElement element, String message, Validator.ValidationHost.ErrorType type) {
|
||||
this.element = element;
|
||||
this.message = message;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
private WeakReference<List<ValidationInfo>> myInfos; // last jaxp validation result
|
||||
@@ -115,17 +121,13 @@ public class ExternalDocumentValidator {
|
||||
myHost = new Validator.ValidationHost() {
|
||||
@Override
|
||||
public void addMessage(PsiElement context, String message, int type) {
|
||||
final ValidationInfo o = new ValidationInfo();
|
||||
|
||||
results.add(o);
|
||||
o.element = context;
|
||||
o.message = message;
|
||||
o.type = type;
|
||||
addMessage(context, message, type==ERROR?ErrorType.ERROR : type==WARNING?ErrorType.WARNING : ErrorType.INFO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessage(final PsiElement context, final String message, @NotNull final ErrorType type) {
|
||||
addMessage(context, message, type.ordinal());
|
||||
final ValidationInfo o = new ValidationInfo(context, message, type);
|
||||
results.add(o);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -154,7 +156,7 @@ public class ExternalDocumentValidator {
|
||||
return;
|
||||
}
|
||||
|
||||
int problemType = getProblemType(warning);
|
||||
Validator.ValidationHost.ErrorType problemType = getProblemType(warning);
|
||||
int offset = Math.max(0, document.getLineStartOffset(e.getLineNumber() - 1) + e.getColumnNumber() - 2);
|
||||
if (offset >= document.getTextLength()) return;
|
||||
PsiElement currentElement = PsiDocumentManager.getInstance(project).getPsiFile(document).findElementAt(offset);
|
||||
@@ -245,7 +247,7 @@ public class ExternalDocumentValidator {
|
||||
}
|
||||
} else if (localizedMessage.startsWith(STRING_ERROR_PREFIX)) {
|
||||
if (currentElement != null) {
|
||||
myHost.addMessage(currentElement,localizedMessage,Validator.ValidationHost.WARNING);
|
||||
myHost.addMessage(currentElement,localizedMessage, Validator.ValidationHost.ErrorType.WARNING);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -277,8 +279,8 @@ public class ExternalDocumentValidator {
|
||||
addAllInfos(host,results);
|
||||
}
|
||||
|
||||
private int getProblemType(ValidateXmlActionHandler.ProblemType warning) {
|
||||
return warning == ValidateXmlActionHandler.ProblemType.WARNING ? Validator.ValidationHost.WARNING : Validator.ValidationHost.ERROR;
|
||||
private static Validator.ValidationHost.ErrorType getProblemType(ValidateXmlActionHandler.ProblemType warning) {
|
||||
return warning == ValidateXmlActionHandler.ProblemType.WARNING ? Validator.ValidationHost.ErrorType.WARNING : Validator.ValidationHost.ErrorType.ERROR;
|
||||
}
|
||||
|
||||
private static PsiElement getNodeForMessage(final PsiElement currentElement) {
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl {
|
||||
host.addMessage(
|
||||
attr.getNameElement(),
|
||||
XmlErrorMessages.message("xml.schema.validation.attr.not.allowed.with.ref", name),
|
||||
ValidationHost.ERROR
|
||||
ValidationHost.ErrorType.ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl {
|
||||
host.addMessage(
|
||||
tag.getAttribute(MAX_OCCURS_ATTR_VALUE, null).getValueElement(),
|
||||
XmlErrorMessages.message("xml.schema.validation.max.occurs.should.be.not.less.than.min.occurs"),
|
||||
Validator.ValidationHost.ERROR
|
||||
ValidationHost.ErrorType.ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl {
|
||||
host.addMessage(
|
||||
tag,
|
||||
XmlErrorMessages.message("xml.schema.validation.name.or.ref.should.present"),
|
||||
Validator.ValidationHost.ERROR
|
||||
ValidationHost.ErrorType.ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl {
|
||||
host.addMessage(
|
||||
tag,
|
||||
XmlErrorMessages.message("xml.schema.validation.name.or.ref.should.present"),
|
||||
Validator.ValidationHost.ERROR
|
||||
ValidationHost.ErrorType.ERROR
|
||||
);
|
||||
}
|
||||
|
||||
@@ -110,13 +110,13 @@ public class SchemaNSDescriptor extends XmlNSDescriptorImpl {
|
||||
host.addMessage(
|
||||
tag.getAttribute(DEFAULT_ATTR_NAME, null).getNameElement(),
|
||||
XmlErrorMessages.message("xml.schema.validation.default.or.fixed.should.be.specified.but.not.both"),
|
||||
Validator.ValidationHost.ERROR
|
||||
ValidationHost.ErrorType.ERROR
|
||||
);
|
||||
|
||||
host.addMessage(
|
||||
tag.getAttribute(FIXED_ATTR_NAME, null).getNameElement(),
|
||||
XmlErrorMessages.message("xml.schema.validation.default.or.fixed.should.be.specified.but.not.both"),
|
||||
Validator.ValidationHost.ERROR
|
||||
ValidationHost.ErrorType.ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -467,10 +467,10 @@ public class XmlUtil {
|
||||
if (psiElement != null) {
|
||||
presentNames.put(nameKey, null);
|
||||
|
||||
host.addMessage(provider.getNodeForMessage(psiElement), message, Validator.ValidationHost.ERROR);
|
||||
host.addMessage(provider.getNodeForMessage(psiElement), message, Validator.ValidationHost.ErrorType.ERROR);
|
||||
}
|
||||
|
||||
host.addMessage(provider.getNodeForMessage(t), message, Validator.ValidationHost.ERROR);
|
||||
host.addMessage(provider.getNodeForMessage(t), message, Validator.ValidationHost.ErrorType.ERROR);
|
||||
}
|
||||
else {
|
||||
presentNames.put(nameKey, t);
|
||||
|
||||
Reference in New Issue
Block a user