compilation aborted

This commit is contained in:
Peter Gromov
2007-01-19 18:45:38 +03:00
parent 098e621edc
commit f8649d1e82
3 changed files with 32 additions and 27 deletions
@@ -86,16 +86,17 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
if (path != null) return VfsUtil.findRelativeFile(path,null);
return null;
}
public abstract class ErrorReporter {
public abstract void processError(SAXParseException ex,boolean warning);
public boolean filterValidationException(Exception ex) {
if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex;
if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex;
if (ex instanceof FileNotFoundException ||
ex instanceof MalformedURLException ||
ex instanceof NoRouteToHostException ||
ex instanceof MalformedURLException ||
ex instanceof NoRouteToHostException ||
ex instanceof ConnectException
) {
// do not log problems caused by malformed and/or ignored external resources
@@ -121,7 +122,7 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
private String buildMessageString(SAXParseException ex) {
String msg = "(" + ex.getLineNumber() + ":" + ex.getColumnNumber() + ") " + ex.getMessage();
final VirtualFile file = getFile(ex.getPublicId());
if ( file != null && !file.equals(myFile.getVirtualFile())) {
msg = file.getName() + ":" + msg;
}
@@ -131,6 +132,10 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
public class TestErrorReporter extends ErrorReporter {
private ArrayList<String> errors = new ArrayList<String>(3);
public boolean isStopOnUndeclaredResource() {
return true;
}
public void processError(SAXParseException ex, boolean warning) {
errors.add(buildMessageString(ex));
}
@@ -323,6 +328,8 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
myErrorReporter.startProcessing();
}
catch (XmlResourceResolver.IgnoredResourceException e) {
}
catch (Exception exception) {
filterAppException(exception);
}
@@ -373,14 +380,14 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
});
final String[] resourcePaths = myXmlResourceResolver.getResourcePaths();
if (resourcePaths.length > 0) { // if caches are used
final VirtualFile[] files = new VirtualFile[resourcePaths.length];
for(int i = 0; i < resourcePaths.length; ++i) {
files[i] = VfsUtil.findRelativeFile(resourcePaths[i], null);
}
myFile.putUserData(DEPENDENT_FILES_KEY, files);
myFile.putUserData(GRAMMAR_POOL_TIME_STAMP_KEY, new Long(calculateTimeStamp(files,myProject)));
}
@@ -413,7 +420,7 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
if (hasDtdDeclaration()) {
factory.setValidating(true);
}
if (needsSchemaChecking()) {
factory.setValidating(true);
factory.setNamespaceAware(true);
@@ -423,7 +430,7 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
} catch(NoSuchMethodError e) {}
schemaChecking = true;
}
SAXParser parser = factory.newSAXParser();
parser.setProperty(ENTITY_RESOLVER_PROPERTY_NAME, myXmlResourceResolver);
@@ -488,7 +495,7 @@ public class ValidateXmlActionHandler implements CodeInsightActionHandler {
return false;
}
}
return true;
}
@@ -1,6 +1,7 @@
package com.intellij.xml.impl;
import com.intellij.codeInsight.daemon.Validator;
import com.intellij.lang.Language;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -16,8 +17,8 @@ import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.reference.SoftReference;
import com.intellij.xml.actions.ValidateXmlActionHandler;
import com.intellij.xml.util.XmlResourceResolver;
import com.intellij.xml.util.XmlUtil;
import com.intellij.lang.Language;
import org.jetbrains.annotations.NonNls;
import org.xml.sax.SAXParseException;
@@ -26,7 +27,11 @@ import java.util.LinkedList;
import java.util.List;
/**
* @author maxim
* Created by IntelliJ IDEA.
* User: maxim
* Date: 21.01.2005
* Time: 0:07:51
* To change this template use File | Settings | File Templates.
*/
public class ExternalDocumentValidator {
private static final Logger LOG = Logger.getInstance("#com.intellij.xml.impl.ExternalDocumentValidator");
@@ -98,16 +103,6 @@ public class ExternalDocumentValidator {
return true;
}
public boolean filterValidationException(Exception ex) {
if (ex instanceof ProcessCanceledException &&
ApplicationManager.getApplication().isUnitTestMode()
) {
return true;
}
return super.filterValidationException(ex);
}
public void processError(final SAXParseException e, final boolean warning) {
try {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@@ -153,7 +148,7 @@ public class ExternalDocumentValidator {
} else if (messageId.startsWith(ATTRIBUTE_MESSAGE_PREFIX)) {
@NonNls String prefix = "of attribute ";
final int i = localizedMessage.indexOf(prefix);
if (i != -1) {
int messagePrefixLength = prefix.length() + i;
final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1);
@@ -221,6 +216,7 @@ public class ExternalDocumentValidator {
}
catch (Exception ex) {
if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex;
if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex;
LOG.error(ex);
}
}
@@ -3,7 +3,6 @@ package com.intellij.xml.util;
import com.intellij.j2ee.openapi.ex.ExternalResourceManagerEx;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
@@ -54,7 +53,7 @@ public class XmlResourceResolver implements XMLEntityResolver {
public String[] getResourcePaths() {
return myExternalResourcesMap.values().toArray(new String[myExternalResourcesMap.size()]);
}
public PsiFile resolve(final String baseSystemId, final String systemId) {
if (LOG.isDebugEnabled()) {
LOG.debug("enter: resolveEntity(baseSystemId='" + baseSystemId + "' systemId='" + systemId + "," + super.toString() + "')");
@@ -63,7 +62,7 @@ public class XmlResourceResolver implements XMLEntityResolver {
if (systemId == null) return null;
if (myStopOnUnDeclaredResource &&
ExternalResourceManagerEx.getInstanceEx().isIgnoredResource(systemId)) {
throw new ProcessCanceledException();
throw new IgnoredResourceException();
}
final PsiFile[] result = new PsiFile[] { null };
final Runnable action = new Runnable() {
@@ -115,7 +114,7 @@ public class XmlResourceResolver implements XMLEntityResolver {
if (psiFile == null && systemId != null && baseSystemId == null) { // entity file
File workingFile = new File("");
String workingDir = workingFile.getAbsoluteFile().getAbsolutePath().replace(File.separatorChar, '/') + "/";
String relativePath = StringUtil.replace(
systemId,
workingDir,
@@ -203,4 +202,7 @@ public class XmlResourceResolver implements XMLEntityResolver {
public void setStopOnUnDeclaredResource(final boolean stopOnUnDeclaredResource) {
myStopOnUnDeclaredResource = stopOnUnDeclaredResource;
}
public static class IgnoredResourceException extends RuntimeException {
}
}