[savara-commits] savara SVN: r401 - in trunk/tools/plugins: org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse and 14 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Sep 16 12:05:36 EDT 2010
Author: objectiser
Date: 2010-09-16 12:05:34 -0400 (Thu, 16 Sep 2010)
New Revision: 401
Added:
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/Messages.properties
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/Context.java
Modified:
trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/RelationshipValidator.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java
trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/ParserTest.java
trunk/tools/plugins/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java
trunk/tools/plugins/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/AbstractModelRepository.java
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParser.java
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParserContext.java
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/Parser.java
trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/ParserContext.java
trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java
trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java
trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java
Log:
Fixed SAVARA-121 where conformance checking for BPEL was producing errors, as the message types were being compared against the WSDL message type name, rather than the type of the doc/lit XSD element/type that it contained.
Modified: trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tap.model/src/java/org/jboss/savara/tap/model/admin/ResourceLoader.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -22,6 +22,7 @@
package org.jboss.savara.tap.model.admin;
import org.jboss.savara.tap.model.Resource;
+import org.scribble.model.ModelReference;
import org.scribble.model.admin.ModelListener;
public interface ResourceLoader {
@@ -36,6 +37,14 @@
public boolean isSupported(Resource resource);
/**
+ * This method determines if the supplied resource exists.
+ *
+ * @param resource The resource
+ * @return Whether the resource exists
+ */
+ public boolean exists(Resource resource);
+
+ /**
* This method retrieves the contents associated with the
* supplied resource.
*
@@ -45,6 +54,29 @@
public java.io.InputStream getContents(Resource resource);
/**
+ * This method retrieves the contents associated with the
+ * supplied URI. If the URI is a relative path, then the resource will
+ * be located relative to the supplied model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The contents, or null if not found
+ */
+ public java.io.InputStream getContents(ModelReference ref, String uri);
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied URI string. If the supplied URI is a relative path,
+ * then the resource will be located relative to the supplied
+ * model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The resolved URI, or null if not found
+ */
+ public java.net.URI getURI(ModelReference ref, String uri);
+
+ /**
* This method returns a model listener associated with the supplied resource.
*
* @param res The resource
@@ -60,4 +92,12 @@
*/
public void freeResourceModelListener(Resource res, ModelListener l);
+ /**
+ * This method returns the model reference associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return The model reference
+ */
+ public ModelReference getModelReference(Resource resource);
+
}
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/model/admin/eclipse/EclipseResourceLoader.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -26,12 +26,15 @@
import java.util.logging.Logger;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Path;
import org.jboss.savara.tap.model.Resource;
import org.jboss.savara.tap.model.URI;
import org.jboss.savara.tap.model.admin.ResourceLoader;
import org.scribble.eclipse.model.admin.OSGIModelListener;
+import org.scribble.eclipse.model.admin.OSGIModelRepository;
+import org.scribble.model.ModelReference;
import org.scribble.model.admin.ModelListener;
/**
@@ -63,6 +66,17 @@
}
/**
+ * This method determines if the supplied resource exists.
+ *
+ * @param resource The resource
+ * @return Whether the resource exists
+ */
+ public boolean exists(Resource resource) {
+ IFile res=getFile(resource);
+ return(res == null ? false : res.exists());
+ }
+
+ /**
* This method retrieves the contents associated with the
* supplied resource.
*
@@ -87,6 +101,89 @@
/**
* This method retrieves the contents associated with the
+ * supplied URI. If the URI is a relative path, then the resource will
+ * be located relative to the supplied model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The contents, or null if not found
+ */
+ public java.io.InputStream getContents(ModelReference ref, String uri) {
+ java.io.InputStream ret=null;
+
+ if (uri != null) {
+
+ if (uri.startsWith("http:")) {
+ // TODO: Implement
+
+ } else {
+ // Try to locate as relative path from supplied model reference
+ IFile file=OSGIModelRepository.getFile(ref);
+
+ // Find folder
+ IFolder folder = (IFolder)file.getParent();
+
+ IFile refFile=folder.getFile(new Path(uri));
+
+ if (refFile != null) {
+ try {
+ ret = refFile.getContents();
+ } catch(Exception e) {
+ logger.log(Level.SEVERE,
+ "Failed to load content from referenced resource '"+uri+"'", e);
+ }
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Unable to locate resource '"+uri+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the URI associated with the
+ * supplied URI string. If the supplied URI is a relative path,
+ * then the resource will be located relative to the supplied
+ * model reference.
+ *
+ * @param ref The model reference
+ * @param uri The URI
+ * @return The resolved URI, or null if not found
+ */
+ public java.net.URI getURI(ModelReference ref, String uri) {
+ java.net.URI ret=null;
+
+ if (uri != null) {
+
+ if (uri.startsWith("http:")) {
+ try {
+ ret = new java.net.URI(uri);
+ } catch(Exception e) {
+ logger.log(Level.SEVERE, "Invalid URI '"+uri+"'", e);
+ }
+ } else {
+ // Try to locate as relative path from supplied model reference
+ IFile file=OSGIModelRepository.getFile(ref);
+
+ // Find folder
+ IFolder folder = (IFolder)file.getParent();
+
+ IFile refFile=folder.getFile(new Path(uri));
+
+ if (refFile != null) {
+ ret = refFile.getRawLocationURI();
+ } else if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Unable to locate resource '"+uri+"'");
+ }
+ }
+ }
+
+ return(ret);
+ }
+
+ /**
+ * This method retrieves the contents associated with the
* supplied resource.
*
* @param resource The resource
@@ -161,4 +258,15 @@
((OSGIModelListener)l).finished();
}
}
+
+ /**
+ * This method returns the model reference associated with the supplied resource.
+ *
+ * @param resource The resource
+ * @return The model reference
+ */
+ public ModelReference getModelReference(Resource resource) {
+ return(OSGIModelRepository.createReference(getFile(resource)));
+ }
+
}
Added: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/Messages.properties
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/Messages.properties (rev 0)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/Messages.properties 2010-09-16 16:05:34 UTC (rev 401)
@@ -0,0 +1,20 @@
+#/*
+# * JBoss, Home of Professional Open Source
+# * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+# * by the @authors tag. All rights reserved.
+# * See the copyright.txt in the distribution for a
+# * full listing of individual contributors.
+# * This copyrighted material is made available to anyone wishing to use,
+# * modify, copy, or redistribute it subject to the terms and conditions
+# * of the GNU Lesser General Public License, v. 2.1.
+# * This program is distributed in the hope that it will be useful, but WITHOUT A
+# * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+# * You should have received a copy of the GNU Lesser General Public License,
+# * v.2.1 along with this distribution; if not, write to the Free Software
+# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# * MA 02110-1301, USA.
+# */
+
+SAVARATAPV-00001=Unable to load resource type for resource with id "{0}"
+SAVARATAPV-00002=Unable to locate resource with id "{0}"
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/RelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/RelationshipValidator.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/RelationshipValidator.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -23,6 +23,7 @@
import org.jboss.savara.tap.model.Relationship;
import org.jboss.savara.tap.model.Resource;
+import org.jboss.savara.tap.model.admin.ResourceLoader;
import org.scribble.model.admin.ModelListener;
/**
@@ -49,12 +50,12 @@
*
* @param rel The relationship details
* @param fromResource The 'from' resource to be validated
- * @param fromIS The 'from' resource input stream
+ * @param fromRL The 'from' resource loader
* @param toResource The 'to' resource to be validated
- * @param toIS The 'to' resource input stream
+ * @param toRL The 'to' resource loader
* @param l The model listener
*/
- public void validate(Relationship rel, Resource fromResource, java.io.InputStream fromIS,
- Resource toResource, java.io.InputStream toIS, ModelListener l);
+ public void validate(Relationship rel, Resource fromResource, ResourceLoader fromRL,
+ Resource toResource, ResourceLoader toRL, ModelListener l);
}
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/TAPValidator.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -21,6 +21,7 @@
*/
package org.jboss.savara.tap.validation;
+import java.text.MessageFormat;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -30,6 +31,7 @@
import org.jboss.savara.tap.model.Relationship;
import org.jboss.savara.tap.model.Resource;
import org.jboss.savara.tap.model.admin.ResourceLoader;
+import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
/**
@@ -113,16 +115,17 @@
// Load and validate the individual resources
for (Phase phase : project.getPhase()) {
for (Resource resource : phase.getResource()) {
- ModelListener rl=getResourceModelListener(resource);
+ ModelListener ml=getResourceModelListener(resource);
// Validate resource
for (ResourceValidator rv : m_resourceValidators) {
if (rv.isSupported(resource)) {
// Obtain input stream for resource
- java.io.InputStream is=getResourceContents(resource);
+ ResourceLoader rl=getResourceLoader(resource);
+ java.io.InputStream is=rl.getContents(resource);
if (is != null) {
- rv.validate(resource, is, rl);
+ rv.validate(resource, is, ml);
try {
is.close();
@@ -146,12 +149,38 @@
if (rv.isSupported(rel, resource, toResource)) {
// Obtain input stream for resource
- java.io.InputStream fromIS=getResourceContents(resource);
- java.io.InputStream toIS=getResourceContents(toResource);
+ ResourceLoader fromRL=getResourceLoader(resource);
+ ResourceLoader toRL=getResourceLoader(toResource);
- rv.validate(rel, resource, fromIS, toResource, toIS, rl);
+ if (fromRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), resource.getId())));
+ } else if (toRL == null) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00001"), toResource.getId())));
+ } else if (!fromRL.exists(resource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), resource.getId())));
+ } else if (!toRL.exists(toResource)) {
+ l.error(new ModelIssue(null,
+ MessageFormat.format(
+ java.util.PropertyResourceBundle.getBundle(
+ "org.jboss.savara.tap.validation.Messages").
+ getString("SAVARATAPV-00002"), toResource.getId())));
+ } else {
+ rv.validate(rel, resource, fromRL, toResource, toRL, ml);
- break;
+ break;
+ }
}
}
} else {
@@ -160,18 +189,18 @@
}
}
- freeResourceModelListener(resource, rl);
+ freeResourceModelListener(resource, ml);
}
}
}
- protected java.io.InputStream getResourceContents(Resource resource) {
- java.io.InputStream ret=null;
+ protected ResourceLoader getResourceLoader(Resource resource) {
+ ResourceLoader ret=null;
try {
for (ResourceLoader rl : m_resourceLoaders) {
if (rl.isSupported(resource)) {
- ret = rl.getContents(resource);
+ ret = rl;
if (ret != null) {
break;
@@ -179,7 +208,7 @@
}
}
} catch(Exception e) {
- logger.log(Level.SEVERE, "Failed to load resource '"+
+ logger.log(Level.SEVERE, "Failed to get resource loader for resource '"+
resource.getId()+"'", e);
}
Modified: trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tap.validation/src/java/org/jboss/savara/tap/validation/ws/BPELRelationshipValidator.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -21,14 +21,19 @@
*/
package org.jboss.savara.tap.validation.ws;
+import java.io.InputStream;
+
import javax.xml.namespace.QName;
import org.jboss.savara.tap.model.Link;
import org.jboss.savara.tap.model.Relationship;
import org.jboss.savara.tap.model.Resource;
+import org.jboss.savara.tap.model.admin.ResourceLoader;
import org.jboss.savara.tap.validation.RelationshipValidator;
import org.scribble.model.Model;
+import org.scribble.model.ModelReference;
import org.scribble.model.Role;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
@@ -70,13 +75,13 @@
*
* @param rel The relationship details
* @param fromResource The 'from' resource to be validated
- * @param fromIS The 'from' resource input stream
+ * @param fromRL The 'from' resource loader
* @param toResource The 'to' resource to be validated
- * @param toIS The 'to' resource input stream
+ * @param toRL The 'to' resource loader
* @param l The model listener
*/
- public void validate(Relationship rel, Resource fromResource, java.io.InputStream fromIS,
- Resource toResource, java.io.InputStream toIS, ModelListener l) {
+ public void validate(Relationship rel, Resource fromResource, final ResourceLoader fromRL,
+ Resource toResource, final ResourceLoader toRL, ModelListener l) {
String roleName=null;
// Get the 'to' role associated with the link
@@ -94,21 +99,27 @@
} else {
org.scribble.parser.Parser p=new org.scribble.parser.DefaultParser();
- org.scribble.model.ModelReference fromRef=
- new org.scribble.model.ModelReference("bpel");
+ org.scribble.model.ModelReference fromRef=fromRL.getModelReference(fromResource);
+ //new org.scribble.model.ModelReference("bpel");
- org.scribble.model.Model fromModel=p.parse(fromRef, fromIS, l);
+ java.io.InputStream fromIS=fromRL.getContents(fromResource);
+ org.scribble.model.Model fromModel=p.parse(fromRef, fromIS, l,
+ new ResourceLoaderContext(fromRL));
+
if (fromModel == null) {
ModelIssue issue=new ModelIssue();
issue.setMessage("Failed to parse '"+fromResource.getId()+"'");
l.error(issue);
} else {
- org.scribble.model.ModelReference toRef=
- new org.scribble.model.ModelReference("cdm");
+ org.scribble.model.ModelReference toRef=toRL.getModelReference(toResource);
+ //new org.scribble.model.ModelReference("cdm");
- org.scribble.model.Model toModel=p.parse(toRef, toIS, l);
+ java.io.InputStream toIS=fromRL.getContents(toResource);
+
+ org.scribble.model.Model toModel=p.parse(toRef, toIS, l,
+ new ResourceLoaderContext(toRL));
if (toModel == null) {
ModelIssue issue=new ModelIssue();
@@ -142,4 +153,23 @@
}
}
+ public class ResourceLoaderContext implements Context {
+
+ private ResourceLoader m_resourceLoader=null;
+
+ public ResourceLoaderContext(ResourceLoader rl) {
+ m_resourceLoader = rl;
+ }
+
+ @Override
+ public InputStream getResource(ModelReference ref, String uri) {
+ return(m_resourceLoader.getContents(ref, uri));
+ }
+
+ @Override
+ public java.net.URI getResourceURI(ModelReference ref, String uri) {
+ return(m_resourceLoader.getURI(ref, uri));
+ }
+
+ }
}
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/editor/BPELEditorManager.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -96,8 +96,11 @@
*/
@Override
public void enrich(ModelIssue issue) {
- String uri=issue.getModelObject().getSource().getComponentURI();
- issue.getProperties().put("address.model", uri);
+ if (issue != null && issue.getModelObject() != null) {
+ String uri=issue.getModelObject().getSource().getComponentURI();
+
+ issue.getProperties().put("address.model", uri);
+ }
}
}
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/DefaultBPELLanguageModel.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -21,6 +21,7 @@
import org.jboss.savara.tools.bpel.model.component.Process;
import org.scribble.conversation.model.Conversation;
import org.scribble.model.*;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
import org.scribble.model.resolutions.*;
@@ -45,7 +46,7 @@
* @param contents The textual contents
*/
public DefaultBPELLanguageModel(ModelReference source, org.w3c.dom.Element elem,
- String contents) {
+ String contents, Context context) {
m_source = source;
m_contents = contents;
m_bpelProcess = new Process(this, elem);
@@ -55,7 +56,7 @@
setNamespace(ns);
// Initialize the existing model
- Conversation conv=m_bpelProcess.convert();
+ Conversation conv=m_bpelProcess.convert(context);
if (conv != null) {
getConversations().add(conv);
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/AbstractInteraction.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -17,6 +17,8 @@
*/
package org.jboss.savara.tools.bpel.model.component;
+import javax.xml.namespace.QName;
+
import org.scribble.model.TypeReference;
import org.scribble.model.admin.ModelListener;
import org.jboss.savara.tools.bpel.model.*;
@@ -150,8 +152,17 @@
if (type != null) {
int index=-1;
- if ((index=type.indexOf(':')) == -1) {
+
+ if (type.charAt(0) == '{') {
+ // Assume a qname
+ QName qname=QName.valueOf(type);
+
+ ret.setLocalpart(qname.getLocalPart());
+ ret.setNamespace(qname.getNamespaceURI());
+
+ } else if ((index=type.indexOf(':')) == -1) {
ret.setLocalpart(type);
+
} else {
ret.setLocalpart(type.substring(index+1));
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/ConversionContext.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -17,9 +17,18 @@
*/
package org.jboss.savara.tools.bpel.model.component;
+import org.scribble.model.admin.Context;
+
public interface ConversionContext {
/**
+ * This method returns a reference to the environment context.
+ *
+ * @return The environment context
+ */
+ public Context getEnvironmentContext();
+
+ /**
* This method returns the process.
*
* @return The process
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/DefaultConversionContext.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -17,6 +17,8 @@
*/
package org.jboss.savara.tools.bpel.model.component;
+import org.scribble.model.admin.Context;
+
/**
* This class provides a default implementation of the conversation
* context.
@@ -28,13 +30,25 @@
* with the role being played by the converted BPEL process.
*
* @param role The role
+ * @param proc The process
+ * @param envContext The environment context
*/
- public DefaultConversionContext(String role, Process proc) {
+ public DefaultConversionContext(String role, Process proc, Context envContext) {
m_role = role;
m_process = proc;
+ m_environmentContext = envContext;
}
/**
+ * This method returns a reference to the environment context.
+ *
+ * @return The environment context
+ */
+ public Context getEnvironmentContext() {
+ return(m_environmentContext);
+ }
+
+ /**
* This method returns the process.
*
* @return The process
@@ -94,6 +108,7 @@
private String m_role=null;
private Process m_process=null;
+ private Context m_environmentContext=null;
private java.util.Map<String,Variable> m_variables=
new java.util.HashMap<String,Variable>();
}
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Invoke.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -212,7 +212,10 @@
Variable var=context.getVariable(getInputVariable());
- TypeReference tref=createTypeReference(var.getMessageType(), context);
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=createTypeReference(xmlType, context);
MessageSignature ms=new MessageSignature();
ms.setOperation(getOperation());
@@ -242,7 +245,10 @@
Variable var=context.getVariable(getOutputVariable());
- TypeReference tref=createTypeReference(var.getMessageType(), context);
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=createTypeReference(xmlType, context);
MessageSignature ms=new MessageSignature();
ms.setOperation(getOperation());
@@ -280,7 +286,10 @@
Variable var=context.getVariable(faultVar);
if (var != null) {
- tref = createTypeReference(var.getMessageType(), context);
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ tref = createTypeReference(xmlType, context);
//tref.setLocalpart(var.getMessageType());
} else if (faultMesgType != null) {
tref = createTypeReference(faultMesgType, context);
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Process.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -17,10 +17,16 @@
*/
package org.jboss.savara.tools.bpel.model.component;
+import java.util.logging.Level;
+
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
import org.scribble.conversation.model.ConditionalBlock;
import org.scribble.conversation.model.Conversation;
import org.scribble.conversation.model.ConversationNotation;
import org.scribble.model.*;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -169,9 +175,10 @@
* WSDL message type.
*
* @param wsdlMessageType The WSDL message type
+ * @param context The context
* @return The underlying XML element/type, or null if not found
*/
- public String getXMLType(String wsdlMessageType) {
+ public String getXMLType(String wsdlMessageType, Context context) {
String ret=null;
// Resolve the namespace prefix
@@ -191,13 +198,56 @@
imp.getNamespace().equals(namespace) &&
imp.getLocation() != null &&
imp.getLocation().endsWith(".wsdl")) {
- System.out.println("Check "+imp.getLocation());
+
+ java.net.URI uri=
+ context.getResourceURI(getModel().getModelReference(),
+ imp.getLocation());
+
+ if (uri != null) {
+ ret = getXMLType(imp.getNamespace(), wsdlMessageType, uri);
+
+ if (ret != null) {
+ break;
+ }
+ }
}
}
}
return(ret);
}
+
+ protected String getXMLType(String namespace, String wsdlMessageType, java.net.URI uri) {
+ String ret=null;
+
+ try {
+ WSDLReader reader=javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
+
+ javax.wsdl.Definition defn=reader.readWSDL(uri.toString());
+
+ if (defn != null) {
+ javax.wsdl.Message mesg=defn.getMessage(new QName(namespace, wsdlMessageType));
+
+ if (mesg != null && mesg.getParts().size() == 1) {
+ System.out.println("PARTS="+mesg.getParts());
+
+ javax.wsdl.Part part=(javax.wsdl.Part)
+ mesg.getParts().values().iterator().next();
+
+ if (part.getElementName() != null) {
+ ret = part.getElementName().toString();
+ } else if (part.getTypeName() != null) {
+ ret = part.getTypeName().toString();
+ }
+ }
+ }
+
+ } catch(Exception e) {
+ logger.error("Failed to read WSDL", e);
+ }
+
+ return(ret);
+ }
/**
* This method returns the list of partner links.
@@ -827,9 +877,10 @@
* This method returns the conversion associated with the
* BPEL process.
*
+ * @param envContext The environment context
* @return The conversation
*/
- public Conversation convert() {
+ public Conversation convert(Context envContext) {
Conversation ret=new Conversation();
ret.derivedFrom(this);
@@ -897,7 +948,7 @@
}
// Convert the process contents
- DefaultConversionContext context=new DefaultConversionContext(role, this);
+ DefaultConversionContext context=new DefaultConversionContext(role, this, envContext);
// Add variables to the context
for (int i=0; i < m_variables.size(); i++) {
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Receive.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -129,7 +129,7 @@
* @param context The conversion context
*/
protected void convertActivity(java.util.List<Activity> activities,
- ConversionContext context) {
+ ConversionContext context) {
getSource().setComponentURI(getURI());
ConversationInteraction interaction=new ConversationInteraction();
@@ -137,9 +137,10 @@
Variable var=context.getVariable(getVariable());
- String xmlType=context.getProcess().getXMLType(var.getMessageType());
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
- TypeReference tref=createTypeReference(var.getMessageType(), context);
+ TypeReference tref=createTypeReference(xmlType, context);
MessageSignature ms=new MessageSignature();
ms.derivedFrom(this);
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/model/component/Reply.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -125,7 +125,10 @@
Variable var=context.getVariable(getVariable());
- TypeReference tref=createTypeReference(var.getMessageType(), context);
+ String xmlType=context.getProcess().getXMLType(var.getMessageType(),
+ context.getEnvironmentContext());
+
+ TypeReference tref=createTypeReference(xmlType, context);
MessageSignature ms=new MessageSignature();
ms.derivedFrom(this);
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/java/org/jboss/savara/tools/bpel/parser/BPELModelParserRule.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -96,7 +96,7 @@
// Identify the model associated with the
// changed resource
ret = new DefaultBPELLanguageModel(context.getSource(),
- doc.getDocumentElement(), str);
+ doc.getDocumentElement(), str, context.getEnvironmentContext());
} catch(Exception e) {
logger.log(Level.SEVERE,
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/generator/GeneratorTest.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -111,7 +111,7 @@
org.scribble.model.admin.ModelListener l=
new org.scribble.model.admin.DefaultModelListener();
- org.scribble.model.Model model=p.parse(ref, is, l);
+ org.scribble.model.Model model=p.parse(ref, is, l, null);
if (model == null) {
result.addError(this, new Throwable("Model is null"));
Modified: trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/ParserTest.java
===================================================================
--- trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/ParserTest.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.jboss.savara.tools.bpel/src/plugintest/org/jboss/savara/tools/bpel/parser/ParserTest.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -87,7 +87,7 @@
org.scribble.model.admin.DefaultModelListener l=
new org.scribble.model.admin.DefaultModelListener();
- org.scribble.model.Model model=p.parse(ref, is, l);
+ org.scribble.model.Model model=p.parse(ref, is, l, null);
if (model == null) {
result.addError(this, new Throwable("Model is null"));
Modified: trunk/tools/plugins/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java
===================================================================
--- trunk/tools/plugins/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.conformance/src/plugintest/org/scribble/conformance/model/transform/TransformTest.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -83,7 +83,7 @@
org.scribble.model.admin.ModelListener l=
new org.scribble.model.admin.DefaultModelListener();
- org.scribble.model.Model model=p.parse(ref, is, l);
+ org.scribble.model.Model model=p.parse(ref, is, l, null);
if (model == null) {
result.addError(this, new Throwable("Model is null"));
Modified: trunk/tools/plugins/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java
===================================================================
--- trunk/tools/plugins/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.conversation.comparator/src/plugintest/org/scribble/conversation/comparator/model/transform/TransformTest.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -82,7 +82,7 @@
org.scribble.model.admin.ModelListener l=
new org.scribble.model.admin.DefaultModelListener();
- org.scribble.model.Model model=p.parse(ref, is, l);
+ org.scribble.model.Model model=p.parse(ref, is, l, null);
if (model == null) {
result.addError(this, new Throwable("Model is null"));
Modified: trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/AbstractModelRepository.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/AbstractModelRepository.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/AbstractModelRepository.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -67,7 +67,7 @@
org.scribble.parser.Parser.class, ref.getNotation());
if (parser != null) {
- ret=parser.parse(ref, is, l);
+ ret=parser.parse(ref, is, l, null);
if (ret != null) {
ret.initializeURIs();
Added: trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/Context.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/Context.java (rev 0)
+++ trunk/tools/plugins/org.scribble.core/src/java/org/scribble/model/admin/Context.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.scribble.model.admin;
+
+import org.scribble.model.ModelReference;
+
+/**
+ * This interface provides access to the environment in which a tool is
+ * being used.
+ *
+ */
+public interface Context {
+
+ /**
+ * This method can be used to retrieve the contents of a resource which
+ * is located at the specified URI. If the URI is a relative path, then
+ * the supplied model reference can be used to identify the source from
+ * which the path is relative.
+ *
+ * @param ref The model reference for the source file
+ * @param uri The URI of the resource to load
+ * @return The input stream, or null if not found
+ */
+ public java.io.InputStream getResource(ModelReference ref, String uri);
+
+ /**
+ * This method can be used to retrieve the URI of a resource which
+ * is located at the specified URI. If the URI is a relative path, then
+ * the supplied model reference can be used to identify the source from
+ * which the path is relative.
+ *
+ * @param ref The model reference for the source file
+ * @param uri The URI of the resource to load
+ * @return The URI, or null if not found
+ */
+ public java.net.URI getResourceURI(ModelReference ref, String uri);
+
+}
Modified: trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParser.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParser.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParser.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -21,6 +21,7 @@
import org.scribble.extensions.RegistryInfo;
import org.scribble.model.*;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelListener;
/**
@@ -46,17 +47,17 @@
*
*/
public Model parse(ModelReference ref, java.io.InputStream is,
- ModelListener l) {
+ ModelListener l, Context context) {
Model ret=null;
Tokenizer tokenizer=(Tokenizer)
org.scribble.extensions.RegistryFactory.getRegistry().
getExtension(Tokenizer.class, ref.getNotation());
- DefaultParserContext context=
- new DefaultParserContext(ref, is, tokenizer);
+ DefaultParserContext parserContext=
+ new DefaultParserContext(ref, is, tokenizer, context);
- ret = (Model)context.parse(Model.class, l);
+ ret = (Model)parserContext.parse(Model.class, l);
return(ret);
}
Modified: trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParserContext.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParserContext.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/DefaultParserContext.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -23,6 +23,7 @@
import java.util.logging.Logger;
import org.scribble.model.*;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelIssue;
import org.scribble.model.admin.ModelListener;
import org.scribble.util.Scope;
@@ -39,10 +40,12 @@
* @param ref The model reference
* @param is The input stream
* @param tokenizer The optional tokenizer to use
+ * @param context The environment context
*/
public DefaultParserContext(ModelReference ref, java.io.InputStream is,
- Tokenizer tokenizer) {
+ Tokenizer tokenizer, Context context) {
m_modelReference = ref;
+ m_environmentContext = context;
initializeScope(m_scope);
@@ -85,6 +88,15 @@
}
/**
+ * This method provides the environment's context.
+ *
+ * @return The environment context
+ */
+ public Context getEnvironmentContext() {
+ return(m_environmentContext);
+ }
+
+ /**
* This method returns the source model reference associated
* with the definition being parsed.
*
@@ -93,6 +105,19 @@
public ModelReference getSource() {
return(m_modelReference);
}
+
+ /**
+ * This method retrieves the contents of the resource at the
+ * specified URI. If the URI is relative, then the path will
+ * be considered relative to the resource associated with
+ * the source model reference.
+ *
+ * @param uri The URI
+ * @return The input stream, or null if not found
+ */
+ public java.io.InputStream getResource(String uri) {
+ return(m_environmentContext.getResource(getSource(), uri));
+ }
/**
* This method returns the located role associated with the
@@ -415,6 +440,7 @@
private static final String UNRESOLVED_REFERENCES="UnresolvedReferences";
private ModelReference m_modelReference=null;
+ private Context m_environmentContext=null;
private int m_position=0;
private java.util.List<Token> m_tokens=null;
private boolean m_errorReported=false;
Modified: trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/Parser.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/Parser.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/Parser.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -20,6 +20,7 @@
package org.scribble.parser;
import org.scribble.model.*;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelListener;
public interface Parser {
@@ -33,9 +34,10 @@
* @param ref The scribble source reference
* @param is The input stream
* @param l The model listener
+ * @param context The environment context
* @return The model, or null if not found
*/
public Model parse(ModelReference ref, java.io.InputStream is,
- ModelListener l);
+ ModelListener l, Context context);
}
Modified: trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/ParserContext.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/ParserContext.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/java/org/scribble/parser/ParserContext.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -20,6 +20,7 @@
package org.scribble.parser;
import org.scribble.model.*;
+import org.scribble.model.admin.Context;
import org.scribble.model.admin.ModelListener;
/**
@@ -29,6 +30,13 @@
public interface ParserContext {
/**
+ * This method provides the environment's context.
+ *
+ * @return The environment context
+ */
+ public Context getEnvironmentContext();
+
+ /**
* This method returns the source model reference associated
* with the definition being parsed.
*
Modified: trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/DefaultParserContextTest.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -49,7 +49,7 @@
ModelReference ref=new ModelReference("");
DefaultParserContext context=new DefaultParserContext(ref,
new java.io.ByteArrayInputStream(text.getBytes()),
- new DefaultTokenizer());
+ new DefaultTokenizer(), null);
// Should be 2 tokens, as comment is filtered out
if (context.getTokenCount() != 2) {
@@ -65,7 +65,7 @@
ModelReference ref=new ModelReference("");
DefaultParserContext context=new DefaultParserContext(ref,
new java.io.ByteArrayInputStream(text.getBytes()),
- new DefaultTokenizer());
+ new DefaultTokenizer(), null);
// Should be 2 tokens, as comment is filtered out
if (context.getTokenCount() != 2) {
@@ -82,7 +82,7 @@
ModelReference ref=new ModelReference("");
DefaultParserContext context=new DefaultParserContext(ref,
new java.io.ByteArrayInputStream(text.getBytes()),
- new DefaultTokenizer());
+ new DefaultTokenizer(), null);
if (context.getTokenCount() != 3) {
fail("Expecting 3 tokens, but got: "+context.getTokenCount());
@@ -100,7 +100,7 @@
ModelReference ref=new ModelReference("");
DefaultParserContext context=new DefaultParserContext(ref,
new java.io.ByteArrayInputStream(text.getBytes()),
- new DefaultTokenizer());
+ new DefaultTokenizer(), null);
// Should be 3 tokens
if (context.getTokenCount() != 3) {
@@ -125,7 +125,7 @@
ModelReference ref=new ModelReference("");
DefaultParserContext context=new DefaultParserContext(ref,
new java.io.ByteArrayInputStream(text.getBytes()),
- new DefaultTokenizer());
+ new DefaultTokenizer(), null);
// Should be 2 tokens
if (context.getTokenCount() != 2) {
Modified: trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java
===================================================================
--- trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.core/src/test/org/scribble/parser/TestParserContext.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -24,6 +24,6 @@
public TestParserContext(org.scribble.model.ModelReference ref,
String text) {
super(ref, new java.io.ByteArrayInputStream(text.getBytes()),
- new DefaultTokenizer());
+ new DefaultTokenizer(), null);
}
}
Modified: trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java
===================================================================
--- trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java 2010-09-15 14:24:47 UTC (rev 400)
+++ trunk/tools/plugins/org.scribble.eclipse/src/java/org/scribble/eclipse/model/admin/OSGIModelListener.java 2010-09-16 16:05:34 UTC (rev 401)
@@ -174,8 +174,10 @@
marker.setAttribute(IMarker.CHAR_END, endPos);
}
- marker.setAttribute(SOURCE_MODEL_OBJECT_URI, src.getSource().getModelObjectURI());
- marker.setAttribute(SOURCE_COMPONENT_URI, src.getSource().getComponentURI());
+ if (src != null && src.getSource() != null) {
+ marker.setAttribute(SOURCE_MODEL_OBJECT_URI, src.getSource().getModelObjectURI());
+ marker.setAttribute(SOURCE_COMPONENT_URI, src.getSource().getComponentURI());
+ }
if (m_reference != null) {
marker.setAttribute(MODEL_NAMESPACE, m_reference.getNamespace());
@@ -273,11 +275,11 @@
}
public int getStartPosition() {
- return(m_issue.getModelObject().getSource().getStartPosition());
+ return(m_issue.getModelObject() == null ? -1 : m_issue.getModelObject().getSource().getStartPosition());
}
public int getEndPosition() {
- return(m_issue.getModelObject().getSource().getEndPosition());
+ return(m_issue.getModelObject() == null ? -1 : m_issue.getModelObject().getSource().getEndPosition());
}
public String getMessage() {
More information about the savara-commits
mailing list