Author: bbrodt
Date: 2010-10-05 15:58:27 -0400 (Tue, 05 Oct 2010)
New Revision: 25501
Added:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/messages.properties
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/factory/AdapterFactory.java
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/Definitions.java
Log:
https://jira.jboss.org/browse/JBIDE-7116
Added <import> location checking: missing XSD imports are not reported by WSDL
validator
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java 2010-10-05
18:34:13 UTC (rev 25500)
+++
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java 2010-10-05
19:58:27 UTC (rev 25501)
@@ -107,12 +107,16 @@
bDebug = toBoolean(args.get("debug"),false);
}
+
AdapterFactory.DEBUG = bDebug;
if (bDebug) {
p("Clear error messages from the cache ... (will re-load)");
Messages.clear();
- }
-
+ }
+
+ //
https://jira.jboss.org/browse/JBIDE-7116
+ clearCach();
+
IProject myProject = this.getProject();
IResourceDelta resourceDelta = this.getDelta(myProject);
@@ -192,6 +196,14 @@
@SuppressWarnings("unchecked")
public void validate (IResource resource, IProgressMonitor monitor) throws CoreException
{
+ //
https://jira.jboss.org/browse/JBIDE-7116
+ // enable element location tracking for error reporting
+ // TODO: move this to somewhere more appropriate when fixing JBIDE-6839
+ Map<Object, Object> loadOptions = fResourceSet.getLoadOptions();
+ loadOptions.put("TRACK_LOCATION", Boolean.TRUE);
+ fResourceSet.setLoadOptions(loadOptions);
+
+
switch (resource.getType()) {
case IResource.FOLDER :
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/factory/AdapterFactory.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/factory/AdapterFactory.java 2010-10-05
18:34:13 UTC (rev 25500)
+++
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/factory/AdapterFactory.java 2010-10-05
19:58:27 UTC (rev 25501)
@@ -142,6 +142,9 @@
// Find the EObject reference to the emf model in the hierarchy of
// the
EObject eObj = (EObject) top.getUserData("emf.model");
+ //
https://jira.jboss.org/browse/JBIDE-7116
+ if (eObj==null)
+ eObj = (EObject) elm.getUserData("emf.model");
result = adapt_EObject2IResource(eObj);
}
@@ -175,32 +178,43 @@
//message && fix
String msg = problem.getAttribute(IProblem.MESSAGE);
String rule = problem.getAttribute(IProblem.RULE);
-
- props.put("bpel.validation.rule", rule);
+
+ //
https://jira.jboss.org/browse/JBIDE-7116
+ // fix ugliness in DEBUG mode (see "org.eclipse.bpel.validator.builder"
buildCommand in .project)
+ if (rule!=null)
+ props.put("bpel.validation.rule", rule);
if (DEBUG) {
+ String emsg = msg;
Throwable t = problem.getAttribute(IProblem.EXCEPTION);
- String emsg = msg;
- emsg += " (rule=";
- emsg += rule;
+ if (rule!=null || t!=null) {
+
+ emsg += "(DEBUG: ";
+ if (rule!=null) {
+ emsg += "rule=";
+ emsg += rule;
+ }
- if (t != null) {
- emsg += "; stack=";
-
- int count = 0;
- for(StackTraceElement e : t.getStackTrace()) {
- emsg += "[" + count + "]";
- emsg += e.getClassName() + ".";
- emsg += e.getMethodName() + "@" + e.getLineNumber();
- count += 1;
- if (count > 2) {
- break;
+ if (t != null) {
+ if (rule!=null)
+ emsg += "; ";
+ emsg += "stack=";
+
+ int count = 0;
+ for(StackTraceElement e : t.getStackTrace()) {
+ emsg += "[" + count + "]";
+ emsg += e.getClassName() + ".";
+ emsg += e.getMethodName() + "@" + e.getLineNumber();
+ count += 1;
+ if (count > 2) {
+ break;
+ }
+ emsg += "/";
}
- emsg += "/";
}
+
+ emsg += ")";
}
-
- emsg += ")";
props.put(IMarker.MESSAGE, emsg);
} else {
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/Definitions.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/Definitions.java 2010-10-05
18:34:13 UTC (rev 25500)
+++
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/Definitions.java 2010-10-05
19:58:27 UTC (rev 25501)
@@ -10,7 +10,33 @@
*******************************************************************************/
package org.eclipse.bpel.validator.wsdl;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.bpel.validator.IBPELMarker;
+import org.eclipse.bpel.validator.ModelQuery;
+import org.eclipse.bpel.validator.model.IModelQuery;
+import org.eclipse.bpel.validator.model.INode;
+import org.eclipse.bpel.validator.model.IProblem;
import org.eclipse.bpel.validator.model.Validator;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdapterManager;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.Import;
+import org.eclipse.wst.wsdl.internal.impl.ImportImpl;
+import org.eclipse.wst.wsdl.util.WSDLParser;
+import org.eclipse.xsd.XSDSchema;
+import org.eclipse.xsd.XSDSchemaContent;
+import org.eclipse.xsd.impl.XSDImportImpl;
+import org.eclipse.xsd.impl.XSDIncludeImpl;
+import org.eclipse.xsd.util.XSDParser;
+import org.w3c.dom.Node;
/**
@@ -23,13 +49,105 @@
public class Definitions extends Validator {
+
+ //
https://jira.jboss.org/browse/JBIDE-7116
+ // Added <import> location checking: missing XSD imports are not reported by WSDL
validator!
+ @Override
+ protected void start() {
+ super.start();
+
+ Definition definition =
(Definition)mModelQuery.adapt(mNode,EObject.class,ModelQuery.ADAPT_HINT_NONE);
+ List<EObject> unresolved = findUnresolvedImports(definition);
+
+ for (EObject obj : unresolved) {
+ String location = "unkonwn";
+ int startLine = 1, startCol = 1;
+ Node node = null;
+ if (obj instanceof Import) {
+ location = ((Import)obj).getLocationURI();
+ node = ((Import)obj).getElement();
+ startLine = WSDLParser.getStartLine(node);
+ startCol = WSDLParser.getStartColumn(node);
+ }
+ else if ( obj instanceof XSDImportImpl ) {
+ location = ((XSDImportImpl)obj).getSchemaLocation();
+ node = ((XSDImportImpl)obj).getElement();
+ startLine = XSDParser.getStartLine(node);
+ startCol = XSDParser.getStartColumn(node);
+ }
+ else if ( obj instanceof XSDIncludeImpl ) {
+ location = ((XSDIncludeImpl)obj).getSchemaLocation();
+ node = ((XSDIncludeImpl)obj).getElement();
+ startLine = XSDParser.getStartLine(node);
+ startCol = XSDParser.getStartColumn(node);
+ }
+ IProblem problem = createWarning(
(INode)mModelQuery.adapt(obj,INode.class,IModelQuery.ADAPT_HINT_NONE) );
+
+ problem.fill("BPELC_IMPORT__UNRESOVED", //$NON-NLS-1$
+ toString(mNode.nodeName()),
+ location,
+ definition.getLocation());
+ problem.setAttribute(IProblem.LINE_NUMBER, startLine);
+ problem.setAttribute(IProblem.COLUMN_NUMBER, startCol);
+ }
+ }
- /** End of public rule methods.
- *
- * Other methods are support methods for this class to perform its
- * validation function.
- *
- */
+
+ @SuppressWarnings({ "restriction", "unchecked",
"rawtypes" })
+ protected List<EObject> findUnresolvedImports(Definition definition) {
+ if (definition == null) {
+ return Collections.emptyList();
+ }
+
+ IAdapterManager adapterManager = Platform.getAdapterManager();
+ IFile file = (IFile)adapterManager.getAdapter(definition, IResource.class);
+ if (file!=null && file.exists())
+ try {
+ file.deleteMarkers(IBPELMarker.ID, false, IResource.DEPTH_INFINITE);
+// System.out.println("deleted markers from "+file);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ ArrayList<EObject> imports = new ArrayList<EObject>();
+ if (definition.getImports() != null) {
+ Iterator defImp = definition.getImports().values().iterator();
+ while (defImp.hasNext()) {
+ List impList = (List) defImp.next();
+ for (int i=0; i<impList.size(); i++) {
+ ImportImpl wsdlImport = (ImportImpl) impList.get(i);
+ wsdlImport.importDefinitionOrSchema();
+ XSDSchema schema = wsdlImport.getESchema();
+ Definition wsdlDefinition = wsdlImport.getEDefinition();
+ if (schema==null && wsdlDefinition==null)
+ imports.add(wsdlImport);
+ // only look at top-level imports to avoid multiple reports of the same
problem
+ imports.addAll(findUnresolvedImports(wsdlDefinition));
+ }
+ }
+ }
+ if (definition.getETypes() != null) {
+ List<XSDSchema> schemas = definition.getETypes().getSchemas();
+ for (XSDSchema si : schemas) {
+ for (XSDSchemaContent sc : si.getContents()) {
+ if (sc instanceof XSDIncludeImpl) {
+ XSDIncludeImpl inc = (XSDIncludeImpl)sc;
+ inc.getIncorporatedSchema();
+ if (inc.getResolvedSchema() == null)
+ imports.add(inc);
+ }
+ if (sc instanceof XSDImportImpl) {
+ XSDImportImpl imp = (XSDImportImpl)sc;
+ imp.importSchema();
+ if (imp.getResolvedSchema() == null)
+ imports.add(imp);
+ }
+ }
+ }
+ }
+ return imports;
+ }
}
Added:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/messages.properties
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/messages.properties
(rev 0)
+++
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/wsdl/messages.properties 2010-10-05
19:58:27 UTC (rev 25501)
@@ -0,0 +1,8 @@
+#
https://jira.jboss.org/browse/JBIDE-7116
+# BPELC_IMPORT__UNRESOVED
+# {0}: node name (import)
+# {1}: import namespace
+# {2}: import location
+BPELC_IMPORT__UNRESOVED.summary = Cannot import "{1}"
+BPELC_IMPORT__UNRESOVED = The "{1}" document could not be imported while
parsing "{2}"
+BPELC_IMPORT__UNRESOVED.fix = Check that the document exists and that the location is
correct