diff options
452 files changed, 7571 insertions, 4175 deletions
diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java new file mode 100644 index 00000000..3c46f67a --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/GeneratorAdvice.java @@ -0,0 +1,177 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.mwe.core.WorkflowComponent; +import org.eclipse.emf.mwe.core.issues.Issues; +import org.eclipse.xpand2.Generator; +import org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowAdvice; + +/** + * Weaves aspect templates into a generator component. + * <p> + * <h2>Parameters</h2> + * <table border="1"> + * <tr> + * <th>Name</th> + * <th>Multiplicity</th> + * <th>Type</th> + * <th>Description</th> + * </tr> + * + * <tr> + * <td>adviceTarget</td> + * <td>1</td> + * <td>String</td> + * <td>The id of a {@link Generator} component</td> + * </tr> + * + * <tr> + * <td>advices</td> + * <td>0..n</td> + * <td>String</td> + * <td>Comma seperated list of qualified aspect templates</td> + * </tr> + * + * <tr> + * <td>advice</td> + * <td>0..n</td> + * <td>String</td> + * <td>Qualified name of an aspect template</td> + * </tr> + * + * + * <tr> + * <td>extensionAdvice</td> + * <td>0..n</td> + * <td>String</td> + * <td>Comma seperated list of qualified aspect extensions</td> + * </tr> + * + * <tr> + * <td>metaModel</td> + * <td>0..n</td> + * <td>org.openarchitectureware.type.MetaModel</td> + * <td>Additional metamodels needed for the advices.</td> + * </tr> + * + * <tr> + * <td>globalVarDef</td> + * <td>0..n</td> + * <td>GlobalVarDef</td> + * <td>Additional global vars needed for the advices.</td> + * </tr> + * </table> + */ +public class GeneratorAdvice extends AbstractExpressionsUsingWorkflowAdvice { + + private static final String COMPONENT_NAME = "Xpand Generator Advice"; + + private List<String> advices = new ArrayList<String>(); + + private List<String> extensionAdvices = new ArrayList<String>(); + + private String fileEncoding; + + /** + * @deprecated Use <code>addAdvice(String)</code> instead. + */ + @Deprecated + public void addAdvices(String advices) { + this.advices.add(advices); + } + + /** + * @deprecated Use <code>addExtensionAdvice(String)</code> instead. + */ + @Deprecated + public void addExtensionAdvices(String extensionAdvices) { + addExtensionAdvice(extensionAdvices); + } + + /** + * Adds an advice. + * + * @param advice + * the advice + */ + public void addAdvice(String advice) { + this.advices.add(advice); + } + + /** + * Adds an extension advice, + * + * @param extensionAdvice + * the extension advice + */ + public void addExtensionAdvice(String extensionAdvice) { + this.extensionAdvices.add(extensionAdvice); + } + + /** + * Sets the file encoding to use for the target generator. + * + * @param fileEncoding + * Encoding string, e.g. 'ISO-8859-1' + * @since 4.2 + * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=195042 + */ + public void setFileEncoding(String fileEncoding) { + this.fileEncoding = fileEncoding; + } + + /** + * @see org.openarchitectureware.workflow.ao.AbstractWorkflowAdvice#checkConfiguration(org.openarchitectureware.workflow.issues.Issues) + */ + @Override + public void checkConfiguration(Issues issues) { + super.checkConfiguration(issues); + if (advices.isEmpty() && extensionAdvices.isEmpty()) { + issues.addError("Neither 'advices' nor 'extensionAdvices' configured."); + } + } + + /** + * @see org.openarchitectureware.expression.AbstractExpressionsUsingWorkflowAdvice#weave(org.openarchitectureware.workflow.WorkflowComponent, + * org.openarchitectureware.workflow.issues.Issues) + */ + @Override + public void weave(WorkflowComponent c, Issues issues) { + super.weave(c, issues); + if (!(c instanceof Generator)) { + issues.addError(this, "advice target is not a Generator component."); + } + else { + Generator gen = (Generator) c; + for (String advice : advices) { + gen.addAdvice(advice); + } + for (String advice : extensionAdvices) { + gen.addExtensionAdvice(advice); + } + if (fileEncoding != null) { + gen.setFileEncoding(fileEncoding); + } + } + } + + @Override + public String getLogMessage() { + return "extension-advices: " + buildList(extensionAdvices) + " template-advices: " + buildList(advices); + } + + @Override + public String getComponentName() { + return COMPONENT_NAME; + } +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/NoSuchTemplateException.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/NoSuchTemplateException.java new file mode 100644 index 00000000..c611cf47 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/NoSuchTemplateException.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2; + +public class NoSuchTemplateException extends RuntimeException { + + private static final long serialVersionUID = -6939510590247142812L; + + public NoSuchTemplateException(final String fullyQualifiedName) { + super("Couldn't find template : " + fullyQualifiedName); + } + +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandCompilerIssue.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandCompilerIssue.java new file mode 100644 index 00000000..3b81ce0d --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandCompilerIssue.java @@ -0,0 +1,17 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2; + +import org.eclipse.xtend.expression.AnalysationIssue.AnalysationIssueType; + +public interface XpandCompilerIssue { + + public final static AnalysationIssueType DEFINITION_NOT_FOUND = new AnalysationIssueType("Definition not found"); + +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandExecutionContextImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandExecutionContextImpl.java new file mode 100644 index 00000000..d0e83607 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandExecutionContextImpl.java @@ -0,0 +1,315 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2; + +import java.io.Reader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; +import org.eclipse.internal.xpand2.model.AdvicedDefinition; +import org.eclipse.internal.xpand2.model.XpandAdvice; +import org.eclipse.internal.xpand2.model.XpandDefinition; +import org.eclipse.internal.xpand2.model.XpandResource; +import org.eclipse.internal.xpand2.parser.XpandParseFacade; +import org.eclipse.internal.xpand2.pr.ProtectedRegionResolver; +import org.eclipse.internal.xpand2.type.XpandTypesMetaModel; +import org.eclipse.internal.xtend.expression.parser.SyntaxConstants; +import org.eclipse.internal.xtend.type.baseimpl.PolymorphicResolver; +import org.eclipse.internal.xtend.xtend.ast.Around; +import org.eclipse.internal.xtend.xtend.ast.Extension; +import org.eclipse.xpand2.XpandExecutionContext; +import org.eclipse.xpand2.output.Output; +import org.eclipse.xtend.expression.Callback; +import org.eclipse.xtend.expression.ExceptionHandler; +import org.eclipse.xtend.expression.ExecutionContextImpl; +import org.eclipse.xtend.expression.NullEvaluationHandler; +import org.eclipse.xtend.expression.Resource; +import org.eclipse.xtend.expression.ResourceManager; +import org.eclipse.xtend.expression.ResourceParser; +import org.eclipse.xtend.expression.TypeSystemImpl; +import org.eclipse.xtend.expression.Variable; +import org.eclipse.xtend.typesystem.Callable; +import org.eclipse.xtend.typesystem.Operation; +import org.eclipse.xtend.typesystem.Type; + +/** + * * + * + * @author Sven Efftinge (http://www.efftinge.de) * + */ +public class XpandExecutionContextImpl extends ExecutionContextImpl implements XpandExecutionContext { + + private final Log log = LogFactory.getLog(getClass()); + + protected final Output output; + + protected final ProtectedRegionResolver protectedRegionResolver; + + private List<XpandAdvice> registeredAdvices = new ArrayList<XpandAdvice>(); + + public XpandExecutionContextImpl(Output output, ProtectedRegionResolver prs) { + this(output, prs, null, null, null); + } + + public XpandExecutionContextImpl(Output output, ProtectedRegionResolver prs, Map<String, Variable> globalVars, + ExceptionHandler exceptionHandler, NullEvaluationHandler nullEvaluationHandler) { + this(new TypeSystemImpl(), output, prs, globalVars, exceptionHandler, nullEvaluationHandler); + } + + protected XpandExecutionContextImpl(final TypeSystemImpl ts, Output output, ProtectedRegionResolver prs, + Map<String, Variable> globalVars, ExceptionHandler exceptionHandler, + NullEvaluationHandler nullEvaluationHandler) { + super(ts, globalVars); + registerMetaModel(new XpandTypesMetaModel(this)); + registerParser(resourceManager); + this.output = output; + this.protectedRegionResolver = prs; + this.exceptionHandler = exceptionHandler; + this.nullEvaluationHandler = nullEvaluationHandler; + } + + private void registerParser(ResourceManager resourceManager) { + resourceManager.registerParser(XpandUtil.TEMPLATE_EXTENSION, new ResourceParser() { + + public Resource parse(Reader in, String fileName) { + return XpandParseFacade.file(in, fileName); + } + }); + } + + protected XpandExecutionContextImpl(ResourceManager resourceManager, Resource currentResource, + TypeSystemImpl typeSystem, Map<String, Variable> vars, Map<String, Variable> globalVars, Output output, + ProtectedRegionResolver protectedRegionResolver, ProgressMonitor monitor, + ExceptionHandler exceptionHandler, List<Around> advices, NullEvaluationHandler nullEvaluationHandler, + Map<Resource, Set<Extension>> allExtensionsPerResource, Callback callback) { + super(resourceManager, currentResource, typeSystem, vars, globalVars, monitor, exceptionHandler, advices, + nullEvaluationHandler, allExtensionsPerResource, callback); + registerMetaModel(new XpandTypesMetaModel(this)); + this.output = output; + this.protectedRegionResolver = protectedRegionResolver; + this.exceptionHandler = exceptionHandler; + } + + @Override + public XpandExecutionContextImpl cloneContext() { + final XpandExecutionContextImpl result = new XpandExecutionContextImpl(resourceManager, currentResource(), + typeSystem, getVisibleVariables(), getGlobalVariables(), output, protectedRegionResolver, getMonitor(), + exceptionHandler, registeredExtensionAdvices, nullEvaluationHandler, allExtensionsPerResource, callback); + result.registeredAdvices.addAll(registeredAdvices); // todo: [aha] + // before I + // refactored, there + // was an assignment + // in this place. Is + // this modification + // correct? + return result; + } + + public List<XpandDefinition> getAllDefinitions() { + XpandResource tpl = null; + tpl = (XpandResource) currentResource(); + if (tpl == null) + return null; + + XpandDefinition[] localDefinitions = tpl.getDefinitions(); + + List<XpandDefinition> advicedDefinitions = new ArrayList<XpandDefinition>(localDefinitions.length); + + for (int i = 0; i < localDefinitions.length; i++) { + XpandDefinition xpandDefinition = localDefinitions[i]; + for (int x = registeredAdvices.size() - 1; x >= 0; x--) { + final XpandAdvice adv = registeredAdvices.get(x); + if (adv.matches(xpandDefinition, this)) { + xpandDefinition = new AdvicedDefinition(adv, xpandDefinition); + } + } + advicedDefinitions.add(xpandDefinition); + } + + return advicedDefinitions; + + } + + public XpandDefinition findDefinition(final String name, final Type target, final Type[] paramTypes) { + XpandResource tpl = null; + if (name.indexOf(SyntaxConstants.NS_DELIM) != -1) { // local call + tpl = findTemplate(XpandUtil.withoutLastSegment(name)); + } + else { + tpl = (XpandResource) currentResource(); + } + if (tpl == null) + return null; + final XpandExecutionContext ctx = (XpandExecutionContext) cloneWithResource(tpl); + XpandDefinition def = findDefinition(tpl.getDefinitions(), name, target, paramTypes, ctx); + for (int x = registeredAdvices.size() - 1; x >= 0; x--) { + final XpandAdvice adv = registeredAdvices.get(x); + if (adv.matches(def, this)) { + def = new AdvicedDefinition(adv, def); + } + } + return def; + } + + public void registerAdvices(final String fullyQualifiedName) { + final XpandResource tpl = findTemplate(fullyQualifiedName); + if (tpl == null) + throw new NoSuchTemplateException(fullyQualifiedName); + final XpandAdvice[] as = tpl.getAdvices(); + for (int i = 0; i < as.length; i++) { + final XpandAdvice advice = as[i]; + if (registeredAdvices.contains(advice)) { + log.warn("advice " + advice.toString() + " allready registered!"); + } + else { + registeredAdvices.add(advice); + } + } + } + + public ProtectedRegionResolver getProtectedRegionResolver() { + return protectedRegionResolver; + } + + public Output getOutput() { + return output; + } + + public XpandResource findTemplate(final String templateName) { + return findTemplate(templateName, getImportedNamespaces()); + } + + public XpandResource findTemplate(final String templateName, String[] importedNs) { + final List<?> possibleNames = typeSystem.getPossibleNames(templateName, importedNs); + for (final Iterator<?> iter = possibleNames.iterator(); iter.hasNext();) { + final String element = (String) iter.next(); + final XpandResource tpl = (XpandResource) resourceManager.loadResource(element, + XpandUtil.TEMPLATE_EXTENSION); + if (tpl != null) + return tpl; + } + return null; + } + + /** + * resolves the correct definition (using parametric polymorphism) + * + * @param definitions + * @param target + * @param paramTypes + * @return + */ + private XpandDefinition findDefinition(final XpandDefinition[] definitions, final String name, final Type target, + Type[] paramTypes, final XpandExecutionContext ctx) { + if (paramTypes == null) { + paramTypes = new Type[0]; + } + final Set<Callable> features = new HashSet<Callable>(); + for (int i = 0; i < definitions.length; i++) { + final XpandDefinition def = definitions[i]; + if (def.getParams().length == paramTypes.length) { + final List<Type> defsParamTypes = new ArrayList<Type>(); + Type t = null; + boolean complete = true; + for (int j = 0; j < paramTypes.length && complete; j++) { + t = ctx.getTypeForName(def.getParams()[j].getType().getValue()); + if (t == null) { + complete = false; + } + defsParamTypes.add(t); + } + t = ctx.getTypeForName(def.getTargetType()); + if (t == null) { + complete = false; + } + if (complete) { + features.add(new DefinitionOperationAdapter(def, def.getName(), t, defsParamTypes)); + } + } + } + final DefinitionOperationAdapter defAdapter = (DefinitionOperationAdapter) PolymorphicResolver.getOperation( + features, XpandUtil.getLastSegment(name), target, Arrays.asList(paramTypes)); + if (defAdapter != null) + return defAdapter.def; + return null; + } + + public class DefinitionOperationAdapter implements Operation { + + private String name; + + private Type owner; + + private List<Type> paramTypes; + + public XpandDefinition def; + + public DefinitionOperationAdapter(final XpandDefinition def, final String name, final Type owner, + final List<Type> paramTypes) { + this.name = name; + this.owner = owner; + this.paramTypes = paramTypes; + this.def = def; + } + + public String getName() { + return name; + } + + public Type getReturnType() { + throw new UnsupportedOperationException(); + } + + public Type getOwner() { + return owner; + } + + public List<Type> getParameterTypes() { + return paramTypes; + } + + public Object evaluate(final Object target, final Object[] params) { + throw new UnsupportedOperationException(); + } + + public String getDocumentation() { + return "Xpand definition " + getName() + " adapted in an Operation"; + } + + public Type getReturnType(final Type targetType, final Type[] paramTpes) { + return getReturnType(); + } + + } + + @Override + public void setFileEncoding(final String fileEncoding) { + resourceManager.setFileEncoding(fileEncoding); // TODO: make this + // immutable - the + // entire context should + // be immutable! + } + + public void setResourceManager(ResourceManager resourceManager) { + registerParser(resourceManager); + this.resourceManager = resourceManager; + } + + public void setCallBack(Callback callback) { + this.callback = callback; + } +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandFacade.java new file mode 100644 index 00000000..da2e165b --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandFacade.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2; + +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.internal.xpand2.model.XpandDefinition; +import org.eclipse.internal.xpand2.model.XpandResource; +import org.eclipse.xpand2.XpandExecutionContext; +import org.eclipse.xtend.expression.AnalysationIssue; +import org.eclipse.xtend.expression.EvaluationException; +import org.eclipse.xtend.expression.ExecutionContext; +import org.eclipse.xtend.expression.Variable; +import org.eclipse.xtend.typesystem.Type; + +/** + * * + * + * @author Sven Efftinge (http://www.efftinge.de) * + */ +public class XpandFacade { + private XpandExecutionContext ctx = null; + + /** + * @deprecated use XpandFacade.create instead + */ + @Deprecated + public XpandFacade(final XpandExecutionContext ctx) { + this.ctx = ctx; + } + + public void evaluate(final String definitionName, final Object targetObject, Object... params) { + params = params == null ? new Object[0] : params; + final Type targetType = ctx.getType(targetObject); + final Type[] paramTypes = new Type[params.length]; + for (int i = 0; i < paramTypes.length; i++) { + paramTypes[i] = ctx.getType(params[i]); + } + + final XpandDefinition def = ctx.findDefinition(definitionName, targetType, paramTypes); + if (def == null) + throw new EvaluationException("No Definition " + definitionName + getParamString(paramTypes) + " for " + + targetType.getName() + " could be found!", null, ctx); + + ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE, + targetObject)); + for (int i = 0; i < params.length; i++) { + final Variable v = new Variable(def.getParams()[i].getName().getValue(), params[i]); + ctx = (XpandExecutionContext) ctx.cloneWithVariable(v); + } + ctx = (XpandExecutionContext) ctx.cloneWithResource(def.getOwner()); + def.evaluate(ctx); + } + + private String getParamString(final Type[] paramTypes) { + if (paramTypes.length == 0) + return ""; + final StringBuffer buff = new StringBuffer("("); + for (int i = 0; i < paramTypes.length; i++) { + final Type t = paramTypes[i]; + buff.append(t.getName()); + if (i + 1 < paramTypes.length) { + buff.append(","); + } + } + buff.append(")"); + return buff.toString(); + } + + public AnalysationIssue[] analyze(final String templateName) { + final Set<AnalysationIssue> issues = new HashSet<AnalysationIssue>(); + final XpandResource tpl = ctx.findTemplate(templateName); + tpl.analyze(ctx, issues); + return issues.toArray(new AnalysationIssue[issues.size()]); + } + + public static XpandFacade create(XpandExecutionContextImpl execCtx) { + return new XpandFacade(execCtx); + } +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandUtil.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandUtil.java new file mode 100644 index 00000000..3ec00e7f --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandUtil.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2; + +import org.eclipse.internal.xtend.expression.parser.SyntaxConstants; + +/** + * + * @author Sven Efftinge (http://www.efftinge.de) * + */ +public class XpandUtil { + + private static final String SLASH = "/"; + + public static final String NS_DELIM = SyntaxConstants.NS_DELIM; + + public static final String TEMPLATE_EXTENSION = "xpt"; + + public final static String getJavaResourceName(final String fqn) { + return fqn.replaceAll(NS_DELIM, SLASH) + "." + TEMPLATE_EXTENSION; + } + + public static String withoutLastSegment(final String fqn) { + if (fqn == null || fqn.lastIndexOf(SyntaxConstants.NS_DELIM) == -1) + return null; + return fqn.substring(0, fqn.lastIndexOf(SyntaxConstants.NS_DELIM)); + } + + public static String getLastSegment(final String fqn) { + if (fqn == null || fqn.lastIndexOf(SyntaxConstants.NS_DELIM) == -1) + return fqn; + return fqn.substring(fqn.lastIndexOf(SyntaxConstants.NS_DELIM) + SyntaxConstants.NS_DELIM.length()); + } + +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java index 3d8149f6..ce6318df 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractDefinition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; @@ -44,7 +42,8 @@ public abstract class AbstractDefinition extends SyntaxElement implements XpandD protected boolean wildParams = false; - public AbstractDefinition(final Identifier name, final Identifier type, final DeclaredParameter[] params, final Statement[] body) { + public AbstractDefinition(final Identifier name, final Identifier type, final DeclaredParameter[] params, + final Statement[] body) { this.name = name; this.type = type; this.params = params; @@ -99,8 +98,9 @@ public abstract class AbstractDefinition extends SyntaxElement implements XpandD for (int i = 0; i < params.length; i++) { final DeclaredParameter p = params[i]; buff.append(p.getType().getValue()); - if(!typesOnly) + if (!typesOnly) { buff.append(" ").append(p.getName().getValue()); + } if (i + 1 < params.length) { buff.append(","); } @@ -120,59 +120,101 @@ public abstract class AbstractDefinition extends SyntaxElement implements XpandD } public void analyze(XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { - if (getType()==null) { - issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Invalid definition: " + this.toString(), this)); - return; - } - final Type thisType = ctx.getTypeForName(getType().getValue()); - if (thisType == null) { - issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't find " + getType().getValue(), getType())); - } - ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE, thisType)); - for (int i = 0; i < params.length; i++) { - final DeclaredParameter param = params[i]; - Type paramType = ctx.getTypeForName(param.getType().getValue()); - if (paramType == null) { - issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't find " + param.getType().getValue(), param.getType())); - paramType = ctx.getObjectType(); + try { + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + final Type thisType = ctx.getTypeForName(getType().getValue()); + if (thisType == null) { + issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't find " + + getType().getValue(), getType())); + } + ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(ExecutionContext.IMPLICIT_VARIABLE, + thisType)); + for (int i = 0; i < params.length; i++) { + final DeclaredParameter param = params[i]; + Type paramType = ctx.getTypeForName(param.getType().getValue()); + if (paramType == null) { + issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Couldn't find " + + param.getType().getValue(), param.getType())); + paramType = ctx.getObjectType(); + } + final String name = param.getName().getValue(); + ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(name, paramType)); + } + for (int i = 0; i < getBody().length; i++) { + Statement stmt = getBody()[i]; + try { + stmt.analyze(ctx, issues); + } + catch (RuntimeException ex) { + Map<String, Object> info = new HashMap<String, Object>(); + info.put("body", stmt); + ctx.handleRuntimeException(ex, this, info); + } } - final String name = param.getName().getValue(); - ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable(name, paramType)); } - for (int i = 0; i < getBody().length; i++) { - Statement stmt = getBody()[i]; - try { - stmt.analyze(ctx, issues); - } catch (RuntimeException ex) { - Map<String, Object> info = new HashMap<String, Object>(); - info.put("body", stmt); - ctx.handleRuntimeException(ex, this, info); + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(null); } } } public void evaluate(XpandExecutionContext ctx) { - ctx = (XpandExecutionContext) ctx.cloneWithResource(getOwner()); - for (int i = 0; i < getBody().length; i++) { - Statement stmt = getBody()[i]; - try { - stmt.evaluate(ctx); - } catch (RuntimeException ex) { - Map<String, Object> info = new HashMap<String, Object>(); - info.put("body", stmt); - ctx.handleRuntimeException(ex, this, info); + try { + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + ctx = (XpandExecutionContext) ctx.cloneWithResource(getOwner()); + for (int i = 0; i < getBody().length; i++) { + Statement stmt = getBody()[i]; + try { + stmt.evaluate(ctx); + } + catch (RuntimeException ex) { + Map<String, Object> info = new HashMap<String, Object>(); + info.put("body", stmt); + ctx.handleRuntimeException(ex, this, info); + } + } + } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(null); } } } @Override public String toString() { - String type = getType()!=null ? getType().getValue() : "null"; if (_stringRepresentation == null) { - _stringRepresentation = name.getValue() + getParamString(false) + " : " + type; + _stringRepresentation = name.getValue() + getParamString(false) + " : " + getType().getValue(); } return _stringRepresentation; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((toString() == null) ? 0 : toString().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null || toString() == null) + return false; + + if (getClass() != obj.getClass()) + return false; + + AbstractDefinition other = (AbstractDefinition) obj; + return toString().equals(other.toString()); + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java new file mode 100644 index 00000000..e5b45ff9 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/AbstractXpandVisitor.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xpand2.ast; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.internal.xtend.expression.ast.AbstractVisitor; +import org.eclipse.internal.xtend.expression.ast.ISyntaxElement; +import org.eclipse.internal.xtend.expression.ast.SyntaxElement; + +public class AbstractXpandVisitor extends AbstractVisitor { + + @Override + public final Object visit(final ISyntaxElement ele) { + Object result = null; + + if (result == null && ele instanceof Advice) { + result = visitAdvice((Advice) ele); + } + if (result == null && ele instanceof Definition) { + result = visitDefinition((Definition) ele); + } + if (result == null && ele instanceof ErrorStatement) { + result = visitErrorStatement((ErrorStatement) ele); + } + if (result == null && ele instanceof ExpandStatement) { + result = visitExpandStatement((ExpandStatement) ele); + } + if (result == null && ele instanceof ExpressionStatement) { + result = visitExpressionStatement((ExpressionStatement) ele); + } + if (result == null && ele instanceof FileStatement) { + result = visitFileStatement((FileStatement) ele); + } + if (result == null && ele instanceof ForEachStatement) { + result = visitForEachStatement((ForEachStatement) ele); + } + if (result == null && ele instanceof IfStatement) { + result = visitIfStatement((IfStatement) ele); + } + if (result == null && ele instanceof ImportDeclaration) { + result = visitImportDeclaration((ImportDeclaration) ele); + } + if (result == null && ele instanceof LetStatement) { + result = visitLetStatement((LetStatement) ele); + } + if (result == null && ele instanceof ProtectStatement) { + result = visitProtectStatement((ProtectStatement) ele); + } + if (result == null && ele instanceof Template) { + result = visitTemplate((Template) ele); + } + if (result == null && ele instanceof TextStatement) { + result = visitTextStatement((TextStatement) ele); + } + return result; + } + + protected void visitChild(final SyntaxElement child) { + if(child != null) + child.accept(this); + } + + protected void visitChildren(final List<? extends SyntaxElement> children) { + if (children != null) { + for (SyntaxElement child : children) { + visitChild(child); + } + } + } + + protected Object visitAdvice(Advice node) { + visitChildren(node.getBodyAsList()); + return node; + } + + protected Object visitDefinition(Definition node) { + visitChildren(node.getBodyAsList()); + return node; + } + + protected Object visitErrorStatement(ErrorStatement node) { + return node; + } + + protected Object visitExpandStatement(ExpandStatement node) { + return node; + } + + protected Object visitExpressionStatement(ExpressionStatement node) { + return node; + } + + protected Object visitFileStatement(FileStatement node) { + visitChildren(node.getBodyAsList()); + return node; + } + + protected Object visitForEachStatement(ForEachStatement node) { + visitChildren(node.getBodyAsList()); + return node; + } + + protected Object visitIfStatement(IfStatement node) { + visitChildren(node.getBodyAsList()); + visitChild(node.getElseIf()); + return node; + } + + protected Object visitImportDeclaration(ImportDeclaration node) { + return node; + } + + protected Object visitLetStatement(LetStatement node) { + visitChildren(node.getBodyAsList()); + return node; + } + + protected Object visitProtectStatement(ProtectStatement node) { + visitChildren(node.getBodyAsList()); + return node; + } + + protected Object visitTemplate(Template node) { + visitChildren(Arrays.asList(node.getAllDefinitions())); + return node; + } + + protected Object visitTextStatement(TextStatement node) { + return node; + } +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java index d48f0944..8b52bfa0 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Advice.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Definition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Definition.java index d309bbcf..6ac19e20 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Definition.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Definition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java index 8cefac52..c7e3b6da 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ErrorStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; @@ -24,23 +22,29 @@ import org.eclipse.xtend.expression.AnalysationIssue; */ public class ErrorStatement extends Statement { - private Expression message; - - public ErrorStatement( final Expression msg) { - message = msg; - } - - public Expression getMessage() { - return message; - } - - public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { - message.analyze(ctx, issues); - } - - @Override - public void evaluateInternal(final XpandExecutionContext ctx) { - System.err.println(message.evaluate(ctx)); - } + private final Expression message; + + public ErrorStatement(final Expression msg) { + message = msg; + } + + @Override + public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { + if (message != null) { + message.analyze(ctx, issues); + } + else { + issues.add(new AnalysationIssue(AnalysationIssue.SYNTAX_ERROR, "Error message required", this)); + } + } + + @Override + public void evaluateInternal(final XpandExecutionContext ctx) { + System.err.println(message.evaluate(ctx)); + } + + public Expression getMessage() { + return message; + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpandStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpandStatement.java index b4d5dc43..930ce0f2 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpandStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpandStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; @@ -80,7 +78,6 @@ public class ExpandStatement extends Statement { return target; } - @Override public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type[] paramTypes = new Type[getParameters().length]; for (int i = 0; i < getParameters().length; i++) { diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpressionStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpressionStatement.java index 15ae2ea6..b864ef25 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpressionStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ExpressionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java index a1a3de46..af727cde 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/FileStatement.java @@ -1,21 +1,22 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.eclipse.internal.xtend.expression.ast.Expression; import org.eclipse.internal.xtend.expression.ast.Identifier; import org.eclipse.xpand2.XpandExecutionContext; +import org.eclipse.xpand2.output.VetoException; import org.eclipse.xtend.expression.AnalysationIssue; import org.eclipse.xtend.expression.EvaluationException; import org.eclipse.xtend.expression.ExecutionContext; @@ -28,66 +29,76 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * */ public class FileStatement extends StatementWithBody { + private static final Log LOG = LogFactory.getLog(FileStatement.class); + + private Expression fileNameExpression; + + private Identifier outletNameIdentifier; + + public FileStatement(final Expression fileName, final Statement[] body, final Identifier mode) { + super(body); + this.fileNameExpression = fileName; + this.outletNameIdentifier = mode; + } + + public Expression getTargetFileName() { + return fileNameExpression; + } + + public Identifier getMode() { + return outletNameIdentifier; + } + + public String getOutletName() { + if (outletNameIdentifier == null) + return null; + return outletNameIdentifier.getValue(); + } - private Expression fileNameExpression; - - private Identifier outletNameIdentifier; - - public FileStatement(final Expression fileName, - final Statement[] body, final Identifier mode) { - super(body); - this.fileNameExpression = fileName; - this.outletNameIdentifier = mode; - } - - public Expression getTargetFileName() { - return fileNameExpression; - } - - public Identifier getMode() { - return outletNameIdentifier; - } - - public String getOutletName () { - if (outletNameIdentifier == null) - return null; - return outletNameIdentifier.getValue(); - } - - @Override - public void analyzeInternal(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { - final Type result = getTargetFileName().analyze(ctx, issues); - if (!ctx.getStringType().isAssignableFrom(result)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "String expected!", - getTargetFileName())); - } - for (int i = 0; i < body.length; i++) { - body[i].analyze(ctx, issues); - } - } - - @Override - public void evaluateInternal(XpandExecutionContext ctx) { - final Object result = getTargetFileName().evaluate(ctx); - if (result == null) - throw new EvaluationException("Nullevaluation", getTargetFileName(), ctx); - final String fileName = result.toString(); - final String outletName = getOutletName(); - - ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable("FILENAME", fileName)); - ctx.getOutput().openFile(fileName, outletName); - for (int i = 0; i < body.length; i++) { - body[i].evaluate(ctx); - } - ctx.getOutput().closeFile(); - } - @Override - public String getNameString(ExecutionContext context) { - return "FILE"; + public void analyzeInternal(XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { + final Type result = getTargetFileName().analyze(ctx, issues); + ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable("FILENAME", result)); + if (!ctx.getStringType().isAssignableFrom(result)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "String expected!", + getTargetFileName())); + } + for (int i = 0; i < body.length; i++) { + body[i].analyze(ctx, issues); + } } -} + @Override + public void evaluateInternal(XpandExecutionContext ctx) { + final Object result = getFilename(ctx); + String fileName = result.toString(); + final String outletName = getOutletName(); + + ctx = (XpandExecutionContext) ctx.cloneWithVariable(new Variable("FILENAME", result)); + try { + ctx.getOutput().openFile(fileName, outletName); + for (int i = 0; i < body.length; i++) { + body[i].evaluate(ctx); + } + ctx.getOutput().closeFile(); + } + catch (VetoException e) { + if (LOG.isDebugEnabled()) { + LOG.debug("Generation of file '" + fileName + "' on outlet '" + outletName + "' skipped due to veto."); + } + } + } + @Override + public String getNameString(ExecutionContext context) { + return "FILE"; + } + private Object getFilename(XpandExecutionContext ctx) { + final Object result = getTargetFileName().evaluate(ctx); + if (result == null) + throw new EvaluationException("Nullevaluation", getTargetFileName(), ctx); + return result; + } +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java index 97633196..15665022 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ForEachStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java index 657d0707..ba98afd7 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/IfStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ImportDeclaration.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ImportDeclaration.java index 4cab29ff..2c1efde9 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ImportDeclaration.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ImportDeclaration.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/LetStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/LetStatement.java index abd81d66..db8d0723 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/LetStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/LetStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java index 525b44a5..4c9e14dc 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/ProtectStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java index e65600a9..05e59db0 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Statement.java @@ -1,58 +1,85 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; import java.util.Set; +import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; import org.eclipse.internal.xtend.expression.ast.SyntaxElement; import org.eclipse.xpand2.XpandExecutionContext; import org.eclipse.xtend.expression.AnalysationIssue; public abstract class Statement extends SyntaxElement implements XpandAnalyzable, XpandEvaluatable { - - protected AbstractDefinition containingDefinition; - - public Statement() { - } - - public final void evaluate(final XpandExecutionContext ctx) { - try { - ctx.getOutput().pushStatement(this,ctx); - ctx.preTask(this); - evaluateInternal(ctx); - ctx.postTask(this); - ctx.getOutput().popStatement(); - } catch (RuntimeException exc) { - ctx.handleRuntimeException(exc, this, null); - } - } - - public void analyze(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { + + protected AbstractDefinition containingDefinition; + + public Statement() { + } + + public final void evaluate(final XpandExecutionContext ctx) { try { + ProgressMonitor monitor = ctx.getMonitor(); + if (monitor != null && monitor.isCanceled()) + return; + + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + ctx.getOutput().pushStatement(this, ctx); + ctx.preTask(this); + evaluateInternal(ctx); + ctx.postTask(this); + ctx.getOutput().popStatement(); + } + catch (final RuntimeException exc) { + ctx.handleRuntimeException(exc, this, null); + } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(null); + } + } + } + + public void analyze(final XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { + try { + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } analyzeInternal(ctx, issues); - } catch (RuntimeException ex) { - ctx.handleRuntimeException(ex, this, null); } - } - - protected abstract void evaluateInternal(XpandExecutionContext ctx); - protected abstract void analyzeInternal(XpandExecutionContext ctx, final Set<AnalysationIssue> issues); + catch (final RuntimeException ex) { + final String message = ex.getMessage(); + if (message != null) { + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, ex.getMessage(), this)); + } + else + throw ex; + } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(null); + } + } + } + + protected abstract void evaluateInternal(XpandExecutionContext ctx); + + protected abstract void analyzeInternal(XpandExecutionContext ctx, final Set<AnalysationIssue> issues); public AbstractDefinition getContainingDefinition() { return containingDefinition; } - public void setContainingDefinition(AbstractDefinition definition) { + public void setContainingDefinition(final AbstractDefinition definition) { this.containingDefinition = definition; } - + } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/StatementWithBody.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/StatementWithBody.java index a66d594f..3bfbb042 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/StatementWithBody.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/StatementWithBody.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java index 6c3fde78..da7cd666 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/Template.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; @@ -15,6 +13,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -62,8 +62,8 @@ public class Template extends SyntaxElement implements XpandResource { this.fullyQualifiedName = fullyQualifiedName; } - public Template(final ImportDeclaration[] imports, - final ImportDeclaration[] extensions, final Definition[] definitions, final Advice[] advices) { + public Template(final ImportDeclaration[] imports, final ImportDeclaration[] extensions, + final Definition[] definitions, final Advice[] advices) { this.imports = imports; this.extensions = extensions; for (int i = 0; i < definitions.length; i++) { @@ -93,7 +93,8 @@ public class Template extends SyntaxElement implements XpandResource { public int compare(SyntaxElement o1, SyntaxElement o2) { return new Integer(o1.getStart()).compareTo(o2.getStart()); - }}); + } + }); return l.toArray(new AbstractDefinition[l.size()]); } @@ -110,16 +111,27 @@ public class Template extends SyntaxElement implements XpandResource { public void analyze(XpandExecutionContext ctx, final Set<AnalysationIssue> issues) { try { ctx = (XpandExecutionContext) ctx.cloneWithResource(this); + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + + checkDuplicateDefinitions(issues); for (int i = 0; i < definitions.length; i++) { definitions[i].analyze(ctx, issues); } for (int i = 0; i < advices.length; i++) { advices[i].analyze(ctx, issues); } - } catch (RuntimeException ex) { - ctx.handleRuntimeException(ex, this, null); } + catch (RuntimeException ex) { + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, ex.getMessage(), this)); } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(null); + } + } + } public XpandDefinition[] getDefinitionsByName(final String aName) { final List<Definition> defs = new ArrayList<Definition>(); @@ -137,12 +149,15 @@ public class Template extends SyntaxElement implements XpandResource { final List<String> l = new ArrayList<String>(); final String thisNs = XpandUtil.withoutLastSegment(getFullyQualifiedName()); - if (thisNs != null) - l.add(thisNs); for (int i = 0; i < getImports().length; i++) { final ImportDeclaration anImport = getImports()[i]; l.add(anImport.getImportString().getValue()); } + + if (thisNs != null) { + l.add(thisNs); + } + commonPrefixes = l.toArray(new String[l.size()]); } return commonPrefixes; @@ -170,4 +185,26 @@ public class Template extends SyntaxElement implements XpandResource { return advices; } + private void checkDuplicateDefinitions(Set<AnalysationIssue> issues) { + Set<Definition> definitionSet = new HashSet<Definition>(); + for (Definition def : definitions) { + if (!definitionSet.contains(def)) { + definitionSet.add(def); + } + else { + Definition origDef = null; + for (Iterator<Definition> it = definitionSet.iterator(); it.hasNext();) { + Definition d = it.next(); + if (d.equals(def)) { + origDef = d; + break; + } + } + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Duplicate definition '" + + def.getName() + "'", def)); + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Duplicate definition '" + + origDef.getName() + "'", origDef)); + } + } + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/TextStatement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/TextStatement.java index be927896..5ccb6993 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/TextStatement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/TextStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandAnalyzable.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandAnalyzable.java index 2bac2451..c3aa13da 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandAnalyzable.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandAnalyzable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandEvaluatable.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandEvaluatable.java index 69b40705..81aa4d92 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandEvaluatable.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/XpandEvaluatable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.ast; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/package.html new file mode 100644 index 00000000..41417b98 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/ast/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +AST of the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/ExpandProposalComputer.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/ExpandProposalComputer.java index c0402432..ac7cc08e 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/ExpandProposalComputer.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/ExpandProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/FastAnalyzer.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/FastAnalyzer.java index a5775eea..5eddc229 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/FastAnalyzer.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/FastAnalyzer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/KeywordProposalComputer.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/KeywordProposalComputer.java index c9a4981e..5f5eeaba 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/KeywordProposalComputer.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/KeywordProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/LazyVar.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/LazyVar.java index 3d290ff5..0e2312bf 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/LazyVar.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/LazyVar.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/NamespaceProposalComputer.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/NamespaceProposalComputer.java index fe775810..944b16db 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/NamespaceProposalComputer.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/NamespaceProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StackElement.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StackElement.java index 2316bf91..a49dd681 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StackElement.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StackElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StatementProposalComputer.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StatementProposalComputer.java index 2487f3bb..131b09d3 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StatementProposalComputer.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/StatementProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandPartition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandPartition.java index 819f8a68..c3688cb5 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandPartition.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandPartition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandTokens.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandTokens.java index 46a7217e..b2d6015d 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandTokens.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/XpandTokens.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.codeassist; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/package.html new file mode 100644 index 00000000..2c5f475d --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/codeassist/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Codeassist for the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ExpandSpecial.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ExpandSpecial.java index 3b7d6140..5b93eb89 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ExpandSpecial.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ExpandSpecial.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.debug; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ForEachSpecial.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ForEachSpecial.java index fb453fb4..16140777 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ForEachSpecial.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/ForEachSpecial.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.debug; @@ -21,38 +19,52 @@ import org.eclipse.xtend.expression.ExecutionContext; * Adapter to handle FOREACH statement special stuff. * * @author Clemens Kadura (zAJKa) + * @author Jan Köhnlein */ public class ForEachSpecial extends BaseSpecialTreatment { - private ForEachStatement lastForEach; - - // ------------------------------------------------------------------------- + private ForEachStatement lastForEachInAdaptSyntaxElementTO; + private ForEachStatement lastForEachInShallSuspend; + int iterationCounter; /** - * A ForEachStatement calls monitor.preTask() always twice. First time for the (outer) statement and 2nd time - * for each loop. We disable suspension the first time. + * A ForEachStatement calls monitor.preTask() always twice. First time for + * the (outer) statement and 2nd time for each loop. We disable suspension + * the first time. * - * @see org.eclipse.internal.xtend.expression.debug.BaseSpecialTreatment#shallNotSuspend(java.lang.Object, int) + * @see org.eclipse.internal.xtend.expression.debug.BaseSpecialTreatment#shallNotSuspend(java.lang.Object, + * int) */ @Override public boolean shallNotSuspend(Object element, int flag, ExecutionContext ctx) { - // in the outer loop the iterator is null, so we don't suspend - return element instanceof ForEachStatement; // && ((ForEachStatement) element).getIterator() == null; + if (element instanceof ForEachStatement) { + if (element.equals(lastForEachInShallSuspend)) + return false; + lastForEachInShallSuspend = (ForEachStatement) element; + iterationCounter = 0; + return true; + } + return false; } /** - * Don't show frame in Launch view, if the ForEachStatement is the 1st time in the stack. + * Don't show frame in Launch view, if the ForEachStatement is the 1st time + * in the stack. * * @see org.eclipse.internal.xtend.expression.debug.BaseSpecialTreatment#adaptSyntaxElement(org.eclipse.emf.mwe.core.debug.model.SyntaxElement, * java.lang.Object) */ @Override public void adaptSyntaxElement(SyntaxElement to, Object element) { - if (element instanceof ForEachStatement) - if (!element.equals(lastForEach)) { + if (element instanceof ForEachStatement) { + if (!element.equals(lastForEachInAdaptSyntaxElementTO)) { to.visible = false; - lastForEach = (ForEachStatement) element; + lastForEachInAdaptSyntaxElementTO = (ForEachStatement) element; } + else { + to.elementName = to.elementName + " #" + (iterationCounter++); + } + } } @Override @@ -60,9 +72,10 @@ public class ForEachSpecial extends BaseSpecialTreatment { if (se instanceof ForEachStatement) { String name = "FOREACH"; // add counter to the FOREACH name - XpandIterator it = null; //((ForEachStatement) se).getIterator(); + XpandIterator it = null; // ((ForEachStatement) se).getIterator(); if (it != null) - // Hint: We can ignore it == null (the outer call), since it isn't visible anyway + // Hint: We can ignore it == null (the outer call), since it + // isn't visible anyway return name + " " + it.counter1() + " of " + it.elements(); } return ""; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/IfSpecial.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/IfSpecial.java index 26e1a956..4cf1721a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/IfSpecial.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/IfSpecial.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.debug; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandElementAdapter.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandElementAdapter.java index d2a4925a..0a2921f0 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandElementAdapter.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandElementAdapter.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.debug; @@ -28,6 +26,7 @@ import org.eclipse.internal.xtend.expression.debug.NoResourceSpecial; */ public class XpandElementAdapter extends ExpressionElementAdapter { + @SuppressWarnings("hiding") public static final String TYPE = "xpand"; // ------------------------------------------------------------------------- @@ -86,19 +85,18 @@ public class XpandElementAdapter extends ExpressionElementAdapter { @Override public List<NameValuePair> getVariables(Object element) { - + // Beispiel wie inspect implementiert werden kann (hat hier nichts zu // suchen, nur als Gedankenstütze CK) // ExpressionFacade ef = new ExpressionFacade(getCtx()); // Object evaluate = ef.evaluate(""); // getAllPropertiesFor(getCtx().getType(evaluate), evaluate); - - if (element instanceof Statement) { + + if (element instanceof Statement) return getAllVisibleVariables(); - } return super.getVariables(element); } - + @Override public Object findElement(SyntaxElement se, Object actual, int flag) { if (actual == null) @@ -109,7 +107,7 @@ public class XpandElementAdapter extends ExpressionElementAdapter { if (se.resource.endsWith(pres.getStringRep(op.getFileName())) && se.start == start) return actual; } - return super.findElement(se,actual, flag); + return super.findElement(se, actual, flag); } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandModelPresentation.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandModelPresentation.java index 3ed72ce4..811f11de 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandModelPresentation.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/XpandModelPresentation.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.debug; @@ -32,7 +30,8 @@ import org.eclipse.internal.xtend.expression.debug.ExpressionModelPresentation; import org.eclipse.xtend.expression.ExecutionContext; /** - * This class is responsible for all presentation topics for Xpand statements in the debugger views. + * This class is responsible for all presentation topics for Xpand statements in + * the debugger views. * * @author Clemens Kadura (zAJKa) */ @@ -97,7 +96,8 @@ public class XpandModelPresentation extends ExpressionModelPresentation { to.resource = getResource(se); to.start = getEndStartPosition(se); to.end = se.getEnd(); - to.line = se.getLine();// TODO: Known issue: "last line" is not stored. How to calculate it? + to.line = se.getLine();// TODO: Known issue: "last line" is not stored. + // How to calculate it? return to; } @@ -107,11 +107,17 @@ public class XpandModelPresentation extends ExpressionModelPresentation { @Override protected String getContainerName(ISyntaxElement se) { XpandDefinition def; - if (se instanceof XpandDefinition) + if (se instanceof XpandDefinition) { def = (XpandDefinition) se; - else + } + else { def = ((Statement) se).getContainingDefinition(); + } + + if (def != null) return getTemplateName(se) + "::" + getDefinitionName(def); + + return ""; } private String getDefinitionName(XpandDefinition def) { diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/package.html new file mode 100644 index 00000000..34d07887 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/debug/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Debug support for the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java index af79ea72..36c32ca9 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/AdvicedDefinition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.model; @@ -14,6 +12,7 @@ import java.util.Set; import org.eclipse.internal.xpand2.ast.Advice; import org.eclipse.internal.xpand2.type.XpandDefinitionImpl; +import org.eclipse.internal.xtend.expression.ast.AbstractVisitor; import org.eclipse.internal.xtend.expression.ast.DeclaredParameter; import org.eclipse.xpand2.XpandExecutionContext; import org.eclipse.xtend.expression.AnalysationIssue; @@ -22,30 +21,30 @@ import org.eclipse.xtend.expression.Variable; public class AdvicedDefinition implements XpandDefinition { - private XpandAdvice advice; + private XpandAdvice advice; - private XpandDefinition definition; + private XpandDefinition definition; - public AdvicedDefinition(final XpandAdvice adv, final XpandDefinition def) { - advice = adv; - definition = def; - } + public AdvicedDefinition(final XpandAdvice adv, final XpandDefinition def) { + advice = adv; + definition = def; + } - public XpandResource getOwner() { - return definition.getOwner(); - } + public XpandResource getOwner() { + return definition.getOwner(); + } - public DeclaredParameter[] getParams() { - return definition.getParams(); - } + public DeclaredParameter[] getParams() { + return definition.getParams(); + } - public String getTargetType() { - return definition.getTargetType(); - } + public String getTargetType() { + return definition.getTargetType(); + } - public String getName() { - return "AROUND " + definition.getName(); - } + public String getName() { + return "AROUND " + definition.getName(); + } public String getQualifiedName() { return definition.getQualifiedName(); @@ -60,15 +59,15 @@ public class AdvicedDefinition implements XpandDefinition { } public void evaluate(final XpandExecutionContext ctx) { - final XpandExecutionContext ctx1 = (XpandExecutionContext) ctx.cloneWithVariable(new Variable( - Advice.DEF_VAR_NAME, new XpandDefinitionImpl(definition, ctx))); - advice.evaluate(ctx1); - } - - public int getLine() { - return advice.getLine(); - } - + final XpandExecutionContext ctx1 = (XpandExecutionContext) ctx.cloneWithVariable(new Variable( + Advice.DEF_VAR_NAME, new XpandDefinitionImpl(definition, ctx))); + advice.evaluate(ctx1); + } + + public int getLine() { + return advice.getLine(); + } + public int getEnd() { return advice.getEnd(); } @@ -76,18 +75,21 @@ public class AdvicedDefinition implements XpandDefinition { public int getStart() { return advice.getStart(); } - + public String getFileName() { return advice.getFileName(); } - public String getNameString(ExecutionContext context){ + public String getNameString(ExecutionContext context) { return advice.getNameString(context); } - @Override - public String toString() { - return definition.toString() + " adviced by " + advice.toString(); - } + @Override + public String toString() { + return definition.toString() + " adviced by " + advice.toString(); + } + public final Object accept(final AbstractVisitor visitor) { + return visitor.visit(this); + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/Procedure.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/Procedure.java index b9ebe61c..add6c858 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/Procedure.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/Procedure.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.model; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandAdvice.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandAdvice.java index 4565a8c6..486c0b35 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandAdvice.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandAdvice.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.model; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandDefinition.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandDefinition.java index 1592a8df..e79d615e 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandDefinition.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandDefinition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.model; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandResource.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandResource.java index 5b935eaa..ef9110da 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandResource.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/XpandResource.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.model; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/package.html new file mode 100644 index 00000000..5e205b7e --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/model/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Basic abstractions of the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/package.html new file mode 100644 index 00000000..08b9f27d --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandFactory.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandFactory.java index 2cf9f317..c9a347c0 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandFactory.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandFactory.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.parser; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLexer.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLexer.java index 709d6092..c3ff1036 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLexer.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLexer.java @@ -1,14 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ -// $ANTLR 3.0 ../core.xpand2/main/src/org/openarchitectureware/xpand2/parser/Xpand.g 2007-08-13 15:51:05 package org.eclipse.internal.xpand2.parser; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLocationAddingParser.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLocationAddingParser.java index 4651bdd8..5210333e 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLocationAddingParser.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandLocationAddingParser.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.parser; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java index 5dd9216f..7e0712ae 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParseFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.parser; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParser.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParser.java index f2ab2f6b..d113d62a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParser.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/XpandParser.java @@ -1,14 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ -// $ANTLR 3.0 ../core.xpand2/main/src/org/openarchitectureware/xpand2/parser/Xpand.g 2007-08-13 15:51:04 package org.eclipse.internal.xpand2.parser; @@ -4565,7 +4562,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 1 : - input.LA(1); + int LA30_48 = input.LA(1); int index30_48 = input.index(); @@ -4580,7 +4577,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 2 : - input.LA(1); + int LA30_39 = input.LA(1); int index30_39 = input.index(); @@ -4595,7 +4592,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 3 : - input.LA(1); + int LA30_42 = input.LA(1); int index30_42 = input.index(); @@ -4610,7 +4607,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 4 : - input.LA(1); + int LA30_44 = input.LA(1); int index30_44 = input.index(); @@ -4625,7 +4622,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 5 : - input.LA(1); + int LA30_35 = input.LA(1); int index30_35 = input.index(); @@ -4640,7 +4637,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 6 : - input.LA(1); + int LA30_43 = input.LA(1); int index30_43 = input.index(); @@ -4655,7 +4652,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 7 : - input.LA(1); + int LA30_11 = input.LA(1); int index30_11 = input.index(); @@ -4670,7 +4667,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 8 : - input.LA(1); + int LA30_28 = input.LA(1); int index30_28 = input.index(); @@ -4685,7 +4682,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 9 : - input.LA(1); + int LA30_29 = input.LA(1); int index30_29 = input.index(); @@ -4700,7 +4697,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 10 : - input.LA(1); + int LA30_33 = input.LA(1); int index30_33 = input.index(); @@ -4715,7 +4712,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 11 : - input.LA(1); + int LA30_30 = input.LA(1); int index30_30 = input.index(); @@ -4730,7 +4727,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 12 : - input.LA(1); + int LA30_34 = input.LA(1); int index30_34 = input.index(); @@ -4745,7 +4742,7 @@ public class XpandParser extends Parser { if ( s>=0 ) return s; break; case 13 : - input.LA(1); + int LA30_36 = input.LA(1); int index30_36 = input.index(); diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/package.html new file mode 100644 index 00000000..13c93903 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/parser/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Parser for the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegion.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegion.java index ef589df0..f81f6f99 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegion.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegion.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolver.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolver.java index bcdd43a7..a9019ccd 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolver.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolver.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java index 03256f8c..1981d4c1 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionResolverImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr; @@ -34,87 +32,89 @@ import org.eclipse.internal.xpand2.pr.util.FSIO; import org.eclipse.internal.xpand2.pr.util.GenericFileFilter; /** - * Default implementation of the {@link ProtectedRegionResolver} interface. + * Default implementation of the {@link ProtectedRegionResolver} interface. */ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver { + private static final Log LOG = LogFactory.getLog(ProtectedRegionResolverImpl.class); - private static final String ENABLED = "ENABLED"; + private static final String ENABLED = "ENABLED"; - public static class ProtectedRegionImpl implements ProtectedRegion { - private SoftReference<String> body; + public static class ProtectedRegionImpl implements ProtectedRegion { + private SoftReference<String> body; - private String fileEncoding; + private String fileEncoding; - private int endIndex; + private int endIndex; - private File file; + private File file; - private String id; + private String id; - private int startIndex; + private int startIndex; - private boolean disabled = true; + private boolean disabled = true; - private boolean useBASE64; + private boolean useBASE64; - public ProtectedRegionImpl(final String id, final boolean disabled, final File file, final String fileEncoding, - final boolean useBASE64, final int startIndex, final int endIndex, final String body) { - this.id = id; - this.disabled = disabled; + public ProtectedRegionImpl(final String id, final boolean disabled, final File file, final String fileEncoding, + final boolean useBASE64, final int startIndex, final int endIndex, final String body) { + this.id = id; + this.disabled = disabled; - this.file = file; - this.fileEncoding = fileEncoding; - this.useBASE64 = useBASE64; - this.startIndex = startIndex; - this.endIndex = endIndex; + this.file = file; + this.fileEncoding = fileEncoding; + this.useBASE64 = useBASE64; + this.startIndex = startIndex; + this.endIndex = endIndex; - this.body = new SoftReference<String>(body); - } + this.body = new SoftReference<String>(body); + } - public void setBody(final String body) { - this.body = new SoftReference<String>(body); - } + public void setBody(final String body) { + this.body = new SoftReference<String>(body); + } - public String getBody(final String startComment, final String endComment) throws ProtectedRegionSyntaxException { - String body = this.body.get(); + public String getBody(final String startComment, final String endComment) throws ProtectedRegionSyntaxException { + String body = this.body.get(); - if (body == null) { - try { - body = FSIO.readSingleFile(file, fileEncoding).substring(startIndex, endIndex); - } catch (final IOException e) { - throw new RuntimeException("Unexpected I/O exception (source files removed?)", e); - } - } + if (body == null) { + try { + body = FSIO.readSingleFile(file, fileEncoding).substring(startIndex, endIndex); + } + catch (final IOException e) { + throw new RuntimeException("Unexpected I/O exception (source files removed?)", e); + } + } - final int endCommentIndex = body.indexOf(endComment); + final int endCommentIndex = body.indexOf(endComment); - if ((endCommentIndex < 0) || (body.substring(0, endCommentIndex).trim().length() > 0)) - throw new ProtectedRegionSyntaxException("Start of protected region " + id - + " does not end with comment " + endComment); + if ((endCommentIndex < 0) || (body.substring(0, endCommentIndex).trim().length() > 0)) + throw new ProtectedRegionSyntaxException("Start of protected region " + id + + " does not end with comment " + endComment); - final int startCommentIndex = body.lastIndexOf(startComment); + final int startCommentIndex = body.lastIndexOf(startComment); - if ((startCommentIndex < 0) - || (body.substring(startCommentIndex + startComment.length()).trim().length() > 0)) - throw new ProtectedRegionSyntaxException("End of protected region " + id - + " does not start with comment " + startComment); + if ((startCommentIndex < 0) + || (body.substring(startCommentIndex + startComment.length()).trim().length() > 0)) + throw new ProtectedRegionSyntaxException("End of protected region " + id + + " does not start with comment " + startComment); - return body.substring(endCommentIndex + endComment.length(), startCommentIndex); - } + return body.substring(endCommentIndex + endComment.length(), startCommentIndex); + } + + public String getEndString(final String startComment, final String endComment) { + return startComment + PROTECT_END + endComment; + } - public String getEndString(final String startComment, final String endComment) { - return startComment + PROTECT_END + endComment; - } + public File getFile() { + return file; + } - public File getFile() { - return file; - } + public String getId() { + return id; + } - public String getId() { - return id; - } - - public String getFileEncoding() { + public String getFileEncoding() { return fileEncoding; } @@ -135,338 +135,373 @@ public class ProtectedRegionResolverImpl implements ProtectedRegionResolver { } public String getStartString(final String startComment, final String endComment) { - if (useBASE64) { - try { - return (startComment + PROTECT_BEGIN + PROTECT_B64_BEFORE_ID + BASE64.toString(id) - + PROTECT_B64_AFTER_ID + " " + (!disabled ? ENABLED + " " : "") + PROTECT_START_END + endComment); - } catch (final IOException ie) { - // fallback to old style if BASE64Encoder fails - } - } + if (useBASE64) { + try { + return (startComment + PROTECT_BEGIN + PROTECT_B64_BEFORE_ID + BASE64.toString(id) + + PROTECT_B64_AFTER_ID + " " + (!disabled ? ENABLED + " " : "") + PROTECT_START_END + endComment); + } + catch (final IOException ie) { + // fallback to old style if BASE64Encoder fails + } + } + + return (startComment + PROTECT_BEGIN + PROTECT_BEFORE_ID + id + PROTECT_AFTER_ID + " " + + (!disabled ? ENABLED + " " : "") + PROTECT_START_END + endComment); + } + + } + + private static final String PROTECT_AFTER_ID = ")"; + + private static final String PROTECT_B64_AFTER_ID = "]"; + + private static final String PROTECT_B64_BEFORE_ID = "["; + + private static final String PROTECT_BEFORE_ID = "("; + + private static final String PROTECT_BEGIN = "PROTECTED REGION ID"; + + private static final String PROTECT_END = "PROTECTED REGION END"; + + private static final String PROTECT_START_END = "START"; + + private final Log log = LogFactory.getLog(getClass()); + + private File[] srcPaths = null; + + private boolean defaultExcludes = true; - return (startComment + PROTECT_BEGIN + PROTECT_BEFORE_ID + id + PROTECT_AFTER_ID + " " - + (!disabled ? ENABLED + " " : "") + PROTECT_START_END + endComment); - } + protected boolean useBASE64 = false; - } + protected String encoding; - private static final String PROTECT_AFTER_ID = ")"; + private String ignoreList = null; - private static final String PROTECT_B64_AFTER_ID = "]"; + /** + * This map stores all scanned protected regions. + * <p> + * Key: Protected Region ID<br> + * Value: The Protected Region + */ + private Map<String, ProtectedRegionImpl> regionMap = null; - private static final String PROTECT_B64_BEFORE_ID = "["; + /** + * All already queried Protected Region Ids. Is used for detecting ambigious + * usage of Protected Regions. + */ + private Set<String> usedSet = null; - private static final String PROTECT_BEFORE_ID = "("; + /** + * Retrieves all Protected Regions from a source file. + * + * @param file + * The source file to scan. + * @return All found Protected Regions in the specified file. + * @throws ProtectedRegionSyntaxException + * If one of the Protected Regions in the file is incomplete or + * invalid. + * @throws IOException + * On errors occuring when reading the file + */ + protected Collection<ProtectedRegionImpl> getAllRegions(final File file) throws ProtectedRegionSyntaxException, + IOException { + final List<ProtectedRegionImpl> regions = new ArrayList<ProtectedRegionImpl>(); - private static final String PROTECT_BEGIN = "PROTECTED REGION ID"; + final String source = FSIO.readSingleFile(file, encoding); - private static final String PROTECT_END = "PROTECTED REGION END"; + final int beginLength = PROTECT_BEGIN.length(); + final int startEndLength = PROTECT_START_END.length(); + final int idBeginLength = PROTECT_BEFORE_ID.length(); + final int idEndLength = PROTECT_AFTER_ID.length(); - private static final String PROTECT_START_END = "START"; + int start = source.indexOf(PROTECT_BEGIN); - private final Log log = LogFactory.getLog(getClass()); + while (start >= 0) { + final int blockStart = start + beginLength; - private File[] srcPaths = null; + boolean isB64 = false; + int idStart = source.indexOf(PROTECT_BEFORE_ID, blockStart); - private boolean defaultExcludes = true; + if (idStart != blockStart) { + // IP System.out.println("IDSTART:"+idStart); + idStart = source.indexOf(PROTECT_B64_BEFORE_ID, blockStart); + isB64 = true; + } + idStart += idBeginLength; - protected boolean useBASE64 = false; + final int end = source.indexOf(PROTECT_END, idStart); + final int next = source.indexOf(PROTECT_BEGIN, idStart); - protected String encoding; + if ((end < 0) || ((next >= 0) && (next < end))) + throw new ProtectedRegionSyntaxException("Protected region at index " + start + " in file '" + file + + "' is incomplete"); - private String ignoreList = null; + final int idEnd = source.indexOf(isB64 ? PROTECT_B64_AFTER_ID : PROTECT_AFTER_ID, idStart); - /** - * This map stores all scanned protected regions. - * <p> - * Key: Protected Region ID<br> - * Value: The Protected Region - */ - private Map<String, ProtectedRegionImpl> regionMap = null; + if ((idEnd <= idStart) || (end < idEnd)) + throw new ProtectedRegionSyntaxException("Protected region Id at index " + start + " in file '" + file + + "' is incomplete"); - /** - * All already queried Protected Region Ids. Is used for detecting ambigious usage of - * Protected Regions. - */ - private Set<String> usedSet = null; + String id = new String(source.substring(idStart, idEnd)); - /** - * Retrieves all Protected Regions from a source file. - * @param file The source file to scan. - * @return All found Protected Regions in the specified file. - * @throws ProtectedRegionSyntaxException If one of the Protected Regions in the file is incomplete or invalid. - * @throws IOException On errors occuring when reading the file - */ - protected Collection<ProtectedRegionImpl> getAllRegions(final File file) throws ProtectedRegionSyntaxException, IOException { - final List<ProtectedRegionImpl> regions = new ArrayList<ProtectedRegionImpl>(); - - final String source = FSIO.readSingleFile(file, encoding); + if (isB64) { + try { + id = new String(BASE64.toByteArray(id)); + } + catch (final IOException ie) { + throw new ProtectedRegionSyntaxException("Protected region Id at index " + start + " in file '" + + file + "' is incomplete", ie); + } + } + + final int startEnd = source.indexOf(PROTECT_START_END, idEnd + idEndLength); + + if (end < startEnd) + throw new ProtectedRegionSyntaxException("Protected region start at index " + start + " in file '" + + file + "' is incomplete"); + + final String type = new String(source.substring(idEnd + idEndLength, startEnd).trim().toUpperCase()); + + if (!(type.equals("") || type.equals(ENABLED))) + throw new ProtectedRegionSyntaxException("Protected region start at index " + start + " in file " + + file + " has illegal type '" + type + "'"); + if (type.equals(ENABLED)) { + final String body = new String(source.substring(startEnd + startEndLength, end)); + regions.add(new ProtectedRegionImpl(id, false, file, encoding, useBASE64, startEnd + startEndLength, + end, body)); + } + start = next; + } + + return regions; + } + + public ProtectedRegion createProtectedRegion(final String id, final boolean disabled) { + return new ProtectedRegionImpl(id, disabled, null, null, useBASE64, 0, 0, null); + } + + public ProtectedRegion getProtectedRegion(final String id) { + init(); + // if (!usedSet.isEmpty()) { // Fix:No error if Handle is not used + // return null; + // } + if (!usedSet.add(id)) { + // id was not added to usedSet -> id was already queried before! + log.warn("Protected region with ID '" + id + "' referenced more than once"); + } + + return regionMap.get(id); + } + + /** + * Initializes the ProtectedRegionResolver. This starts the scan over all + * configured paths (property 'srcPaths'). + * <p> + * A second call (already initialized) to this method will return + * immediately. + * + * @throws IllegalStateException + * If a Protected Region Id is detected the second time, i.e. it + * is not unique. + */ + public void init() throws IllegalStateException { + // Already initialized? + if (regionMap != null) + return; + + // Initialize the Protected Region map + regionMap = new HashMap<String, ProtectedRegionImpl>(); + usedSet = new HashSet<String>(); + + if (srcPaths == null) { + log.warn("No source paths configured for scanning."); + // abort + return; + } + + long time = 0; + long fileCount = 0; + + if (log.isInfoEnabled()) { + log.info("Source scan started ..."); + time = System.currentTimeMillis(); + } + + // create the file filter + final GenericFileFilter filter = new GenericFileFilter(ignoreList, defaultExcludes); + + // Scan all configured paths + for (int i = 0; i < srcPaths.length; i += 1) { + try { + // retrieve (recursive) all files from a path matching the + // configured filter + final File[] files = FSIO.getAllFiles(srcPaths[i], filter); + + fileCount += files.length; + + // scan all files + for (int j = 0; j < files.length; j += 1) { + // retrieve the Protected Regions from the current file + final Iterator<ProtectedRegionImpl> regions = getAllRegions(files[j]).iterator(); + + while (regions.hasNext()) { + final ProtectedRegionImpl region = regions.next(); + + final String id = region.getId(); + // check for non-uniqueness of a Protected Region Id + if (regionMap.containsKey(id)) + throw new IllegalStateException("Id '" + id + "' occuring in files " + region.getFile() + + " and " + regionMap.get(id).getFile() + " is not unique"); + // Store this region + regionMap.put(id, region); + } + } + } + catch (final IOException e) { + throw new RuntimeException("Unexpected I/O exception", e); + } + catch (final ProtectedRegionSyntaxException e) { + throw new RuntimeException(e.getMessage(), e); + } + } + + if (log.isInfoEnabled()) { + time = System.currentTimeMillis() - time; + + log.info("Source scan finished in " + (time / 1000.0) + "s"); + log.info("Files scanned: " + fileCount); + log.info("Regions found: " + regionMap.size()); + } + + } + + /** + * Dumps all known protected regions to files. For each protected region a + * file is created. + * + * @param dumpPath + * Directory where the dump files are created within. + */ + public void reportRegions(final File dumpPath) { + final int unused = regionMap.size() - usedSet.size(); + + if (unused > 0) { + log.warn("There are " + unused + " unused Regions:"); + + if (dumpPath != null) { + dumpPath.mkdirs(); + } + + for (final Iterator<ProtectedRegionImpl> regions = regionMap.values().iterator(); regions.hasNext();) { + final ProtectedRegionImpl region = regions.next(); + + final String id = region.getId(); + + if (!usedSet.contains(id)) { + log.warn("File: " + region.getFile()); + log.warn("ID: " + id); + + try { + if (dumpPath != null) { + final File file = new File(dumpPath, BASE64.toString(id)); + + Writer writer; + + if (encoding == null) { + writer = new FileWriter(file); + } + else { + writer = new OutputStreamWriter(new FileOutputStream(file), encoding); + } + + writer.write(region.getStartString("", "")); + writer.write(region.getBody("", "")); + writer.write(region.getEndString("", "")); + + writer.close(); + } + } + catch (final IOException e) { + throw new RuntimeException("Unexpected I/O exception", e); + } + catch (final ProtectedRegionSyntaxException e) { + log.error(e.getMessage(), e); + } + } + } + } + } + + /** + * This flag determines whether default file exclusion patterns should be + * used. + * + * @param defaultExcludes + * <code>true</code>: Use default file exclusion patterns, + * <code>false</code>: ignore them, just use the patterns + * specified by {@link #setIgnoreList(String) ignoreList} + * @see Xpand reference manual + */ + public void setDefaultExcludes(final boolean defaultExcludes) { + this.defaultExcludes = defaultExcludes; + } + + /** + * Sets the file encoding to be used when reading files. + * + * @param encoding + * A valid encoding string. + */ + public void setFileEncoding(final String encoding) { + this.encoding = encoding; + } + + /** + * Sets a custom list of file patterns that should be filtered during + * scanning of source files and directories. + * + * @param ignoreList + * A comma separated list of file patterns to ignore during scan. + */ + public void setIgnoreList(final String ignoreList) { + this.ignoreList = ignoreList; + } + + /** + * Sets the source paths that should be scanned. + * + * @param srcPathsAsString + * A comma separated list of directory paths. + * @throws IllegalArgumentException + * If one of the passed arguments is not a directory or does not + * exist + */ + public void setSrcPathes(final String srcPathsAsString) throws IllegalArgumentException { + // Split the paths and initialize the + // file array 'srcPaths' from it + if ("".equals(srcPathsAsString)) { + this.srcPaths = new File[0]; + } + else { + final String[] s = srcPathsAsString.split(","); + final List<File> validPaths = new ArrayList<File>(s.length); + for (int i = 0; i < s.length; i++) { + File dir = new File(s[i].trim()); + // The configured path must point to an existing directory + if (dir.isDirectory()) { + validPaths.add(dir); + } + else { + final String msg = "Ignoring non-existing protected region path " + dir.getAbsolutePath(); + LOG.warn(msg); + throw new IllegalArgumentException(msg); + } + } + this.srcPaths = validPaths.toArray(new File[] {}); + } + } - final int beginLength = PROTECT_BEGIN.length(); - final int startEndLength = PROTECT_START_END.length(); - final int idBeginLength = PROTECT_BEFORE_ID.length(); - final int idEndLength = PROTECT_AFTER_ID.length(); - - int start = source.indexOf(PROTECT_BEGIN); - - while (start >= 0) { - final int blockStart = start + beginLength; - - boolean isB64 = false; - int idStart = source.indexOf(PROTECT_BEFORE_ID, blockStart); - - if (idStart != blockStart) { - // IP System.out.println("IDSTART:"+idStart); - idStart = source.indexOf(PROTECT_B64_BEFORE_ID, blockStart); - isB64 = true; - } - idStart += idBeginLength; - - final int end = source.indexOf(PROTECT_END, idStart); - final int next = source.indexOf(PROTECT_BEGIN, idStart); - - if ((end < 0) || ((next >= 0) && (next < end))) - throw new ProtectedRegionSyntaxException("Protected region at index " + start + " in file '" + file - + "' is incomplete"); - - final int idEnd = source.indexOf(isB64 ? PROTECT_B64_AFTER_ID : PROTECT_AFTER_ID, idStart); - - if ((idEnd <= idStart) || (end < idEnd)) - throw new ProtectedRegionSyntaxException("Protected region Id at index " + start + " in file '" + file - + "' is incomplete"); - - String id = new String(source.substring(idStart, idEnd)); - - if (isB64) { - try { - id = new String(BASE64.toByteArray(id)); - } catch (final IOException ie) { - throw new ProtectedRegionSyntaxException("Protected region Id at index " + start + " in file '" - + file + "' is incomplete", ie); - } - } - - final int startEnd = source.indexOf(PROTECT_START_END, idEnd + idEndLength); - - if (end < startEnd) - throw new ProtectedRegionSyntaxException("Protected region start at index " + start + " in file '" - + file + "' is incomplete"); - - final String type = new String(source.substring(idEnd + idEndLength, startEnd).trim().toUpperCase()); - - if (!(type.equals("") || type.equals(ENABLED))) - throw new ProtectedRegionSyntaxException("Protected region start at index " + start + " in file " - + file + " has illegal type '" + type+ "'"); - if (type.equals(ENABLED)) { - final String body = new String(source.substring(startEnd + startEndLength, end)); - regions.add(new ProtectedRegionImpl(id, false, file, encoding, useBASE64, startEnd + startEndLength, - end, body)); - } - start = next; - } - - return regions; - } - - public ProtectedRegion createProtectedRegion(final String id, final boolean disabled) { - return new ProtectedRegionImpl(id, disabled, null, null, useBASE64, 0, 0, null); - } - - public ProtectedRegion getProtectedRegion(final String id) { - init(); -// if (!usedSet.isEmpty()) { // Fix:No error if Handle is not used -// return null; -// } - if (!usedSet.add(id)) { - // id was not added to usedSet -> id was already queried before! - log.warn("Protected region with ID '" + id + "' referenced more than once"); - } - - return regionMap.get(id); - } - - /** - * Initializes the ProtectedRegionResolver. This starts the scan over all configured paths (property 'srcPaths'). - * <p> - * A second call (already initialized) to this method will return immediately. - * - * @throws IllegalStateException If a Protected Region Id is detected the second time, i.e. it is not unique. - */ - public void init() throws IllegalStateException { - // Already initialized? - if (regionMap != null) { - return; - } - - // Initialize the Protected Region map - regionMap = new HashMap<String, ProtectedRegionImpl>(); - usedSet = new HashSet<String>(); - - if (srcPaths==null) { - log.warn("No source paths configured for scanning."); - // abort - return; - } - - long time = 0; - long fileCount = 0; - - if (log.isInfoEnabled()) { - log.info("Source scan started ..."); - time = System.currentTimeMillis(); - } - - // create the file filter - final GenericFileFilter filter = new GenericFileFilter(ignoreList, defaultExcludes); - - // Scan all configured paths - for (int i = 0; i < srcPaths.length; i += 1) { - try { - // retrieve (recursive) all files from a path matching the configured filter - final File[] files = FSIO.getAllFiles(srcPaths[i], filter); - - fileCount += files.length; - - // scan all files - for (int j = 0; j < files.length; j += 1) { - // retrieve the Protected Regions from the current file - final Iterator<ProtectedRegionImpl> regions = getAllRegions(files[j]).iterator(); - - while (regions.hasNext()) { - final ProtectedRegionImpl region = regions.next(); - - final String id = region.getId(); - // check for non-uniqueness of a Protected Region Id - if (regionMap.containsKey(id)) { - throw new IllegalStateException ("Id '" + id + "' occuring in files " + region.getFile() - + " and " + regionMap.get(id).getFile() - + " is not unique"); - } - // Store this region - regionMap.put(id, region); - } - } - } catch (final IOException e) { - throw new RuntimeException("Unexpected I/O exception", e); - } catch (final ProtectedRegionSyntaxException e) { - throw new RuntimeException(e.getMessage(), e); - } - } - - if (log.isInfoEnabled()) { - time = System.currentTimeMillis() - time; - - log.info("Source scan finished in " + (time / 1000.0) + "s"); - log.info("Files scanned: " + fileCount); - log.info("Regions found: " + regionMap.size()); - } - - } - - /** - * Dumps all known protected regions to files. For each protected region a file is created. - * @param dumpPath Directory where the dump files are created within. - */ - public void reportRegions(final File dumpPath) { - final int unused = regionMap.size() - usedSet.size(); - - if (unused > 0) { - log.warn("There are " + unused + " unused Regions:"); - - if (dumpPath != null) { - dumpPath.mkdirs(); - } - - for (final Iterator<ProtectedRegionImpl> regions = regionMap.values().iterator(); regions.hasNext();) { - final ProtectedRegionImpl region = regions.next(); - - final String id = region.getId(); - - if (!usedSet.contains(id)) { - log.warn("File: " + region.getFile()); - log.warn("ID: " + id); - - try { - if (dumpPath != null) { - final File file = new File(dumpPath, BASE64.toString(id)); - - Writer writer; - - if (encoding == null) { - writer = new FileWriter(file); - } else { - writer = new OutputStreamWriter(new FileOutputStream(file), encoding); - } - - writer.write(region.getStartString("", "")); - writer.write(region.getBody("", "")); - writer.write(region.getEndString("", "")); - - writer.close(); - } - } catch (final IOException e) { - throw new RuntimeException("Unexpected I/O exception", e); - } catch (final ProtectedRegionSyntaxException e) { - log.error(e.getMessage(), e); - } - } - } - } - } - - /** - * This flag determines whether default file exclusion patterns should be used. - * @param defaultExcludes <code>true</code>: Use default file exclusion patterns, <code>false</code>: ignore them, just use - * the patterns specified by {@link #setIgnoreList(String) ignoreList} - * @see Xpand reference manual - */ - public void setDefaultExcludes(final boolean defaultExcludes) { - this.defaultExcludes = defaultExcludes; - } - - /** - * Sets the file encoding to be used when reading files. - * @param encoding A valid encoding string. - */ - public void setFileEncoding(final String encoding) { - this.encoding = encoding; - } - - /** - * Sets a custom list of file patterns that should be filtered during scanning of source files - * and directories. - * @param ignoreList A comma separated list of file patterns to ignore during scan. - */ - public void setIgnoreList(final String ignoreList) { - this.ignoreList = ignoreList; - } - - /** - * Sets the source paths that should be scanned. - * @param srcPathsAsString A comma separated list of directory paths. - * @throws IllegalArgumentException If one of the passed arguments is not a directory or does not exist - */ - public void setSrcPathes(final String srcPathsAsString) throws IllegalArgumentException { - // Split the paths and initialize the - // file array 'srcPaths' from it - if ("".equals(srcPathsAsString)) { - this.srcPaths = new File[0]; - } else { - final String[] s = srcPathsAsString.split(","); - this.srcPaths = new File[s.length]; - for (int i = 0; i < this.srcPaths.length; i++) { - this.srcPaths[i] = new File(s[i].trim()); - // The configured path must point to an existing directory - if (!srcPaths[i].isDirectory()) { - throw new IllegalArgumentException("Source path component " + srcPaths[i] - + " not found or no directory"); - } - } - - } - } - - public void setUseBASE64(final boolean useBASE64) { - this.useBASE64 = useBASE64; - } + public void setUseBASE64(final boolean useBASE64) { + this.useBASE64 = useBASE64; + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionSyntaxException.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionSyntaxException.java index e82fafe6..1ec42617 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionSyntaxException.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/ProtectedRegionSyntaxException.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/package.html new file mode 100644 index 00000000..12e63266 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of protected regions +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/BASE64.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/BASE64.java index f5174520..b2833336 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/BASE64.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/BASE64.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr.util; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/FSIO.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/FSIO.java index 7582ee39..909ce3c0 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/FSIO.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/FSIO.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr.util; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/GenericFileFilter.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/GenericFileFilter.java index 3fa484e3..c42864c1 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/GenericFileFilter.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/GenericFileFilter.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.pr.util; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/package.html new file mode 100644 index 00000000..11fcbe61 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/pr/util/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Utility classes for protected regions +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/DefinitionType.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/DefinitionType.java index 27f82c17..1500cba0 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/DefinitionType.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/DefinitionType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.type; @@ -56,7 +54,7 @@ public class DefinitionType extends AbstractTypeImpl { return ((XpandDefinitionImpl) target).getParamNames(); } }, - new OperationImpl(this, "proceed", getTypeSystem().getVoidType(), new Type[0]) { + new OperationImpl(this, "proceed", getTypeSystem().getVoidType()) { @Override protected Object evaluateInternal(final Object target, final Object[] params) { @@ -74,7 +72,7 @@ public class DefinitionType extends AbstractTypeImpl { return null; } - }, new OperationImpl(this, "toString", getTypeSystem().getStringType(), new Type[0]) { + }, new OperationImpl(this, "toString", getTypeSystem().getStringType()) { @Override protected Object evaluateInternal(final Object target, final Object[] params) { diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/IteratorType.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/IteratorType.java index cd9b8d6e..0c4b5a03 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/IteratorType.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/IteratorType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.type; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandDefinitionImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandDefinitionImpl.java index 62c9ea7c..4b130735 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandDefinitionImpl.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandDefinitionImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.type; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandIterator.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandIterator.java index cc23e5f1..9783a30f 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandIterator.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandIterator.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.type; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java index daf23d18..a8e9b926 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/XpandTypesMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xpand2.type; @@ -28,54 +26,81 @@ public class XpandTypesMetaModel implements MetaModel { private final Map<String, AbstractTypeImpl> types = new HashMap<String, AbstractTypeImpl>(); public XpandTypesMetaModel(final TypeSystem ts) { - if (ts == null) { + if (ts == null) throw new IllegalArgumentException("Typesystem must not be null!"); - } typeSystem = ts; types.put(DefinitionType.TYPE_NAME, new DefinitionType(ts)); types.put(IteratorType.TYPE_NAME, new IteratorType(ts)); } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeSystem() + */ public TypeSystem getTypeSystem() { return typeSystem; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#setTypeSystem(org.eclipse.xtend.expression.TypeSystem) + */ public void setTypeSystem(final TypeSystem typeSystem) { this.typeSystem = typeSystem; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeForName(java.lang.String) + */ public Type getTypeForName(final String typeName) { return types.get(typeName); } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getType(java.lang.Object) + */ public Type getType(final Object obj) { for (final Iterator<AbstractTypeImpl> iter = types.values().iterator(); iter.hasNext();) { final Type t = iter.next(); - if (t.isInstance(obj)) { + if (t.isInstance(obj)) return t; - } } return null; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getKnownTypes() + */ public Set<? extends Type> getKnownTypes() { return new HashSet<AbstractTypeImpl>(types.values()); } + /** + * Returns the name of the metamodel. + * + * @return name of metamodel + */ public String getName() { return "xpand"; } + /** + * @see java.lang.Object#equals(java.lang.Object) + */ @Override public boolean equals(Object arg0) { return arg0 instanceof XpandTypesMetaModel; } + /** + * @see java.lang.Object#hashCode() + */ @Override public int hashCode() { return 4711; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getNamespaces() + */ public Set<String> getNamespaces() { return new HashSet<String>(); } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/package.html new file mode 100644 index 00000000..66d40c88 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/type/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Basic types of the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java index 68d39667..0adbb385 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/Generator.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; @@ -18,8 +16,9 @@ import java.io.OutputStream; import java.io.StringReader; import java.util.ArrayList; import java.util.Collections; -import java.util.Iterator; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.eclipse.emf.mwe.core.ConfigurationException; import org.eclipse.emf.mwe.core.WorkflowContext; @@ -44,361 +43,467 @@ import org.eclipse.xtend.typesystem.MetaModel; public class Generator extends AbstractExpressionsUsingWorkflowComponent { - private String genPath = null; + private static final String COMPONENT_NAME = "Xpand Generator"; - private String srcPath = null; + private String genPath = null; - private String prSrcPaths = null; + private String srcPath = null; - private String prExcludes = null; + private String prSrcPaths = null; - private boolean prDefaultExcludes = true; + private String prExcludes = null; - private String expand = null; + private boolean prDefaultExcludes = true; - private String fileEncoding = null; + private String expand = null; - private List<?> beautifier = new ArrayList<Object>(); + private String fileEncoding = null; - private List<String> advices = new ArrayList<String>(); + private List<?> beautifier = new ArrayList<Object>(); - private List<String> extensionAdvices = new ArrayList<String>(); - - private boolean automaticHyphens = false; - - private ExceptionHandler exceptionHandler = null; + private final List<String> advices = new ArrayList<String>(); - private String collectProfileSummary = null; - private String verboseProfileFilename = null; - - private Output output = null; - - public void setCollectProfileSummary (String c) { - collectProfileSummary = c; - } - - public void setVerboseProfileFilename (String f) { - verboseProfileFilename = f; - } - - public void setAutomaticHyphens(boolean automaticHyphens) { - this.automaticHyphens = automaticHyphens; - } + private final List<String> extensionAdvices = new ArrayList<String>(); - @Override + private boolean automaticHyphens = false; + + private ExceptionHandler exceptionHandler = null; + + private String collectProfileSummary = null; + private String verboseProfileFilename = null; + + private Output output = null; + + /** + * Sets the collection profile summary. + * + * @param summary + * the summary + */ + public void setCollectProfileSummary(final String summary) { + collectProfileSummary = summary; + } + + /** + * Sets the filename for verbose profile. + * + * @param fileName + * filename for verbose profile + */ + public void setVerboseProfileFilename(final String fileName) { + verboseProfileFilename = fileName; + } + + /** + * Enables or disables the automatic hyphenation. If automatic hyphenation + * is enabled, redundant blank lines are avoided automatically. + * + * @param automaticHyphens + * If <code>true</code>, automatic hyphenation is enabled, + * otherwise disabled. + */ + public void setAutomaticHyphens(final boolean automaticHyphens) { + this.automaticHyphens = automaticHyphens; + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ + @Override public String getLogMessage() { - return "generating '"+expand+"' => directory '"+genPath+"'"; - } - - @Override - public void addAdvices(final String advice) { - if ( !this.advices.contains(advice) ) this.advices.add( advice ); - } - - @Override - public void addAdvice(final String advice) { - if ( !this.advices.contains(advice) ) this.advices.add( advice ); - } - - @Override - public void addExtensionAdvices(String extensionAdvices) { - if ( !this.extensionAdvices.contains(extensionAdvices) ) - this.extensionAdvices.add( extensionAdvices ); + Set<String> outletDescriptions = new HashSet<String>(); + for (Outlet outlet : outlets) { + outletDescriptions.add(outlet.toString()); + } + String outletDesc = outletDescriptions.size() == 1 ? outletDescriptions.iterator().next() : outletDescriptions + .toString(); + return "generating '" + expand + "' => " + outletDesc; } - @Override - public void addExtensionAdvice(String extensionAdvice) { - if ( !this.extensionAdvices.contains(extensionAdvice) ) - this.extensionAdvices.add( extensionAdvice ); + /** + * Adds an advice. + * + * @param advice + * the advice + */ + @Override + public void addAdvice(final String advice) { + if (!advices.contains(advice)) { + advices.add(advice); + } } - public List<?> getBeautifier() { - return beautifier; - } + /** + * Adds an extension advice. + * + * @param extensionAdvice + * the extension advice + */ + @Override + public void addExtensionAdvice(final String extensionAdvice) { + if (!extensionAdvices.contains(extensionAdvice)) { + extensionAdvices.add(extensionAdvice); + } + } - public void setBeautifier(final List<?> beautifiers) { - beautifier = beautifiers; - } + /** + * Returns the list of beatifiers that will be applied to the generated + * output. + * + * @return list of beautifiers + */ + public List<?> getBeautifier() { + return beautifier; + } - public void setFileEncoding(final String fileEncoding) { - this.fileEncoding = fileEncoding; - } - + /** + * Sets the list of beatifiers that will be applied to the generated output. + * + * @param beautifiers + * list of beautifiera + */ + public void setBeautifier(final List<?> beautifiers) { + beautifier = beautifiers; + } + + /** + * Sets the character encoding used for the output file. + * + * @param fileEncoding + * name of character encoding + */ + public void setFileEncoding(final String fileEncoding) { + this.fileEncoding = fileEncoding; + } + + /** + * Returns the name of character encoding used for the output file. + * + * @return name of character encoding + */ public String getFileEncoding() { return fileEncoding; } - /** - * - * @deprecated use outlets instead - */ - @Deprecated - public void setGenPath(final String genPath) { - this.genPath = fixPath(genPath); - } - - public void setExpand(final String invoke) { - expand = invoke; - } - - public void setPrDefaultExcludes(final boolean prDefaultExcludes) { - this.prDefaultExcludes = prDefaultExcludes; - } - - public void setPrExcludes(final String prExcludes) { - this.prExcludes = prExcludes; - } - - public void setPrSrcPaths(final String prSrcPathes) { - this.prSrcPaths = prSrcPathes; - } - - public void setExceptionHandler(final ExceptionHandler exceptionHandler) { - this.exceptionHandler = exceptionHandler; + /** + * + * @deprecated use outlets instead + */ + @Deprecated + public void setGenPath(final String genPath) { + this.genPath = fixPath(genPath); } /** - * - * @deprecated use outlets instead - */ - @Deprecated - public void setSrcPath(final String srcPath) { - this.srcPath = fixPath(srcPath); - } - - private String fixPath(final String p) { - if (p.endsWith("\\")) - return p.replace('\\', '/'); - if (p.endsWith("/")) - return p; - return p + "/"; - } - - @Override - protected void invokeInternal2(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { - OutputStream verboseProfileOutputStream = null; - - if (verboseProfileFilename != null) { - try { - verboseProfileOutputStream = new BufferedOutputStream (new FileOutputStream (verboseProfileFilename)); - ProfileCollector.getInstance().setDetailedLoggingWriter(verboseProfileOutputStream); - } - catch (IOException exc) { - log.warn("could nto open profiling log file", exc); - } - } - - final Output out = getOutput(); - final List<Outlet> outlets = getInitializedOutlets(); - for (final Iterator<Outlet> iter = outlets.iterator(); iter.hasNext();) { - out.addOutlet(iter.next()); - } - - ProtectedRegionResolverImpl prs = null; - if (prSrcPaths != null) { - prs = new ProtectedRegionResolverImpl(); - prs.setDefaultExcludes(prDefaultExcludes); - prs.setIgnoreList(prExcludes); - prs.setSrcPathes(prSrcPaths); - prs.setFileEncoding(fileEncoding); - } - - XpandExecutionContextImpl executionContext = new XpandExecutionContextImpl(out, prs, getGlobalVars(ctx), exceptionHandler,getNullEvaluationHandler()); - if (monitor!=null) { - executionContext.setMonitor(monitor); - } - - - if (fileEncoding != null) { - executionContext.setFileEncoding(fileEncoding); - } - - for (MetaModel mm : metaModels) { - executionContext.registerMetaModel(mm); - } - - final ExpandStatement es = getStatement(); - if (es == null) - throw new ConfigurationException("property 'expand' has wrong syntax!"); - - final String[] names = ctx.getSlotNames(); - for (int i = 0; i < names.length; i++) { - final String name = names[i]; - executionContext = (XpandExecutionContextImpl) executionContext.cloneWithVariable(new Variable(name, ctx - .get(name))); - } - - for (String advice : advices) { - final String[] allAdvices = advice.split(","); - for (int i = 0; i < allAdvices.length; i++) { - final String string = allAdvices[i]; - executionContext.registerAdvices(string.trim()); - } + * Sets the statement that is to expand by the generator. + * + * @param invoke + * statement to expand + */ + public void setExpand(final String invoke) { + expand = invoke; + } + + /** + * Enables oder disables the default excludes for protected regions. + * + * @param prDefaultExcludes + * If <code>true</code>, the default excludes are enabled, + * otherwise disabled. + */ + public void setPrDefaultExcludes(final boolean prDefaultExcludes) { + this.prDefaultExcludes = prDefaultExcludes; + } + + /** + * Sets the additional excludes for protected regions. + * + * @param prExcludes + * the excludes + */ + public void setPrExcludes(final String prExcludes) { + this.prExcludes = prExcludes; + } + + /** + * Sets the source paths for protected regions. + * + * @param prSrcPathes + * the source paths + */ + public void setPrSrcPaths(final String prSrcPathes) { + this.prSrcPaths = prSrcPathes; + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } + + /** + * + * @deprecated use outlets instead + */ + @Deprecated + public void setSrcPath(final String srcPath) { + this.srcPath = fixPath(srcPath); + } + + private String fixPath(final String p) { + if (p.endsWith("\\")) + return p.replace('\\', '/'); + if (p.endsWith("/")) + return p; + return p + "/"; + } + + @Override + protected void invokeInternal2(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { + OutputStream verboseProfileOutputStream = null; + + if (verboseProfileFilename != null) { + try { + verboseProfileOutputStream = new BufferedOutputStream(new FileOutputStream(verboseProfileFilename)); + ProfileCollector.getInstance().setDetailedLoggingWriter(verboseProfileOutputStream); + } + catch (final IOException exc) { + log.warn("Could not open profiling log file", exc); + } + } + + final Output out = getOutput(); + final List<Outlet> outlets = getInitializedOutlets(); + for (final Outlet outlet : outlets) { + out.addOutlet(outlet); + } + + ProtectedRegionResolverImpl prs = null; + if (prSrcPaths != null) { + prs = new ProtectedRegionResolverImpl(); + prs.setDefaultExcludes(prDefaultExcludes); + prs.setIgnoreList(prExcludes); + prs.setSrcPathes(prSrcPaths); + prs.setFileEncoding(fileEncoding); + } + + XpandExecutionContextImpl executionContext = new XpandExecutionContextImpl(out, prs, getGlobalVars(ctx), + exceptionHandler, getNullEvaluationHandler()); + if (monitor != null) { + executionContext.setMonitor(monitor); + } + executionContext.setResourceManager(getResourceManager()); + if (callback != null) { + executionContext.setCallBack(callback); + } + + if (fileEncoding != null) { + executionContext.setFileEncoding(fileEncoding); } - - for (String advice : extensionAdvices) { - final String[] allAdvices = advice.split(","); - for (int i = 0; i < allAdvices.length; i++) { - final String string = allAdvices[i]; - executionContext.registerExtensionAdvices(string.trim()); - } - } - - es.evaluate(executionContext); - - for (final Iterator<Outlet> iter = outlets.iterator(); iter.hasNext();) { - final Outlet element = iter.next(); - final String name = (element.getName() == null ? "[default]" : element.getName()) + "(" + element.getPath() - + ")"; - if (element.getFilesWrittenAndClosed() > 0) { - log.info("Written " + element.getFilesWrittenAndClosed() + " files to outlet " + name); - } - if (element.getFilesCreated() > element.getFilesWrittenAndClosed()) { - log.info("Skipped writing of " + (element.getFilesCreated() - element.getFilesWrittenAndClosed()) - + " files to outlet " + name); - } - } - - ProfileCollector.getInstance().finish(); - if ("true".equalsIgnoreCase(this.collectProfileSummary)) { - log.info ("profiling info: \n" + ProfileCollector.getInstance().toString()); - } - - if (verboseProfileOutputStream != null) { - try { - verboseProfileOutputStream.close (); - } - catch (IOException exc) { - log.warn("problem closing profile log file", exc); - } - } - } - - private final List<Outlet> outlets = new ArrayList<Outlet>(); - - public void addOutlet(final Outlet outlet) { - outlets.add(outlet); - } - - public void setOutput (final Output output) { - this.output = output; - } - - private Output getOutput () { - if (output==null) { - // lazy initialization - OutputImpl out = new OutputImpl(); - out.setAutomaticHyphens(automaticHyphens); - this.output = out; - } - return output; - } - - private List<Outlet> initializedOutlets = null; - - private List<Outlet> getInitializedOutlets() { - if (initializedOutlets == null) { - final List<Outlet> result = new ArrayList<Outlet>(outlets); - if (result.isEmpty()) { - if (genPath != null) { // backward compatibility - Outlet o = new Outlet(); - o.setAppend(false); - o.setFileEncoding(fileEncoding); - o.setOverwrite(true); - o.setPath(genPath); - result.add(o); - - o = new Outlet(); - o.setAppend(true); - o.setFileEncoding(fileEncoding); - o.setName("APPEND"); - o.setOverwrite(true); - o.setPath(genPath); - result.add(o); - } - if (srcPath != null) { - final Outlet o = new Outlet(); - o.setAppend(false); - o.setFileEncoding(fileEncoding); - o.setName("ONCE"); - o.setOverwrite(false); - o.setPath(srcPath); - - result.add(o); - } - } - for (final Iterator<Outlet> iter = result.iterator(); iter.hasNext();) { - final Outlet o = iter.next(); - if (o.postprocessors.isEmpty()) { - for (final Iterator<?> iterator = beautifier.iterator(); iterator.hasNext();) { - final PostProcessor element = (PostProcessor) iterator.next(); - o.addPostprocessor(element); - } - } - // Initialize file encoding for outlets. If it is not set then take the Generator - // default encoding. If this not set also then take System default. - if (o.hasDefaultEncoding() && fileEncoding!=null) { - o.setFileEncoding(fileEncoding); - } - } - initializedOutlets = result; - } - return initializedOutlets; - } - - /** - * Retrieves the configured and initialized outlets of the generator. - * @since 4.2 - */ - public final List<Outlet> getOutlets () { - return Collections.unmodifiableList(getInitializedOutlets()); - } - - private ExpandStatement getStatement() { - Template tpl = XpandParseFacade.file(new StringReader(XpandTokens.LT + "DEFINE test FOR test" + XpandTokens.RT - + XpandTokens.LT + "EXPAND " + expand + XpandTokens.RT + XpandTokens.LT + "ENDDEFINE" + XpandTokens.RT),null); - ExpandStatement es = null; - try { - es = (ExpandStatement) ((Definition) tpl.getDefinitions()[0]).getBody()[1]; - } catch (final Exception e) { - log.error(e); - } - return es; - } - - @Override - public void checkConfiguration(final Issues issues) { - super.checkConfiguration(issues); - if (genPath == null && getInitializedOutlets().isEmpty()) { - issues.addError(this, "You need to configure at least one outlet!"); - } - if ((genPath != null || srcPath != null) && !outlets.isEmpty()) { - issues.addWarning(this, "'genPath' and 'srcPath' properties are ignored since you have specified outlets!"); - } - int defaultOutlets = 0; - for (final Iterator<Outlet> iter = getInitializedOutlets().iterator(); iter.hasNext();) { - final Outlet o = iter.next(); - if (o.getName() == null) - defaultOutlets++; - } - if (defaultOutlets > 1) { - issues.addError(this, - "Only one outlet can be the default outlet. Please specifiy a name for the other outlets!"); - } else if (defaultOutlets == 0) { - issues.addWarning(this, "No default outlet configured!"); - } - if (expand == null) { - issues.addError(this, "property 'expand' not configured!"); - } else { - try { + + for (final MetaModel mm : metaModels) { + executionContext.registerMetaModel(mm); + } + + final ExpandStatement es = getStatement(); + if (es == null) + throw new ConfigurationException("property 'expand' has wrong syntax!"); + + final String[] names = ctx.getSlotNames(); + for (final String name : names) { + executionContext = (XpandExecutionContextImpl) executionContext.cloneWithVariable(new Variable(name, ctx + .get(name))); + } + + for (final String advice : advices) { + final String[] allAdvices = advice.split(","); + for (final String string : allAdvices) { + executionContext.registerAdvices(string.trim()); + } + } + + for (final String advice : extensionAdvices) { + final String[] allAdvices = advice.split(","); + for (final String string : allAdvices) { + executionContext.registerExtensionAdvices(string.trim()); + } + } + + es.evaluate(executionContext); + + for (final Outlet element : outlets) { + final String name = (element.getName() == null ? "[default]" : element.getName()) + "(" + element.getPath() + + ")"; + if (element.getFilesWrittenAndClosed() > 0) { + log.info("Written " + element.getFilesWrittenAndClosed() + " files to outlet " + name); + } + if (element.getFilesCreated() > element.getFilesWrittenAndClosed()) { + log.info("Skipped writing of " + (element.getFilesCreated() - element.getFilesWrittenAndClosed()) + + " files to outlet " + name); + } + } + + ProfileCollector.getInstance().finish(); + if ("true".equalsIgnoreCase(this.collectProfileSummary)) { + log.info("profiling info: \n" + ProfileCollector.getInstance().toString()); + } + + if (verboseProfileOutputStream != null) { + try { + verboseProfileOutputStream.close(); + } + catch (final IOException exc) { + log.warn("problem closing profile log file", exc); + } + } + } + + private final List<Outlet> outlets = new ArrayList<Outlet>(); + + /** + * Adds an outlet. + * + * @param outlet + * the outlet + */ + public void addOutlet(final Outlet outlet) { + outlets.add(outlet); + } + + /** + * Sets the output. + * + * @param output + * the output + */ + public void setOutput(final Output output) { + this.output = output; + } + + private Output getOutput() { + if (output == null) { + // lazy initialization + final OutputImpl out = new OutputImpl(); + out.setAutomaticHyphens(automaticHyphens); + this.output = out; + } + return output; + } + + private List<Outlet> initializedOutlets = null; + + private List<Outlet> getInitializedOutlets() { + if (initializedOutlets == null) { + final List<Outlet> result = new ArrayList<Outlet>(outlets); + if (result.isEmpty()) { + if (genPath != null) { // backward compatibility + Outlet o = new Outlet(); + o.setAppend(false); + o.setFileEncoding(fileEncoding); + o.setOverwrite(true); + o.setPath(genPath); + result.add(o); + + o = new Outlet(); + o.setAppend(true); + o.setFileEncoding(fileEncoding); + o.setName("APPEND"); + o.setOverwrite(true); + o.setPath(genPath); + result.add(o); + } + if (srcPath != null) { + final Outlet o = new Outlet(); + o.setAppend(false); + o.setFileEncoding(fileEncoding); + o.setName("ONCE"); + o.setOverwrite(false); + o.setPath(srcPath); + + result.add(o); + } + } + for (final Outlet o : result) { + if (o.postprocessors.isEmpty()) { + for (final Object name : beautifier) { + final PostProcessor element = (PostProcessor) name; + o.addPostprocessor(element); + } + } + // Initialize file encoding for outlets. If it is not set then + // take the Generator + // default encoding. If this not set also then take System + // default. + if (o.hasDefaultEncoding() && fileEncoding != null) { + o.setFileEncoding(fileEncoding); + } + } + initializedOutlets = result; + } + return initializedOutlets; + } + + /** + * Retrieves the configured and initialized outlets of the generator. + * + * @since 4.2 + */ + public final List<Outlet> getOutlets() { + return Collections.unmodifiableList(getInitializedOutlets()); + } + + private ExpandStatement getStatement() { + final Template tpl = XpandParseFacade.file(new StringReader(XpandTokens.LT + "DEFINE test FOR test" + + XpandTokens.RT + XpandTokens.LT + "EXPAND " + expand + XpandTokens.RT + XpandTokens.LT + "ENDDEFINE" + + XpandTokens.RT), null); + ExpandStatement es = null; + try { + es = (ExpandStatement) ((Definition) tpl.getDefinitions()[0]).getBody()[1]; + } + catch (final Exception e) { + log.error(e); + } + return es; + } + + @Override + protected void checkConfigurationInternal(final Issues issues) { + super.checkConfigurationInternal(issues); + if (genPath == null && getInitializedOutlets().isEmpty()) { + issues.addError(this, "You need to configure at least one outlet!"); + } + if ((genPath != null || srcPath != null) && !outlets.isEmpty()) { + issues.addWarning(this, "'genPath' and 'srcPath' properties are ignored since you have specified outlets!"); + } + int defaultOutlets = 0; + for (final Outlet o : getInitializedOutlets()) { + if (o.getName() == null) { + defaultOutlets++; + } + } + if (defaultOutlets > 1) { + issues.addError(this, + "Only one outlet can be the default outlet. Please specifiy a name for the other outlets!"); + } + else if (defaultOutlets == 0) { + issues.addWarning(this, "No default outlet configured!"); + } + if (expand == null) { + issues.addError(this, "property 'expand' not configured!"); + } + else { + try { final ExpandStatement es = getStatement(); if (es == null) { issues.addError(this, "property 'expand' has wrong syntax!"); } - } catch (ParseException e) { - issues.addError(this, "property 'expand' has wrong syntax : "+e.getMessage()); } - } - } + catch (final ParseException e) { + issues.addError(this, "property 'expand' has wrong syntax : " + e.getMessage()); + } + } + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/GeneratorAdvice.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/GeneratorAdvice.java index d93d9aa8..b4eec05a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/GeneratorAdvice.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/GeneratorAdvice.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/NoSuchTemplateException.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/NoSuchTemplateException.java index c92e24a5..5128749a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/NoSuchTemplateException.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/NoSuchTemplateException.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandCompilerIssue.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandCompilerIssue.java index 65eb4923..823d9d87 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandCompilerIssue.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandCompilerIssue.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContext.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContext.java index 32046492..3b65c90a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContext.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContext.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java index 5c552c58..efe8bd60 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; @@ -35,6 +33,7 @@ import org.eclipse.internal.xtend.type.baseimpl.PolymorphicResolver; import org.eclipse.internal.xtend.xtend.ast.Around; import org.eclipse.internal.xtend.xtend.ast.Extension; import org.eclipse.xpand2.output.Output; +import org.eclipse.xtend.expression.Callback; import org.eclipse.xtend.expression.ExceptionHandler; import org.eclipse.xtend.expression.ExecutionContextImpl; import org.eclipse.xtend.expression.NullEvaluationHandler; @@ -54,67 +53,83 @@ import org.eclipse.xtend.typesystem.Type; */ public class XpandExecutionContextImpl extends ExecutionContextImpl implements XpandExecutionContext { - private final Log log = LogFactory.getLog(getClass()); - - protected final Output output; - - protected final ProtectedRegionResolver protectedRegionResolver; - - private List<XpandAdvice> registeredAdvices = new ArrayList<XpandAdvice>(); - - public XpandExecutionContextImpl(Output output, ProtectedRegionResolver prs) { - this (output, prs, null, null, null); - } - - public XpandExecutionContextImpl(Output output, ProtectedRegionResolver prs, Map<String, Variable> globalVars, ExceptionHandler exceptionHandler, NullEvaluationHandler nullEvaluationHandler) { - this(new TypeSystemImpl(), output, prs, globalVars, exceptionHandler, nullEvaluationHandler); - } - - protected XpandExecutionContextImpl(final TypeSystemImpl ts, Output output, ProtectedRegionResolver prs, Map<String, Variable> globalVars, ExceptionHandler exceptionHandler, NullEvaluationHandler nullEvaluationHandler) { - super(ts, globalVars); - registerMetaModel(new XpandTypesMetaModel(this)); - resourceManager.registerParser(XpandUtil.TEMPLATE_EXTENSION, new ResourceParser() { + private final Log log = LogFactory.getLog(getClass()); + + protected final Output output; + + protected final ProtectedRegionResolver protectedRegionResolver; + + private List<XpandAdvice> registeredAdvices = new ArrayList<XpandAdvice>(); + + public XpandExecutionContextImpl(Output output, ProtectedRegionResolver prs) { + this(output, prs, null, null, null); + } + + public XpandExecutionContextImpl(Output output, ProtectedRegionResolver prs, Map<String, Variable> globalVars, + ExceptionHandler exceptionHandler, NullEvaluationHandler nullEvaluationHandler) { + this(new TypeSystemImpl(), output, prs, globalVars, exceptionHandler, nullEvaluationHandler); + } + + protected XpandExecutionContextImpl(final TypeSystemImpl ts, Output output, ProtectedRegionResolver prs, + Map<String, Variable> globalVars, ExceptionHandler exceptionHandler, + NullEvaluationHandler nullEvaluationHandler) { + super(ts, globalVars); + registerMetaModel(new XpandTypesMetaModel(this)); + registerParser(resourceManager); + this.output = output; + this.protectedRegionResolver = prs; + this.exceptionHandler = exceptionHandler; + this.nullEvaluationHandler = nullEvaluationHandler; + } + + private void registerParser(ResourceManager resourceManager) { + resourceManager.registerParser(XpandUtil.TEMPLATE_EXTENSION, new ResourceParser() { public Resource parse(Reader in, String fileName) { return XpandParseFacade.file(in, fileName); - }}); - this.output = output; - this.protectedRegionResolver = prs; - this.exceptionHandler = exceptionHandler; - this.nullEvaluationHandler = nullEvaluationHandler; - } - - - protected XpandExecutionContextImpl (ResourceManager resourceManager, Resource currentResource, TypeSystemImpl typeSystem, Map<String, Variable> vars, - Map<String, Variable> globalVars, Output output, ProtectedRegionResolver protectedRegionResolver, ProgressMonitor monitor, ExceptionHandler exceptionHandler,List<Around> advices, NullEvaluationHandler nullEvaluationHandler, Map<Resource, Set<Extension>> allExtensionsPerResource) { - super (resourceManager, currentResource, typeSystem, vars, globalVars, monitor, exceptionHandler,advices, nullEvaluationHandler,allExtensionsPerResource); - registerMetaModel(new XpandTypesMetaModel(this)); - this.output = output; - this.protectedRegionResolver = protectedRegionResolver; - this.exceptionHandler = exceptionHandler; - } - - - - @Override - public XpandExecutionContextImpl cloneContext() { - final XpandExecutionContextImpl result = new XpandExecutionContextImpl (resourceManager, currentResource(), typeSystem, getVisibleVariables(), getGlobalVariables(), output, - protectedRegionResolver, getMonitor(), exceptionHandler,registeredExtensionAdvices, nullEvaluationHandler,allExtensionsPerResource); - result.registeredAdvices.addAll(registeredAdvices); //todo: [aha] before I refactored, there was an assignment in this place. Is this modification correct? - return result; - } - - public List<XpandDefinition> getAllDefinitions() { - XpandResource tpl = null; - tpl = (XpandResource) currentResource(); - if (tpl == null) - return null; - - XpandDefinition[] localDefinitions = tpl.getDefinitions(); - - List<XpandDefinition> advicedDefinitions = new ArrayList<XpandDefinition>(localDefinitions.length); - - for (int i = 0; i < localDefinitions.length; i++) { + } + }); + } + + protected XpandExecutionContextImpl(ResourceManager resourceManager, Resource currentResource, + TypeSystemImpl typeSystem, Map<String, Variable> vars, Map<String, Variable> globalVars, Output output, + ProtectedRegionResolver protectedRegionResolver, ProgressMonitor monitor, + ExceptionHandler exceptionHandler, List<Around> advices, NullEvaluationHandler nullEvaluationHandler, + Map<Resource, Set<Extension>> allExtensionsPerResource, Callback callback) { + super(resourceManager, currentResource, typeSystem, vars, globalVars, monitor, exceptionHandler, advices, + nullEvaluationHandler, allExtensionsPerResource, callback); + registerMetaModel(new XpandTypesMetaModel(this)); + this.output = output; + this.protectedRegionResolver = protectedRegionResolver; + this.exceptionHandler = exceptionHandler; + } + + @Override + public XpandExecutionContextImpl cloneContext() { + final XpandExecutionContextImpl result = new XpandExecutionContextImpl(resourceManager, currentResource(), + typeSystem, getVisibleVariables(), getGlobalVariables(), output, protectedRegionResolver, getMonitor(), + exceptionHandler, registeredExtensionAdvices, nullEvaluationHandler, allExtensionsPerResource, callback); + result.registeredAdvices.addAll(registeredAdvices); // todo: [aha] + // before I + // refactored, there + // was an assignment + // in this place. Is + // this modification + // correct? + return result; + } + + public List<XpandDefinition> getAllDefinitions() { + XpandResource tpl = null; + tpl = (XpandResource) currentResource(); + if (tpl == null) + return null; + + XpandDefinition[] localDefinitions = tpl.getDefinitions(); + + List<XpandDefinition> advicedDefinitions = new ArrayList<XpandDefinition>(localDefinitions.length); + + for (int i = 0; i < localDefinitions.length; i++) { XpandDefinition xpandDefinition = localDefinitions[i]; for (int x = registeredAdvices.size() - 1; x >= 0; x--) { final XpandAdvice adv = registeredAdvices.get(x); @@ -124,164 +139,177 @@ public class XpandExecutionContextImpl extends ExecutionContextImpl implements X } advicedDefinitions.add(xpandDefinition); } - - return advicedDefinitions; - - } - - public XpandDefinition findDefinition(final String name, final Type target, final Type[] paramTypes) { - XpandResource tpl = null; - if (name.indexOf(SyntaxConstants.NS_DELIM) != -1) { // local call - tpl = findTemplate(XpandUtil.withoutLastSegment(name)); - } else { - tpl = (XpandResource) currentResource(); - } - if (tpl == null) - return null; - final XpandExecutionContext ctx = (XpandExecutionContext) cloneWithResource(tpl); - XpandDefinition def = findDefinition(tpl.getDefinitions(), name, target, paramTypes, ctx); - for (int x = registeredAdvices.size() - 1; x >= 0; x--) { - final XpandAdvice adv = registeredAdvices.get(x); - if (adv.matches(def, this)) { - def = new AdvicedDefinition(adv, def); - } - } - return def; - } - - public void registerAdvices(final String fullyQualifiedName) { - final XpandResource tpl = findTemplate(fullyQualifiedName); - if (tpl == null) - throw new NoSuchTemplateException(fullyQualifiedName); - final XpandAdvice[] as = tpl.getAdvices(); - for (int i = 0; i < as.length; i++) { - final XpandAdvice advice = as[i]; - if (registeredAdvices.contains(advice)) { - log.warn("advice " + advice.toString() + " already registered!"); - } else { - registeredAdvices.add(advice); - } - } - } - - public ProtectedRegionResolver getProtectedRegionResolver() { - return protectedRegionResolver; - } - - public Output getOutput() { - return output; - } - - public XpandResource findTemplate(final String templateName) { - return findTemplate(templateName, getImportedNamespaces()); - } - - public XpandResource findTemplate(final String templateName, String[] importedNs) { - final List<?> possibleNames = typeSystem.getPossibleNames(templateName, importedNs); - for (final Iterator<?> iter = possibleNames.iterator(); iter.hasNext();) { - final String element = (String) iter.next(); - final XpandResource tpl = (XpandResource) resourceManager.loadResource(element, - XpandUtil.TEMPLATE_EXTENSION); - if (tpl != null) - return tpl; - } - return null; - } - - /** - * resolves the correct definition (using parametric polymorphism) - * - * @param definitions - * @param target - * @param paramTypes - * @return - */ - private XpandDefinition findDefinition(final XpandDefinition[] definitions, final String name, final Type target, - Type[] paramTypes, final XpandExecutionContext ctx) { - if (paramTypes == null) { - paramTypes = new Type[0]; - } - final Set<Callable> features = new HashSet<Callable>(); - for (int i = 0; i < definitions.length; i++) { - final XpandDefinition def = definitions[i]; - if (def.getParams().length == paramTypes.length) { - final List<Type> defsParamTypes = new ArrayList<Type>(); - Type t = null; - boolean complete = true; - for (int j = 0; j < paramTypes.length && complete; j++) { - t = ctx.getTypeForName(def.getParams()[j].getType().getValue()); - if (t == null) { - complete = false; - } - defsParamTypes.add(t); - } - t = ctx.getTypeForName(def.getTargetType()); - if (t == null) { - complete = false; - } - if (complete) { - features.add(new DefinitionOperationAdapter(def, def.getName(), t, defsParamTypes)); - } - } - } - final DefinitionOperationAdapter defAdapter = (DefinitionOperationAdapter) PolymorphicResolver.getOperation( - features, XpandUtil.getLastSegment(name), target, Arrays.asList(paramTypes)); - if (defAdapter != null) - return defAdapter.def; - return null; - } - - public class DefinitionOperationAdapter implements Operation { - - private String name; - - private Type owner; - - private List<Type> paramTypes; - - public XpandDefinition def; - - public DefinitionOperationAdapter(final XpandDefinition def, final String name, final Type owner, - final List<Type> paramTypes) { - this.name = name; - this.owner = owner; - this.paramTypes = paramTypes; - this.def = def; - } - - public String getName() { - return name; - } - - public Type getReturnType() { - throw new UnsupportedOperationException(); - } - - public Type getOwner() { - return owner; - } - - public List<Type> getParameterTypes() { - return paramTypes; - } - - public Object evaluate(final Object target, final Object[] params) { - throw new UnsupportedOperationException(); - } - - public String getDocumentation() { - return "Xpand definition " + getName() + " adapted in an Operation"; - } - - public Type getReturnType(final Type targetType, final Type[] paramTpes) { - return getReturnType(); - } - - } - - @Override - public void setFileEncoding(final String fileEncoding) { - resourceManager.setFileEncoding(fileEncoding); //TODO: make this immutable - the entire context should be immutable! - } + return advicedDefinitions; + + } + + public XpandDefinition findDefinition(final String name, final Type target, final Type[] paramTypes) { + XpandResource tpl = null; + if (name.indexOf(SyntaxConstants.NS_DELIM) != -1) { // local call + tpl = findTemplate(XpandUtil.withoutLastSegment(name)); + } + else { + tpl = (XpandResource) currentResource(); + } + if (tpl == null) + return null; + final XpandExecutionContext ctx = (XpandExecutionContext) cloneWithResource(tpl); + XpandDefinition def = findDefinition(tpl.getDefinitions(), name, target, paramTypes, ctx); + for (int x = registeredAdvices.size() - 1; x >= 0; x--) { + final XpandAdvice adv = registeredAdvices.get(x); + if (adv.matches(def, this)) { + def = new AdvicedDefinition(adv, def); + } + } + return def; + } + + public void registerAdvices(final String fullyQualifiedName) { + final XpandResource tpl = findTemplate(fullyQualifiedName); + if (tpl == null) + throw new NoSuchTemplateException(fullyQualifiedName); + final XpandAdvice[] as = tpl.getAdvices(); + for (int i = 0; i < as.length; i++) { + final XpandAdvice advice = as[i]; + if (registeredAdvices.contains(advice)) { + log.warn("advice " + advice.toString() + " allready registered!"); + } + else { + registeredAdvices.add(advice); + } + } + } + + public ProtectedRegionResolver getProtectedRegionResolver() { + return protectedRegionResolver; + } + + public Output getOutput() { + return output; + } + + public XpandResource findTemplate(final String templateName) { + return findTemplate(templateName, getImportedNamespaces()); + } + + public XpandResource findTemplate(final String templateName, String[] importedNs) { + final List<?> possibleNames = typeSystem.getPossibleNames(templateName, importedNs); + for (final Iterator<?> iter = possibleNames.iterator(); iter.hasNext();) { + final String element = (String) iter.next(); + final XpandResource tpl = (XpandResource) resourceManager.loadResource(element, + XpandUtil.TEMPLATE_EXTENSION); + if (tpl != null) + return tpl; + } + return null; + } + + /** + * resolves the correct definition (using parametric polymorphism) + * + * @param definitions + * @param target + * @param paramTypes + * @return + */ + private XpandDefinition findDefinition(final XpandDefinition[] definitions, final String name, final Type target, + Type[] paramTypes, final XpandExecutionContext ctx) { + if (paramTypes == null) { + paramTypes = new Type[0]; + } + final Set<Callable> features = new HashSet<Callable>(); + for (int i = 0; i < definitions.length; i++) { + final XpandDefinition def = definitions[i]; + if (def.getParams().length == paramTypes.length) { + final List<Type> defsParamTypes = new ArrayList<Type>(); + Type t = null; + boolean complete = true; + for (int j = 0; j < paramTypes.length && complete; j++) { + t = ctx.getTypeForName(def.getParams()[j].getType().getValue()); + if (t == null) { + complete = false; + } + defsParamTypes.add(t); + } + t = ctx.getTypeForName(def.getTargetType()); + if (t == null) { + complete = false; + } + if (complete) { + features.add(new DefinitionOperationAdapter(def, def.getName(), t, defsParamTypes)); + } + } + } + final DefinitionOperationAdapter defAdapter = (DefinitionOperationAdapter) PolymorphicResolver.getOperation( + features, XpandUtil.getLastSegment(name), target, Arrays.asList(paramTypes)); + if (defAdapter != null) + return defAdapter.def; + return null; + } + + public class DefinitionOperationAdapter implements Operation { + + private String name; + + private Type owner; + + private List<Type> paramTypes; + + public XpandDefinition def; + + public DefinitionOperationAdapter(final XpandDefinition def, final String name, final Type owner, + final List<Type> paramTypes) { + this.name = name; + this.owner = owner; + this.paramTypes = paramTypes; + this.def = def; + } + + public String getName() { + return name; + } + + public Type getReturnType() { + throw new UnsupportedOperationException(); + } + + public Type getOwner() { + return owner; + } + + public List<Type> getParameterTypes() { + return paramTypes; + } + + public Object evaluate(final Object target, final Object[] params) { + throw new UnsupportedOperationException(); + } + + public String getDocumentation() { + return "Xpand definition " + getName() + " adapted in an Operation"; + } + + public Type getReturnType(final Type targetType, final Type[] paramTpes) { + return getReturnType(); + } + + } + + @Override + public void setFileEncoding(final String fileEncoding) { + resourceManager.setFileEncoding(fileEncoding); // TODO: make this + // immutable - the + // entire context should + // be immutable! + } + + public void setResourceManager(ResourceManager resourceManager) { + registerParser(resourceManager); + this.resourceManager = resourceManager; + } + + public void setCallBack(Callback callback) { + this.callback = callback; + } } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java index 548edaf7..c4c0f6b7 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandUtil.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandUtil.java index c307b5b5..f08944a1 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandUtil.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandUtil.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java index a9140732..c8e3b96a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/BlankLineSkippingOutput.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandle.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandle.java index a561a51b..82d514a6 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandle.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandle.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java index 44ff7891..d0ad862c 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/FileHandleImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/JavaBeautifier.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/JavaBeautifier.java index fe074312..31f2512a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/JavaBeautifier.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/JavaBeautifier.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/NoChangesVetoStrategy.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/NoChangesVetoStrategy.java index 35464ef6..6c894c6a 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/NoChangesVetoStrategy.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/NoChangesVetoStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java index 069661a2..670b81d3 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Outlet.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java index 83f633af..6e494e7e 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/Output.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java index 13e6dd0e..21bc9418 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/OutputImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/PostProcessor.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/PostProcessor.java index 70c1338c..2d151977 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/PostProcessor.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/PostProcessor.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java new file mode 100644 index 00000000..d4626c84 --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoException.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +package org.eclipse.xpand2.output; + +/** + * Signals a veto by a {@link VetoStrategy2} implementation. + * + * @author thoms + * @since 4.3.1 + */ +public class VetoException extends RuntimeException { + private static final long serialVersionUID = 8376169402481644160L; + + public VetoException(String message) { + super(message); + } + +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java index a504b818..9123e6b5 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy.java @@ -1,23 +1,24 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ + package org.eclipse.xpand2.output; public interface VetoStrategy { - + /** - * Called before the file will be written - * and <b>after</b> beforeWriteAndClose() has been invoked on all post processors. - * @param impl A handle to the file that will be written + * Called before the file will be written and <b>after</b> + * beforeWriteAndClose() has been invoked on all post processors. + * + * @param impl + * A handle to the file that will be written * @return if hasVeto returns true the file will not be written */ boolean hasVeto(FileHandle handle); - + } diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java new file mode 100644 index 00000000..2cb6067b --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/VetoStrategy2.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +package org.eclipse.xpand2.output; + +/** + * + * @author thoms + * @since 4.3.1 + */ +public interface VetoStrategy2 extends VetoStrategy { + + /** + * Called before the file will be opened and generated. + * + * @param impl + * A handle to the file that will be generated + * @return if hasVetoBeforeOpen returns true the file will not be opened nor + * generated + */ + boolean hasVetoBeforeOpen(FileHandle handle); + +} diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/XmlBeautifier.java b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/XmlBeautifier.java index e5249084..eec572e2 100644 --- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/XmlBeautifier.java +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/XmlBeautifier.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand2.output; diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/package.html new file mode 100644 index 00000000..869f09cc --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/output/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Generator output handling +</body> +</html> diff --git a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/package.html b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/package.html new file mode 100644 index 00000000..08b9f27d --- /dev/null +++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:23 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of the Xpand language +</body> +</html> diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java index ccf62c18..8b1e74e4 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllAllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllTests.java index 9d35f043..77949265 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionAnalyzationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionAnalyzationTest.java index 057d99d1..a412cddb 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionAnalyzationTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionAnalyzationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionEvaluationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionEvaluationTest.java index aca3d89c..90659e2c 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionEvaluationTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/ExtensionEvaluationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; @@ -35,9 +33,7 @@ public class ExtensionEvaluationTest extends TestCase { @Override protected void setUp() throws Exception { ec = new ExecutionContextImpl(); - ec - .registerMetaModel(new JavaMetaModel("asdf", - new JavaBeansStrategy())); + ec.registerMetaModel(new JavaMetaModel("asdf", new JavaBeansStrategy())); } private ExtensionFile parse(final String expression) { @@ -50,11 +46,7 @@ public class ExtensionEvaluationTest extends TestCase { + "String privateHelper(String str) : JAVA org.eclipse.xtend.Helper.privateHelper(java.lang.String) ; \n" + "\n" + "String nonStaticHelper(String str) : JAVA org.eclipse.xtend.Helper.nonStaticHelper(java.lang.String) ; \n" - + "\n" - + "/* \n" - + " * Meine Funktion \n" - + " */ \n" - + "myExtension(Object val) : {val} ; \n"); + + "\n" + "/* \n" + " * Meine Funktion \n" + " */ \n" + "myExtension(Object val) : {val} ; \n"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); final Object[] params = new Object[] { "test" }; @@ -62,8 +54,7 @@ public class ExtensionEvaluationTest extends TestCase { assertEquals("TEST", ext.evaluate(params, ec)); ext = ec.getExtension("myExtension", params); - assertEquals(Collections.singletonList("test"), ext - .evaluate(params, ec)); + assertEquals(Collections.singletonList("test"), ext.evaluate(params, ec)); } public final void testJavaExtension2() { @@ -71,8 +62,7 @@ public class ExtensionEvaluationTest extends TestCase { + "org.eclipse.xtend.Helper.union(java.util.Collection,java.util.Collection) ; \n"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); - final Object[] params = new Object[] { Collections.singleton("1"), - Collections.singleton("2") }; + final Object[] params = new Object[] { Collections.singleton("1"), Collections.singleton("2") }; final Extension ext = ec.getExtension("union", params); final Collection result = (Collection) ext.evaluate(params, ec); assertTrue(result.size() == 2); @@ -81,26 +71,21 @@ public class ExtensionEvaluationTest extends TestCase { } public final void testPolymorphism() { - final ExtensionFile file = parse("ext(Object val) : 'Object' ; \n" - + "ext(List[Object] val) : 'List' ; \n" - + "ext(Collection[Object] val) : 'Collection' ; \n" - + "ext(Integer val) : 'Integer' ; \n"); + final ExtensionFile file = parse("ext(Object val) : 'Object' ; \n" + "ext(List[Object] val) : 'List' ; \n" + + "ext(Collection[Object] val) : 'Collection' ; \n" + "ext(Integer val) : 'Integer' ; \n"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); Extension ext = ec.getExtension("ext", new Object[] { "test" }); assertEquals("Object", ext.evaluate(new Object[] { "test" }, ec)); ext = ec.getExtension("ext", new Object[] { Collections.EMPTY_SET }); - assertEquals("Collection", ext.evaluate( - new Object[] { Collections.EMPTY_SET }, ec)); + assertEquals("Collection", ext.evaluate(new Object[] { Collections.EMPTY_SET }, ec)); ext = ec.getExtension("ext", new Object[] { Collections.EMPTY_LIST }); - assertEquals("List", ext.evaluate( - new Object[] { Collections.EMPTY_LIST }, ec)); + assertEquals("List", ext.evaluate(new Object[] { Collections.EMPTY_LIST }, ec)); ext = ec.getExtension("ext", new Object[] { new Integer(2) }); - assertEquals("Integer", ext.evaluate(new Object[] { new Integer(2) }, - ec)); + assertEquals("Integer", ext.evaluate(new Object[] { new Integer(2) }, ec)); } @@ -109,21 +94,18 @@ public class ExtensionEvaluationTest extends TestCase { ec = (ExecutionContextImpl) ec.cloneWithResource(file); - final Extension ext = ec.getExtension("recExtension", new Object[] { - new Long(5), new Long(10) }); + final Extension ext = ec.getExtension("recExtension", new Object[] { new Long(5), new Long(10) }); final List<Long> expected = new ArrayList<Long>(); for (int i = 5; i <= 10; i++) { expected.add(new Long(i)); } - final Object evalResult = ext.evaluate(new Object[] { new Long(5), - new Long(10) }, ec); + final Object evalResult = ext.evaluate(new Object[] { new Long(5), new Long(10) }, ec); assertEquals(expected, evalResult); } public final void testMemberPosition() { - final ExtensionFile file = parse("ext1(String txt) : 'test'+txt ;" - + "ext2(String txt) : txt.ext1() ;"); + final ExtensionFile file = parse("ext1(String txt) : 'test'+txt ;" + "ext2(String txt) : txt.ext1() ;"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); final Extension ext = ec.getExtension("ext2", new Object[] { "fall" }); @@ -132,16 +114,16 @@ public class ExtensionEvaluationTest extends TestCase { } - public final void testCachedExtension() { final ExtensionFile file = parse("cached String ext(String txt) : JAVA org.eclipse.xtend.ExtensionEvaluationTest.testMethod(java.lang.String);"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); final Extension ext = ec.getExtension("ext", new Object[] { "test" }); - assertEquals("test0", ext.evaluate(new Object[] { "test" }, ec)); - assertEquals("test0", ext.evaluate(new Object[] { "test" }, ec)); - assertEquals("test0", ext.evaluate(new Object[] { "test" }, ec)); - assertEquals("test0", ext.evaluate(new Object[] { "test" }, ec)); + String expected = "test" + String.valueOf(magic); + assertEquals(expected, ext.evaluate(new Object[] { "test" }, ec)); + assertEquals(expected, ext.evaluate(new Object[] { "test" }, ec)); + assertEquals(expected, ext.evaluate(new Object[] { "test" }, ec)); + assertEquals(expected, ext.evaluate(new Object[] { "test" }, ec)); } private static int magic = 0; @@ -153,8 +135,7 @@ public class ExtensionEvaluationTest extends TestCase { public final void testCreateExtension() { final ExtensionFile file = parse("create List l test(String s) : l.add(s) ;"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); - final List l = (List) ((Extension) file.getExtensions().get(0)) - .evaluate(new String[] { "test" }, ec); + final List l = (List) (file.getExtensions().get(0)).evaluate(new String[] { "test" }, ec); assertEquals(Collections.singletonList("test"), l); } @@ -162,31 +143,29 @@ public class ExtensionEvaluationTest extends TestCase { public final void testCreateExtension1() { final ExtensionFile file = parse("create List test(String s) : add(s) ;"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); - final List l = (List) ((Extension) file.getExtensions().get(0)) - .evaluate(new String[] { "test" }, ec); + final List l = (List) (file.getExtensions().get(0)).evaluate(new String[] { "test" }, ec); assertEquals(Collections.singletonList("test"), l); } public final void testAmbigous() { - final ExtensionFile file = parse("import " - + TypeA.class.getPackage().getName().replaceAll("\\.", "::") - + ";" + "doStuff(TypeA this) : true; " - + "doStuff(TypeC this) : false;"); + final ExtensionFile file = parse("import " + TypeA.class.getPackage().getName().replaceAll("\\.", "::") + ";" + + "doStuff(TypeA this) : true; " + "doStuff(TypeC this) : false;"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); assertNotNull(ec.getExtension("doStuff", new Object[] { new TypeA() })); try { ec.getExtension("doStuff", new Object[] { new TypeB() }); fail("Ambigous operation exception expected"); - } catch (final RuntimeException re) { + } + catch (final RuntimeException re) { // expected System.out.println(re.getMessage()); } } public final void testBug134626() { - final ExtensionFile file = parse("String someExt(TestA someA) : JAVA " - + getClass().getName() + "(java.lang.String) ; \n"); + final ExtensionFile file = parse("String someExt(TestA someA) : JAVA " + getClass().getName() + + "(java.lang.String) ; \n"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); } @@ -196,8 +175,7 @@ public class ExtensionEvaluationTest extends TestCase { } public void testAdvices() throws Exception { - final ExtensionFile file = parse("doStuff() : '_THE_'; " - + "doStuff(String s) : s;"); + final ExtensionFile file = parse("doStuff() : '_THE_'; " + "doStuff(String s) : s;"); ec = (ExecutionContextImpl) ec.cloneWithResource(file); ec.registerExtensionAdvices("org::eclipse::xtend::Advices"); @@ -206,8 +184,7 @@ public class ExtensionEvaluationTest extends TestCase { } - private Object call(ExecutionContextImpl ctx, String string, - Object... params) { + private Object call(ExecutionContextImpl ctx, String string, Object... params) { Extension ext = ctx.getExtension(string, params); return ext.evaluate(params, ctx); } diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/Helper.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/Helper.java index fbbbe44e..f0ad2131 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/Helper.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/Helper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendComponentTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendComponentTest.java index 2a64a523..e0823dac 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendComponentTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendComponentTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendFacadeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendFacadeTest.java index 63a7996e..9906fa69 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendFacadeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/XtendFacadeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/AllTests.java index 5f7e112c..ea54aec8 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.check; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckAnalyzationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckAnalyzationTest.java index 769cbf6e..fdabbca0 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckAnalyzationTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckAnalyzationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckEvaluationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckEvaluationTest.java index 30d64477..9df1f200 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckEvaluationTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckEvaluationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckFastAnalyzerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckFastAnalyzerTest.java index 737a7340..5633598f 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckFastAnalyzerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/CheckFastAnalyzerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/FeaturedCheckTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/FeaturedCheckTest.java index d1039c7f..cce5995a 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/FeaturedCheckTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/FeaturedCheckTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/Helper.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/Helper.java index 5b0ec1c5..388e02a8 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/Helper.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/check/Helper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/AllTests.java index a19661e4..f56725c5 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.codeassist; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/FastAnalyzerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/FastAnalyzerTest.java index 734f5649..cb126673 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/FastAnalyzerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/codeassist/FastAnalyzerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.codeassist; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/AllTests.java index 73100757..bf31ba29 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.expression; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java index 66c95d9c..50a0fbed 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/EvaluationExceptionTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ExecutionContextImplTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ExecutionContextImplTest.java index ef6ba469..4e607344 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ExecutionContextImplTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ExecutionContextImplTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/PolymorphismTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/PolymorphismTest.java index 9faaadb7..3d2be2a4 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/PolymorphismTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/PolymorphismTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ResourceManagerDefaultImplTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ResourceManagerDefaultImplTest.java index 402fa388..44aec9d2 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ResourceManagerDefaultImplTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ResourceManagerDefaultImplTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; @@ -18,10 +16,9 @@ import java.io.StringWriter; import junit.framework.TestCase; public class ResourceManagerDefaultImplTest extends TestCase { - private static final String LINE_WRAP = System - .getProperty("line.separator"); - private final static String CONTENT = tag("IMPORT ecore") + LINE_WRAP - + tag("AROUND Root FOR EPackage") + LINE_WRAP + tag("ENDAROUND"); + private static final String LINE_WRAP = System.getProperty("line.separator"); + private final static String CONTENT = tag("IMPORT ecore") + LINE_WRAP + tag("AROUND Root FOR EPackage") + LINE_WRAP + + tag("ENDAROUND"); class TestResourcManager extends ResourceManagerDefaultImpl { public Reader _createReader(InputStream in) { @@ -51,18 +48,26 @@ public class ResourceManagerDefaultImplTest extends TestCase { checkResourceLoading(null, "templatefile-macroman.xpt"); } - private void checkResourceLoading(String encoding, String testfile) - throws IOException { + private void checkResourceLoading(String encoding, String testfile) throws IOException { resMgr.setFileEncoding(encoding); InputStream is = getClass().getResourceAsStream(testfile); assertNotNull(is); Reader reader = resMgr._createReader(is); String read = read(reader); assertNotNull(read); - assertEquals(CONTENT, read); + assertEquals(unifyLineWrap(CONTENT), unifyLineWrap(read)); } + private String unifyLineWrap(String s) { + if (s == null) + return null; + + String res = s.replaceAll("\\r\\n", "\n"); + res = res.replaceAll("\\r", "\n"); + return res; + } + private String read(Reader r) throws IOException { StringWriter s = new StringWriter(); char[] buf = new char[1024]; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type1.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type1.java index dfe9f639..278f6100 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type1.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type1.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type2.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type2.java index c7ada1db..d95de777 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type2.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type2.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type3.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type3.java index 549bf03f..288764a7 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type3.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/Type3.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/TypeNameUtilTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/TypeNameUtilTest.java index 2f19fa51..17f86590 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/TypeNameUtilTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/TypeNameUtilTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AType.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AType.java index 18c07435..05c47b5c 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AType.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AllTests.java index 890e59ea..c62dada9 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.expression.ast; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AnalyzationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AnalyzationTest.java index 08c5888a..7e269746 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AnalyzationTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/AnalyzationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java index 78f0efed..0486426e 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/EvaluationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestMetaModel.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestMetaModel.java index 12ef64c1..c0607378 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestMetaModel.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestMetaModel.java @@ -1,16 +1,11 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ -/** - * - */ package org.eclipse.xtend.expression.ast; import java.util.Collections; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestType.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestType.java index de4c7588..f5ad6e31 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestType.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/ast/TestType.java @@ -1,13 +1,11 @@ -/* -Copyright (c) 2008 Arno Haase. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/epl-v10.html - -Contributors: - Arno Haase - initial API and implementation - */ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.expression.ast; import java.util.Arrays; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/AllTests.java index b728e386..0818ea73 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.expression.codeassist; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExpressionProposalComputerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExpressionProposalComputerTest.java index c1afa3f9..d13bbec3 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExpressionProposalComputerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExpressionProposalComputerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExtensionImportProposalComputerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExtensionImportProposalComputerTest.java index 32b617c7..3f54b7dd 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExtensionImportProposalComputerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ExtensionImportProposalComputerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ReverseScannerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ReverseScannerTest.java index 95d1c0fd..df2b9876 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ReverseScannerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/ReverseScannerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/TypeProposalComputerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/TypeProposalComputerTest.java index 72bf6443..9680e778 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/TypeProposalComputerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/codeassist/TypeProposalComputerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/AllTests.java index 7e2f9793..4d2194e6 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.expression.parser; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ParserTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ParserTest.java index db7c1165..16a80235 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ParserTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ParserTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.parser; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ScannerTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ScannerTest.java index 47f3a429..a06268e6 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ScannerTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/expression/parser/ScannerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression.parser; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/AllTests.java index 5289ab4c..4fe4bd30 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.parser; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/ExtensionParserTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/ExtensionParserTest.java index b62e670f..cd01347a 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/ExtensionParserTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/parser/ExtensionParserTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.parser; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/AllTests.java index 5dc7cb65..4973f610 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/CollectionFeaturesTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/CollectionFeaturesTest.java index 5050b792..783e4abd 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/CollectionFeaturesTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/CollectionFeaturesTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl; @@ -29,75 +27,75 @@ import org.eclipse.xtend.expression.ExpressionFacade; * @author Bernd Kolb */ public class CollectionFeaturesTest extends TestCase { - ExecutionContextImpl ec; - - private ExpressionFacade ef; - - private ArrayList<String> vals; - - @Override - protected void setUp() throws Exception { - vals = new ArrayList<String>(); - vals.add("1"); - vals.add("2"); - vals.add("3"); - vals.add("4"); - vals.add("5"); - ec = new ExecutionContextImpl(); - ec.registerMetaModel(new JavaMetaModel("asdf", new JavaBeansStrategy())); - ef = new ExpressionFacade(ec); - } - - public final void testSelect() { - final Collection result = (Collection) ef.evaluate("vals.select(s| s >= \"3\")", Collections.singletonMap( - "vals", vals)); - assertEquals(3, result.size()); - assertTrue(result.contains("3")); - assertTrue(result.contains("4")); - assertTrue(result.contains("5")); - } - - public final void testSelectFirst() { - final Object result = ef.evaluate("vals.selectFirst(s| s >= \"3\")", Collections.singletonMap( - "vals", vals)); - assertEquals("3", result); - } - - public final void testContains() { - final Boolean result = (Boolean)ef.evaluate("vals.contains(\"3\")", Collections.singletonMap( - "vals", vals)); - assertTrue(result.booleanValue()); - } - - public final void testContainsAll() { - final Boolean result = (Boolean)ef.evaluate("vals.containsAll({\"3\",\"4\"})", Collections.singletonMap( - "vals", vals)); - assertTrue(result.booleanValue()); - } - - public final void testCollect() { - final Collection result = (Collection) ef.evaluate("vals.collect( s| s.length)", Collections.singletonMap( - "vals", vals)); - assertEquals(5, result.size()); - for (final Iterator iter = result.iterator(); iter.hasNext();) { - assertEquals(new Long(1), iter.next()); - } - } - - public final void testExists() { - assertEquals(Boolean.TRUE, ef.evaluate("vals.exists(s| s == \"3\")", Collections.singletonMap("vals", vals))); - assertEquals(Boolean.FALSE, ef.evaluate("vals.exists(s| s == \"33\")", Collections.singletonMap("vals", vals))); - } - - public final void testNotExists() { - assertEquals(Boolean.FALSE, ef.evaluate("vals.notExists(s| s == \"3\")", Collections.singletonMap("vals", vals))); - assertEquals(Boolean.TRUE, ef.evaluate("vals.notExists(s| s == \"33\")", Collections.singletonMap("vals", vals))); - } - - public final void testForAll() { - assertEquals(Boolean.FALSE, ef.evaluate("{}.forAll(s | true)")); - assertEquals(Boolean.TRUE, ef.evaluate("vals.forAll(s| s.length == 1)", Collections.singletonMap("vals", vals))); - assertEquals(Boolean.FALSE, ef.evaluate("vals.forAll(s| s == \"3\")", Collections.singletonMap("vals", vals))); - } + ExecutionContextImpl ec; + + private ExpressionFacade ef; + + private ArrayList<String> vals; + + @Override + protected void setUp() throws Exception { + vals = new ArrayList<String>(); + vals.add("1"); + vals.add("2"); + vals.add("3"); + vals.add("4"); + vals.add("5"); + ec = new ExecutionContextImpl(); + ec.registerMetaModel(new JavaMetaModel("asdf", new JavaBeansStrategy())); + ef = new ExpressionFacade(ec); + } + + public final void testSelect() { + final Collection result = (Collection) ef.evaluate("vals.select(s| s >= \"3\")", Collections.singletonMap( + "vals", vals)); + assertEquals(3, result.size()); + assertTrue(result.contains("3")); + assertTrue(result.contains("4")); + assertTrue(result.contains("5")); + } + + public final void testSelectFirst() { + final Object result = ef.evaluate("vals.selectFirst(s| s >= \"3\")", Collections.singletonMap("vals", vals)); + assertEquals("3", result); + } + + public final void testContains() { + final Boolean result = (Boolean) ef.evaluate("vals.contains(\"3\")", Collections.singletonMap("vals", vals)); + assertTrue(result.booleanValue()); + } + + public final void testContainsAll() { + final Boolean result = (Boolean) ef.evaluate("vals.containsAll({\"3\",\"4\"})", Collections.singletonMap( + "vals", vals)); + assertTrue(result.booleanValue()); + } + + public final void testCollect() { + final Collection result = (Collection) ef.evaluate("vals.collect( s| s.length)", Collections.singletonMap( + "vals", vals)); + assertEquals(5, result.size()); + for (final Iterator iter = result.iterator(); iter.hasNext();) { + assertEquals(new Long(1), iter.next()); + } + } + + public final void testExists() { + assertEquals(Boolean.TRUE, ef.evaluate("vals.exists(s| s == \"3\")", Collections.singletonMap("vals", vals))); + assertEquals(Boolean.FALSE, ef.evaluate("vals.exists(s| s == \"33\")", Collections.singletonMap("vals", vals))); + } + + public final void testNotExists() { + assertEquals(Boolean.FALSE, ef + .evaluate("vals.notExists(s| s == \"3\")", Collections.singletonMap("vals", vals))); + assertEquals(Boolean.TRUE, ef + .evaluate("vals.notExists(s| s == \"33\")", Collections.singletonMap("vals", vals))); + } + + public final void testForAll() { + assertEquals(Boolean.TRUE, ef.evaluate("{}.forAll(s | true)")); + assertEquals(Boolean.TRUE, ef.evaluate("vals.forAll(s| s.length == 1)", Collections.singletonMap("vals", vals))); + assertEquals(Boolean.FALSE, ef.evaluate("vals.forAll(s| s == \"3\")", Collections.singletonMap("vals", vals))); + } } diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/ObjectFeaturesTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/ObjectFeaturesTest.java index 9d705d05..9a7fcf47 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/ObjectFeaturesTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/ObjectFeaturesTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/TypesComparatorTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/TypesComparatorTest.java index 92b1264d..06597409 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/TypesComparatorTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/TypesComparatorTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/AllTests.java index 3be695f8..ad24d217 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/BooleanTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/BooleanTypeTest.java index 857b6e24..eb601801 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/BooleanTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/BooleanTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/CollectionTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/CollectionTypeTest.java index 6d3cd424..8e1c7879 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/CollectionTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/CollectionTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/EnumTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/EnumTest.java index 720c01a2..76c5a133 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/EnumTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/EnumTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/IntegerTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/IntegerTypeTest.java index 73d9056e..c4ba12f5 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/IntegerTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/IntegerTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyClass.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyClass.java index d2181338..ccbbea23 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyClass.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyClass.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyEnum.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyEnum.java index 90fd5015..6c9edde6 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyEnum.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/MyEnum.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/ObjectTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/ObjectTypeTest.java index 79ef2f05..906bd25b 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/ObjectTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/ObjectTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/RealTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/RealTypeTest.java index 196c4dfa..51e874fe 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/RealTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/RealTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/StringTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/StringTypeTest.java index d3f4743c..d6332b5c 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/StringTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/StringTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/TypeTypeTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/TypeTypeTest.java index 4f4165a4..c8991476 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/TypeTypeTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/baseimpl/types/TypeTypeTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.baseimpl.types; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java index f77f68df..3ba2fcca 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/AllTests.java @@ -1,9 +1,10 @@ /******************************************************************************* - * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java index 69afb78d..de2a1830 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorPluginTests.java @@ -1,14 +1,10 @@ /******************************************************************************* - * <copyright> - * Copyright (c) 2008 itemis AG and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation - * </copyright> *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java index 14e59f96..bd5118e8 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/OawValidatorStandaloneTests.java @@ -1,14 +1,10 @@ /******************************************************************************* - * <copyright> - * Copyright (c) 2008 itemis AG and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation - * </copyright> *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java index f70306d6..cf8fc800 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/AllTests.java @@ -1,9 +1,10 @@ /******************************************************************************* - * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html + * *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.cache; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java index ddca185d..db1834be 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/cache/CachedExtensionTest.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.cache; import junit.framework.TestCase; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java index 125eaaec..7b36156e 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/HelloPDE.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model; public class HelloPDE { diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java index fc7a4809..a5f16038 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyEnum.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: MyEnum.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test; import java.util.Arrays; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java index 62083a76..7192c622 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/MyMetaClass.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: MyMetaClass.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test; import org.eclipse.emf.common.util.EList; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java index 90449625..9d3326fd 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestFactory.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: TestFactory.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test; import org.eclipse.emf.ecore.EFactory; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java index c9a2d775..d722201b 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/TestPackage.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: TestPackage.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test; import org.eclipse.emf.ecore.EAttribute; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java index 118e73bf..4fb887bb 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/MyMetaClassImpl.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: MyMetaClassImpl.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.impl; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java index 6127056f..3b258bdd 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestFactoryImpl.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: TestFactoryImpl.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.impl; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java index 276616f0..30e9dfe4 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/impl/TestPackageImpl.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: TestPackageImpl.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.impl; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java index 2747ac9e..e0bac143 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageFactory.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackageFactory.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage; import org.eclipse.emf.ecore.EFactory; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java index b8942276..8a4936a7 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackageMetaClass.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackageMetaClass.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage; import org.eclipse.emf.ecore.EObject; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java index 89bc3463..e8796c71 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/SubpackagePackage.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackagePackage.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage; import org.eclipse.emf.ecore.EAttribute; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java index 28146471..07d1b376 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageFactoryImpl.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackageFactoryImpl.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl; import org.eclipse.emf.ecore.EClass; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java index 55c7cbad..85e32cdb 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackageMetaClassImpl.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackageMetaClassImpl.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl; import org.eclipse.emf.common.notify.Notification; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java index f617dd1a..7c22a552 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/impl/SubpackagePackageImpl.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackagePackageImpl.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.impl; import org.eclipse.emf.ecore.EAttribute; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java index b79d88f0..af748f32 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageAdapterFactory.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackageAdapterFactory.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.util; import org.eclipse.emf.common.notify.Adapter; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java index fd81280a..a3a094c2 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/subpackage/util/SubpackageSwitch.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: SubpackageSwitch.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.subpackage.util; import java.util.List; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java index a151fc72..4350cd5b 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestAdapterFactory.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: TestAdapterFactory.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.util; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java index 2f3c91c5..9e6322be 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/util/TestSwitch.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: TestSwitch.java,v 1.2 2008/11/26 12:46:25 dhubner Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.util; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java index ec5cc63d..78674740 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/emf/check/model/test/validation/MyMetaClassValidator.java @@ -1,9 +1,11 @@ -/** - * <copyright> - * </copyright> +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html * - * $Id: MyMetaClassValidator.java,v 1.1 2008/10/21 07:32:51 jkohnlein Exp $ - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check.model.test.validation; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/AllTests.java index 120eb36f..850f3771 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.javabeans; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansMetaType.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansMetaType.java index f3bb6b75..b0882214 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansMetaType.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansMetaType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.javabeans; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansStrategyTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansStrategyTest.java index 6387027e..4d93bbae 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansStrategyTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/JavaBeansStrategyTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.javabeans; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/MyMetaTypeInterface.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/MyMetaTypeInterface.java index 7156351b..f781cdad 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/MyMetaTypeInterface.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/javabeans/MyMetaTypeInterface.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.javabeans; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/AllTests.java index 5c5f716b..b0b6cc4a 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.oawclassic; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicMetaType.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicMetaType.java index 51edcfbb..4dbae14a 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicMetaType.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicMetaType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.oawclassic; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicStrategyTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicStrategyTest.java index 37e3c364..0464cc2b 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicStrategyTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/impl/oawclassic/OawClassicStrategyTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.impl.oawclassic; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/AllTests.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/AllTests.java index 09e8c2dd..d48c6ff2 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/AllTests.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; import junit.framework.Test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/InterfaceD.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/InterfaceD.java index fd842b8c..02cb1c88 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/InterfaceD.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/InterfaceD.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/JavaTest.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/JavaTest.java index 066d552f..0ffeb7fa 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/JavaTest.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/JavaTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/Mib.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/Mib.java index 9d844355..85e7f291 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/Mib.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/Mib.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/OAWTypeD.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/OAWTypeD.java index 5a62f0e1..206fd4aa 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/OAWTypeD.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/OAWTypeD.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeA.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeA.java index 23675369..6ec8be1f 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeA.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeA.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeB.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeB.java index b553d309..36299008 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeB.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeB.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeC.java b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeC.java index 307feb59..b6c883fb 100644 --- a/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeC.java +++ b/plugins/org.eclipse.xtend.tests/src/org/eclipse/xtend/typesystem/javabeansimpl/test/TypeC.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.javabeansimpl.test; diff --git a/plugins/org.eclipse.xtend.tests/src/test/Bean.java b/plugins/org.eclipse.xtend.tests/src/test/Bean.java index 0f7d3bb2..0ff449d6 100644 --- a/plugins/org.eclipse.xtend.tests/src/test/Bean.java +++ b/plugins/org.eclipse.xtend.tests/src/test/Bean.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package test; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java index 08a7f62e..7094f4ce 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EClassType.java @@ -1,17 +1,11 @@ -/** - * <copyright> - * - * Copyright (c) 2005-2006 Sven Efftinge (http://www.efftinge.de) and others. - * All rights reserved. This program and the accompanying materials +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Sven Efftinge (http://www.efftinge.de) - Initial API and implementation - * - * </copyright> - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; import java.lang.reflect.Method; @@ -41,147 +35,160 @@ import org.eclipse.xtend.typesystem.Type; public class EClassType extends AbstractTypeImpl { - private final static Log log = LogFactory.getLog(EClassType.class); - - private EmfRegistryMetaModel emfMetaModel; - - private EClass eClass; - - public EClassType(final EmfRegistryMetaModel model, final String name, final EClass class1) { - super(model.getTypeSystem(), name); - emfMetaModel = model; - eClass = class1; - } - - - @Override - public Feature[] getContributedFeatures() { - final Set<FeatureImpl> result = new HashSet<FeatureImpl>(); - // Attributes - List<EStructuralFeature> list = eClass.getEStructuralFeatures(); - for (final EStructuralFeature feature : list) { - final Type t = emfMetaModel.getTypeForETypedElement(feature); - if (t == null) { - log.warn("Couldn't resolve type for " + getTypeName(feature.getEType())); - } else { - result.add(new PropertyImpl(this, feature.getName(), t) { - - public Object get(final Object target) { - return ((EObject) target).eGet(feature); - } - - @Override - public void set(final Object target, Object newValue) { - if (feature.isChangeable() && !feature.isUnsettable() && !feature.isDerived()) { - if (feature.getEType() instanceof EDataType && !(feature.getEType() instanceof EEnum)) { - final EDataType dt = (EDataType) feature.getEType(); - newValue = getReturnType().convert(newValue, dt.getInstanceClass()); - } - ((EObject) target).eSet(feature, newValue); - } else - throw new UnsupportedOperationException("setting property '" + feature.getName() + "' is not allowed!"); - } - }); - } - } - // Operations - final List operations = eClass.getEOperations(); - for (final Iterator iter = operations.iterator(); iter.hasNext();) { - final EOperation op = (EOperation) iter.next(); - final EList emfParams = op.getEParameters(); - final Type[] paramTypes = new Type[emfParams.size()]; - boolean errors = false; - for (int i = 0, x = emfParams.size(); i < x; i++) { - final EParameter param = (EParameter) emfParams.get(i); - paramTypes[i] = emfMetaModel.getTypeForETypedElement(param); - if (paramTypes[i] == null) { - log.warn("Couldn't resolve type for " + getTypeName(param.getEType())); - errors = true; - } - } - final Type t = emfMetaModel.getTypeForETypedElement(op); - if (t == null) { - log.warn("Couldn't resolve type for " + getTypeName(op.getEType())); - errors = true; - } - if (!errors) { - - result.add(new OperationImpl(this, op.getName(), t, paramTypes) { - - @Override - protected Object evaluateInternal(final Object target, final Object[] params) { - final Class[] paramClasses = new Class[emfParams.size()]; - for (int i = 0, x = emfParams.size(); i < x; i++) { - final EParameter param = (EParameter) emfParams.get(i); - paramClasses[i] = param.getEType().getInstanceClass(); - params[i] = getParameterTypes().get(i).convert(params[i], paramClasses[i]); - } - try { - final Method m = target.getClass().getMethod(getName(), paramClasses); - return m.invoke(target, params); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - }); - } - } - // setter - for (final EStructuralFeature feature : (List<EStructuralFeature>) eClass.getEStructuralFeatures()) { - - final Type t = emfMetaModel.getTypeForETypedElement(feature); - if (t == null) { - log.warn("Couldn't resolve type for " + getTypeName(feature.getEType())); - } else { - if (feature.isChangeable() && !feature.isDerived()) { // !feature.isUnsettable() && - result.add(new OperationImpl(this, "set" + StringHelper.firstUpper(feature.getName()), this, new Type[] { t }) { - - @Override - protected Object evaluateInternal(final Object target, final Object[] params) { - Object newValue = params[0]; - if (newValue != null && feature.getEType() instanceof EDataType && !(feature.getEType() instanceof EEnum)) { - final EDataType dt = (EDataType) feature.getEType(); - newValue = getParameterTypes().get(0).convert(newValue, dt.getInstanceClass()); - } - ((EObject) target).eSet(feature, newValue); - return target; - } - - }); - } - } - } - return result.toArray(new Feature[result.size()]); - } - - private String getTypeName(EClassifier type) { - if (type==null) return "null"; - return type.getName(); - } - - public boolean isInstance(final Object o) { - return eClass.isInstance(o); - } - - public Object newInstance() { - return eClass.getEPackage().getEFactoryInstance().create(eClass); - } - - @Override - protected Set<Type> internalGetSuperTypes() { - final EList st = eClass.getESuperTypes(); - final Set<Type> result = new HashSet<Type>(); - for (final Iterator iter = st.iterator(); iter.hasNext();) { - final EClass element = (EClass) iter.next(); - result.add(emfMetaModel.getTypeForEClassifier(element)); - } - result.add(emfMetaModel.getEobjectType()); - return result; - } - - @Override - public boolean isAbstract() { - return eClass.isAbstract(); - } + private final static Log log = LogFactory.getLog(EClassType.class); + + private EmfRegistryMetaModel emfMetaModel; + + private EClass eClass; + + public EClassType(final EmfRegistryMetaModel model, final String name, final EClass class1) { + super(model.getTypeSystem(), name); + emfMetaModel = model; + eClass = class1; + } + + @Override + public Feature[] getContributedFeatures() { + final Set<FeatureImpl> result = new HashSet<FeatureImpl>(); + // Attributes + List<EStructuralFeature> list = eClass.getEStructuralFeatures(); + for (final EStructuralFeature feature : list) { + final Type t = emfMetaModel.getTypeForETypedElement(feature); + if (t == null) { + log.warn("Couldn't resolve type for " + getTypeName(feature.getEType())); + } + else { + result.add(new PropertyImpl(this, feature.getName(), t) { + + public Object get(final Object target) { + return ((EObject) target).eGet(feature); + } + + @Override + public void set(final Object target, Object newValue) { + if (feature.isChangeable() && !feature.isUnsettable() && !feature.isDerived()) { + if (feature.getEType() instanceof EDataType && !(feature.getEType() instanceof EEnum)) { + final EDataType dt = (EDataType) feature.getEType(); + newValue = getReturnType().convert(newValue, dt.getInstanceClass()); + } + ((EObject) target).eSet(feature, newValue); + } + else + throw new UnsupportedOperationException("setting property '" + feature.getName() + + "' is not allowed!"); + } + }); + } + } + // Operations + final List operations = eClass.getEOperations(); + for (final Iterator iter = operations.iterator(); iter.hasNext();) { + final EOperation op = (EOperation) iter.next(); + final EList emfParams = op.getEParameters(); + final Type[] paramTypes = new Type[emfParams.size()]; + boolean errors = false; + for (int i = 0, x = emfParams.size(); i < x; i++) { + final EParameter param = (EParameter) emfParams.get(i); + paramTypes[i] = emfMetaModel.getTypeForETypedElement(param); + if (paramTypes[i] == null) { + log.warn("Couldn't resolve type for " + getTypeName(param.getEType())); + errors = true; + } + } + final Type t = emfMetaModel.getTypeForETypedElement(op); + if (t == null) { + log.warn("Couldn't resolve type for " + getTypeName(op.getEType())); + errors = true; + } + if (!errors) { + + result.add(new OperationImpl(this, op.getName(), t, paramTypes) { + + @Override + protected Object evaluateInternal(final Object target, final Object[] params) { + final Class[] paramClasses = new Class[emfParams.size()]; + for (int i = 0, x = emfParams.size(); i < x; i++) { + final EParameter param = (EParameter) emfParams.get(i); + if (param.isMany()) { + paramClasses[i] = EList.class; + } + else { + paramClasses[i] = param.getEType().getInstanceClass(); + } + params[i] = getParameterTypes().get(i).convert(params[i], paramClasses[i]); + } + try { + final Method m = target.getClass().getMethod(getName(), paramClasses); + return m.invoke(target, params); + } + catch (final Exception e) { + throw new RuntimeException(e); + } + } + }); + } + } + // setter + for (final EStructuralFeature feature : eClass.getEStructuralFeatures()) { + + final Type t = emfMetaModel.getTypeForETypedElement(feature); + if (t == null) { + log.warn("Couldn't resolve type for " + getTypeName(feature.getEType())); + } + else { + if (feature.isChangeable() && !feature.isDerived()) { // !feature.isUnsettable() + // && + result.add(new OperationImpl(this, "set" + StringHelper.firstUpper(feature.getName()), this, + new Type[] { t }) { + + @Override + protected Object evaluateInternal(final Object target, final Object[] params) { + Object newValue = params[0]; + if (newValue != null && feature.getEType() instanceof EDataType + && !(feature.getEType() instanceof EEnum)) { + final EDataType dt = (EDataType) feature.getEType(); + newValue = getParameterTypes().get(0).convert(newValue, dt.getInstanceClass()); + } + ((EObject) target).eSet(feature, newValue); + return target; + } + + }); + } + } + } + return result.toArray(new Feature[result.size()]); + } + + private String getTypeName(EClassifier type) { + if (type == null) + return "null"; + return type.getName(); + } + + public boolean isInstance(final Object o) { + return eClass.isInstance(o); + } + + public Object newInstance() { + return eClass.getEPackage().getEFactoryInstance().create(eClass); + } + + @Override + protected Set<Type> internalGetSuperTypes() { + final EList st = eClass.getESuperTypes(); + final Set<Type> result = new HashSet<Type>(); + for (final Iterator iter = st.iterator(); iter.hasNext();) { + final EClass element = (EClass) iter.next(); + result.add(emfMetaModel.getTypeForEClassifier(element)); + } + result.add(emfMetaModel.getEobjectType()); + return result; + } + + @Override + public boolean isAbstract() { + return eClass.isAbstract(); + } } diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EDataTypeType.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EDataTypeType.java index d13344ff..90c515e5 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EDataTypeType.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EDataTypeType.java @@ -1,17 +1,11 @@ -/** - * <copyright> - * - * Copyright (c) 2005-2006 Sven Efftinge (http://www.efftinge.de) and others. - * All rights reserved. This program and the accompanying materials +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Sven Efftinge (http://www.efftinge.de) - Initial API and implementation - * - * </copyright> - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; import java.util.Collections; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EEnumType.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EEnumType.java index fb8f2c5b..eebe155a 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EEnumType.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EEnumType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; @@ -22,6 +20,7 @@ import org.eclipse.internal.xtend.type.baseimpl.StaticPropertyImpl; import org.eclipse.xtend.typesystem.AbstractTypeImpl; import org.eclipse.xtend.typesystem.Feature; +@SuppressWarnings("unchecked") public class EEnumType extends AbstractTypeImpl { private EEnum eEnum; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EObjectType.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EObjectType.java index 06286fc3..6078cc24 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EObjectType.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EObjectType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; @@ -38,7 +36,7 @@ public class EObjectType extends AbstractTypeImpl { @Override public String getDocumentation() { - return "base type for all ecore based metamodels (added by xtend's typesystem)"; + return "base type for all ecore based metamodels (added by oAW4 emftools)"; } @Override @@ -84,6 +82,7 @@ public class EObjectType extends AbstractTypeImpl { new PropertyImpl(EObjectType.this, "eAllContents", getTypeSystem().getSetType(EObjectType.this)) { + @SuppressWarnings("unchecked") public Object get(final Object target) { final HashSet allCont = new HashSet(); final Iterator iter = ((EObject) target).eAllContents(); @@ -126,6 +125,7 @@ public class EObjectType extends AbstractTypeImpl { return Collections.singleton(getTypeSystem().getObjectType()); } + @SuppressWarnings("unchecked") public static StringBuffer toString(EObject x) { if (x == null) { return new StringBuffer("null"); diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java index 4b235845..2a816a4e 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EcoreUtil2.java @@ -1,23 +1,18 @@ -/** - * <copyright> - * - * Copyright (c) 2005-2006 Sven Efftinge (http://www.efftinge.de) and others. - * All rights reserved. This program and the accompanying materials +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Sven Efftinge (http://www.efftinge.de) - Initial API and implementation - * - * </copyright> - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -27,6 +22,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; @@ -40,44 +36,68 @@ import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory; /** * Provides useful functions for usage of EMF. + * * @since 4.0 */ +@SuppressWarnings("unchecked") public class EcoreUtil2 { private final static Log log = LogFactory.getLog(EcoreUtil2.class); static { - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, + new XMIResourceFactoryImpl()); EPackage.Registry.INSTANCE.put(EcorePackage.eINSTANCE.getNsURI(), EcorePackage.eINSTANCE); } public final static EPackage getEPackage(final String pathToEcoreFile) { - EPackage result = null; + EPackage topLevelPackage = null; final URI fileURI = getURI(pathToEcoreFile); if (fileURI == null) - throw new RuntimeException("cannot resolve EPackage for " + pathToEcoreFile + ". Probably cannot find the .ecore file."); + throw new RuntimeException("cannot resolve EPackage for " + pathToEcoreFile + + ". Probably cannot find the .ecore file."); try { final Resource res = new ResourceSetImpl().createResource(fileURI); if (res == null) - throw new ConfigurationException("No ecore model file '" + pathToEcoreFile + "' found! (" + fileURI.toString() + ")"); + throw new ConfigurationException("No ecore model file '" + pathToEcoreFile + "' found! (" + + fileURI.toString() + ")"); res.load(new HashMap()); - result = (EPackage) res.getContents().get(0); - if (result.getNsURI() != null) { - if (EPackage.Registry.INSTANCE.containsKey(result.getNsURI())) { - result = EPackage.Registry.INSTANCE.getEPackage(result.getNsURI()); - } else { - EPackage.Registry.INSTANCE.put(result.getNsURI(), result); - URIConverter.URI_MAP.put(URI.createURI(result.getNsURI()), fileURI); - } - } - return result; - } catch (final IOException e) { + topLevelPackage = (EPackage) res.getContents().get(0); + registerPackage(topLevelPackage, fileURI); + registerSubPackages(topLevelPackage, fileURI); + return topLevelPackage; + } + catch (final IOException e) { throw new ConfigurationException(e); - } finally { + } + finally { logPackages(); } } + private static void registerSubPackages(EPackage ePackage, URI fileURI) { + if (ePackage == null || fileURI == null) + throw new IllegalArgumentException(); + + for (TreeIterator<EObject> it = ePackage.eAllContents(); it.hasNext();) { + EObject obj = it.next(); + if (obj instanceof EPackage) { + EPackage p = (EPackage) obj; + registerPackage(p, fileURI); + } + } + + } + + private static void registerPackage(EPackage ePackage, final URI fileURI) { + if (ePackage != null && fileURI != null && ePackage.getNsURI() != null) { + if (!EPackage.Registry.INSTANCE.containsKey(ePackage.getNsURI())) { + EPackage.Registry.INSTANCE.put(ePackage.getNsURI(), ePackage); + URIConverter.URI_MAP.put(URI.createURI(ePackage.getNsURI()), fileURI); + } + } + } + private static void logPackages() { // if (log.isDebugEnabled()) { // Set s = EPackage.Registry.INSTANCE.keySet(); @@ -93,27 +113,33 @@ public class EcoreUtil2 { /** * Finds all elements within a collection of a specific type. - * @param iter An iterator over the source collection. - * @param type The type which should be selected. + * + * @param iter + * An iterator over the source collection. + * @param type + * The type which should be selected. * @return A set with all elements of the specified type. */ public static Set<EObject> findAllByType(final Iterator iter, final Class type) { final Set<EObject> result = new HashSet<EObject>(); while (iter.hasNext()) { final EObject curr = (EObject) iter.next(); - if (type.isInstance(curr)) + if (type.isInstance(curr)) { result.add(curr); + } } return result; } /** * Clones a list. - * @param list The list that should be cloned. + * + * @param list + * The list that should be cloned. * @return A copy of the original list */ public static List clone(final EList list) { - if (list==null) + if (list == null) return null; final List res = new ArrayList(); res.addAll(list); @@ -121,12 +147,15 @@ public class EcoreUtil2 { } /** - * Finds an EMF EPackage instance by its class name. The EPackage class must be loadable by the - * ResourceLoader - * @param ePackage The class name of the EPackage interface - * @return The EPackage instance. Returns <code>null</code> if any exception occurs after the class - * was successfully loaded. - * @throws ConifgurationException If the class specified by <tt>ePackage</tt> cannot be loaded. + * Finds an EMF EPackage instance by its class name. The EPackage class must + * be loadable by the ResourceLoader + * + * @param ePackage + * The class name of the EPackage interface + * @return The EPackage instance. Returns <code>null</code> if any exception + * occurs after the class was successfully loaded. + * @throws ConifgurationException + * If the class specified by <tt>ePackage</tt> cannot be loaded. */ public static EPackage getEPackageByClassName(final String ePackage) throws ConfigurationException { Class clazz; @@ -135,34 +164,43 @@ public class EcoreUtil2 { clazz = ResourceLoaderFactory.createResourceLoader().loadClass(ePackage); if (clazz == null) throw new ConfigurationException("Couldn't find class " + ePackage); - // each EPackage class has an 'eINSTANCE' field which holds the implementation instance + // each EPackage class has an 'eINSTANCE' field which holds the + // implementation instance final Field f = clazz.getField("eINSTANCE"); // retrieve the EPackage instance from the eINSTANCE field final EPackage result = (EPackage) f.get(null); - // register the EPackage instance in the EPackage Registry + // register the EPackage instance in the EPackage Registry EPackage.Registry.INSTANCE.put(result.getNsURI(), result); return result; - } catch (final SecurityException e) { + } + catch (final SecurityException e) { log.error(e); return null; - } catch (final NoSuchFieldException e) { + } + catch (final NoSuchFieldException e) { log.error(e); return null; - } catch (final IllegalArgumentException e) { + } + catch (final IllegalArgumentException e) { log.error(e); return null; - } catch (final IllegalAccessException e) { + } + catch (final IllegalAccessException e) { log.error(e); return null; - } finally { + } + finally { logPackages(); } } /** * Finds an EPackage by the class name of the Package Descriptor. - * @param ePackageDescriptor The Package Descriptor's classname - * @return The EPackage instance. Returns <code>null</code> on any exception occuring while retrieval. + * + * @param ePackageDescriptor + * The Package Descriptor's classname + * @return The EPackage instance. Returns <code>null</code> on any exception + * occuring while retrieval. */ public static EPackage getEPackageByDescriptorClassName(final String ePackageDescriptor) { Class clazz; @@ -173,27 +211,67 @@ public class EcoreUtil2 { final String uri = (String) f.get(null); EPackage.Registry.INSTANCE.put(uri, descriptor); return EPackage.Registry.INSTANCE.getEPackage(uri); - } catch (final Exception e) { + } + catch (final Exception e) { log.error("Couldn't load ePackage '" + ePackageDescriptor, e); return null; - } finally { + } + finally { logPackages(); } } /** * Creates an URI from a file name. - * @param file The file's path + * + * @param file + * The file's path * @return The URI representing the file */ public static URI getURI(final String file) { // try to load the resource specified by 'file' final URL url = ResourceLoaderFactory.createResourceLoader().getResource(file); - // if the ResourceLoader cannot locate this file create a URI from the file - if (url == null) - return URI.createURI(file); - // the ResourceLoader has successfully located the file. Return the external form of the path - return URI.createURI(url.toExternalForm()); + URI uri; + + try { + // if the ResourceLoader cannot locate this file create a URI from + // the file + if (url == null) { + uri = URI.createURI(file); + } + else { + // the ResourceLoader has successfully located the file. Return + // the external form of the path + + uri = URI.createURI(url.toExternalForm()); + + // this is the old implementation of this block, but it caused + // errors: + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=256833 + // I'm leaving this here for a while to make sure unforeseen + // side effects can be understood + // if (url.getProtocol().equals("file")) { + // uri = URI.createFileURI(url.getFile()); + // } + // else { + // uri = URI.createURI(url.toString()); + // } + } + } + catch (IllegalArgumentException e) { + uri = URI.createFileURI(url.getFile()); + } + + return uri; + } + + public static Collection<EObject> allContents(EObject modelElement) { + List<EObject> all = new ArrayList<EObject>(); + TreeIterator<EObject> iterator = modelElement.eAllContents(); + while (iterator.hasNext()) { + all.add(iterator.next()); + } + return all; } } diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java index e7c88fc2..c272cf02 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfRegistryMetaModel.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfRegistryMetaModel.java index b8dc5057..38edfd8b 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfRegistryMetaModel.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/EmfRegistryMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; @@ -37,6 +35,7 @@ import org.eclipse.xtend.expression.TypeSystem; import org.eclipse.xtend.typesystem.MetaModel; import org.eclipse.xtend.typesystem.Type; +@SuppressWarnings("unchecked") public class EmfRegistryMetaModel implements MetaModel { TypeSystem typeSystem; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Mapping.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Mapping.java index 59ea4da7..a67c0a82 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Mapping.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Mapping.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Setup.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Setup.java index c7f2529d..410eb549 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Setup.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/Setup.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; @@ -43,6 +41,7 @@ public class Setup { EcoreUtil2.getEPackageByClassName(clazz); } + @SuppressWarnings("unchecked") public void addUriMap(final Mapping uriMap) { final URI baseUri = URI.createURI(uriMap.getFrom()); final URI mappedUri = EcoreUtil2.getURI(uriMap.getTo()); @@ -62,6 +61,7 @@ public class Setup { * <li> The inner factory class for the extension cannot be found * </ul> */ + @SuppressWarnings("unchecked") public void addExtensionMap(final Mapping m) throws ConfigurationException { try { // locate the factory class of the extension diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java index 4889a5e4..4d41482f 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiReader.java @@ -1,17 +1,11 @@ -/** - * <copyright> - * - * Copyright (c) 2005-2006 Sven Efftinge (http://www.efftinge.de) and others. - * All rights reserved. This program and the accompanying materials +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Sven Efftinge (http://www.efftinge.de) - Initial API and implementation - * - * </copyright> - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; import java.io.File; @@ -30,86 +24,149 @@ import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory; /** - * @author Sven Efftinge (http://www.efftinge.de) + * @author Sven Efftinge (http://www.itemis.eu) + * + * + * @deprecated use org.eclipse.mwe.emf.Reader instead */ -public class XmiReader extends AbstractWorkflowComponent { - - protected String modelFile; - - protected String outputSlot = WorkflowContext.DEFAULT_SLOT; - - protected boolean firstElementOnly = true; - - public String getLogMessage() { - return "file '"+modelFile+"' => slot '"+outputSlot+"'"; - } - - public void setMetaModelFile(final String metaModelFile) { - new Setup().addEPackageFile(metaModelFile); - } - - public void setMetaModelPackage(final String metaModelPackage) { - new Setup().addEPackageClass(metaModelPackage); - } - - public void setMetaModelDescriptor(final String metaModelDescriptor) { - new Setup().addEPackageDescriptor(metaModelDescriptor); - } - - public void setModelFile(final String modelFile) { - this.modelFile = modelFile; - } - - public void setOutputSlot(final String outputSlot) { - this.outputSlot = outputSlot; - } - - public void setFirstElementOnly(final boolean firstElementOnly) { - this.firstElementOnly = firstElementOnly; - } - - public void checkConfiguration(final Issues issues) { - loadFile(issues); - } - - @Override - protected void invokeInternal(final WorkflowContext model, final ProgressMonitor monitor, final Issues issues) { - final File f = loadFile(issues); - final URI fileURI = URI.createFileURI(f.getAbsolutePath()); - - final Resource r = new ResourceSetImpl().createResource(fileURI); - try { - r.load(null); - } catch (final IOException e) { - throw new ConfigurationException(e); - } - - if (firstElementOnly) { - model.set(outputSlot, r.getContents().get(0)); - } else { - model.set(outputSlot, r.getContents()); - } - } - - protected File loadFile(final Issues issues) { - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); - if (modelFile == null) { - issues.addError("No modelFile specified!"); - return null; - } - final URL url = ResourceLoaderFactory.createResourceLoader().getResource(modelFile); - if ((url == null) || (url.getFile() == null)) { - issues.addError(this, "cannot find file: " + modelFile); - return null; - } - final File f = new File(URI.decode(url.getFile())); - if (!f.exists()) { - issues.addError(this, "cannot find file: " + modelFile); - return null; - } - return f; - } - - - +@Deprecated +public class XmiReader extends AbstractWorkflowComponent { + + private static final String COMPONENT_NAME = "XMI Reader"; + + protected String modelFile; + + protected String outputSlot = WorkflowContext.DEFAULT_SLOT; + + protected boolean firstElementOnly = true; + + /** + * @see org.openarchitectureware.workflow.lib.AbstractWorkflowComponent#getLogMessage() + */ + @Override + public String getLogMessage() { + return "file '" + modelFile + "' => slot '" + outputSlot + "'"; + } + + /** + * Sets the name of the metamodel file. + * + * @param metaModelFile + * name of file + */ + public void setMetaModelFile(final String metaModelFile) { + new Setup().addEPackageFile(metaModelFile); + } + + /** + * Sets the name of the metamodel package. + * + * @param metaModelPackage + * name of package + */ + public void setMetaModelPackage(final String metaModelPackage) { + new Setup().addEPackageClass(metaModelPackage); + } + + /** + * Sets the metamodel descriptor. + * + * @param metaModelDescriptor + * the descriptor + */ + public void setMetaModelDescriptor(final String metaModelDescriptor) { + new Setup().addEPackageDescriptor(metaModelDescriptor); + } + + /** + * Sets the name of the model file. + * + * @param modelFile + * name of file + */ + public void setModelFile(final String modelFile) { + this.modelFile = modelFile; + } + + /** + * Sets the name of the output slot. + * + * @param outputSlot + * name of slot + */ + public void setOutputSlot(final String outputSlot) { + this.outputSlot = outputSlot; + } + + /** + * Sets if only the first element will be used or not. + * + * @param firstElementOnly + * If <code>true</code>, only the first element will be used, + * otherwise all elements will be used. + */ + public void setFirstElementOnly(final boolean firstElementOnly) { + this.firstElementOnly = firstElementOnly; + } + + /** + * @see org.openarchitectureware.workflow.WorkflowComponent#checkConfiguration(org.openarchitectureware.workflow.issues.Issues) + */ + public void checkConfiguration(final Issues issues) { + loadFile(issues); + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#invokeInternal(org.eclipse.emf.mwe.core.WorkflowContext, + * org.eclipse.emf.mwe.core.monitor.ProgressMonitor, + * org.eclipse.emf.mwe.core.issues.Issues) + */ + @Override + public void invokeInternal(final WorkflowContext model, final ProgressMonitor monitor, final Issues issues) { + final File f = loadFile(issues); + final URI fileURI = URI.createFileURI(f.getAbsolutePath()); + + final Resource r = new ResourceSetImpl().createResource(fileURI); + try { + r.load(null); + } + catch (final IOException e) { + throw new ConfigurationException(e); + } + + if (firstElementOnly) { + model.set(outputSlot, r.getContents().get(0)); + } + else { + model.set(outputSlot, r.getContents()); + } + } + + @SuppressWarnings("unchecked") + protected File loadFile(final Issues issues) { + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); + if (modelFile == null) { + issues.addError("No modelFile specified!"); + return null; + } + final URL url = ResourceLoaderFactory.createResourceLoader().getResource(modelFile); + if ((url == null) || (url.getFile() == null)) { + issues.addError(this, "cannot find file: " + modelFile); + return null; + } + final File f = new File(URI.decode(url.getFile())); + if (!f.exists()) { + issues.addError(this, "cannot find file: " + modelFile); + return null; + } + return f; + } + + /** + * @see org.openarchitectureware.workflow.WorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiWriter.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiWriter.java index eaf5d83d..c9f3f5fa 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiWriter.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/XmiWriter.java @@ -1,17 +1,11 @@ -/** - * <copyright> - * - * Copyright (c) 2005-2006 Sven Efftinge (http://www.efftinge.de) and others. - * All rights reserved. This program and the accompanying materials +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Sven Efftinge (http://www.efftinge.de) - Initial API and implementation - * - * </copyright> - */ + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf; import java.io.File; @@ -41,12 +35,19 @@ import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; * * @author Markus Völter * @since 4.0 + * + * @deprecated use org.eclipse.mwe.emf.Writer instead */ +@SuppressWarnings("unchecked") +@Deprecated public class XmiWriter extends AbstractWorkflowComponent { - + // default save options. + @SuppressWarnings("unchecked") private static final Map saveOptions = new HashMap(); + private static final String COMPONENT_NAME = "XMI Writer"; + static { XMIResource resource = new XMIResourceImpl(); // default save options. @@ -54,112 +55,158 @@ public class XmiWriter extends AbstractWorkflowComponent { saveOptions.put(XMIResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); } - - private String modelFile; + private String modelFile; - private String inputSlot = WorkflowContext.DEFAULT_SLOT; + private String inputSlot = WorkflowContext.DEFAULT_SLOT; private String pathPrefix = "."; - public void setModelFile(final String modelFile) { - this.modelFile = modelFile; - } - + /** + * Sets the name of the model file. + * + * @param modelFile + * name of file + */ + public void setModelFile(final String modelFile) { + this.modelFile = modelFile; + } + + /** + * Returns the name of the model file. + * + * @return name of model file + */ public String getModelFile() { return modelFile; } - + + /** + * Sets the name of the input slot. + * + * @param inputSlot + * name of slot + */ public void setInputSlot(final String inputSlot) { - this.inputSlot = inputSlot; - } + this.inputSlot = inputSlot; + } - public String getInputSlot() { + /** + * Returns the name of the input slot. + * + * @return name of slot + */ + public String getInputSlot() { return inputSlot; } - @Override - public String getLogMessage() { - return "slot '"+inputSlot+"' => file '" + pathPrefix + "/" + modelFile+"'"; - } - - public void checkConfiguration(final Issues issues) { - modelFile = modelFile.replace('\\', '/'); - int p = modelFile.lastIndexOf("/"); - if ( p >= 0) { - pathPrefix = modelFile.substring(0, p+1); - modelFile = modelFile.substring(p+1); - } - } - - @Override - protected void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { - final Object slotContent = ctx.get(inputSlot); - if (slotContent == null) { - issues.addError(this, "slot '" + inputSlot + "' is empty."); - return; - } - if (!(slotContent instanceof Collection<?> || slotContent instanceof EObject)) { - issues.addError(this, "slot '" + inputSlot + "' neither contains an EList nor an EObject", slotContent); - return; - } - - Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); - - final URI fileURI = URI.createFileURI(modelFile);// EcoreUtil2.getURI(modelFile); - ResourceSetImpl rsImpl = new ResourceSetImpl(); - rsImpl.setURIConverter(new XmiWriterURIConverter(pathPrefix)); - Resource r = rsImpl .createResource(fileURI); - if (r instanceof XMIResource) { + /** + * @see org.openarchitectureware.workflow.lib.AbstractWorkflowComponent#getLogMessage() + */ + @Override + public String getLogMessage() { + return "slot '" + inputSlot + "' => file '" + pathPrefix + "/" + modelFile + "'"; + } + + /** + * @see org.openarchitectureware.workflow.WorkflowComponent#checkConfiguration(org.openarchitectureware.workflow.issues.Issues) + */ + public void checkConfiguration(final Issues issues) { + modelFile = modelFile.replace('\\', '/'); + int p = modelFile.lastIndexOf("/"); + if (p >= 0) { + pathPrefix = modelFile.substring(0, p + 1); + modelFile = modelFile.substring(p + 1); + } + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#invokeInternal(org.eclipse.emf.mwe.core.WorkflowContext, + * org.eclipse.emf.mwe.core.monitor.ProgressMonitor, + * org.eclipse.emf.mwe.core.issues.Issues) + */ + @Override + @SuppressWarnings("unchecked") + public void invokeInternal(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { + final Object slotContent = ctx.get(inputSlot); + if (slotContent == null) { + issues.addError(this, "slot '" + inputSlot + "' is empty."); + return; + } + if (!(slotContent instanceof Collection<?> || slotContent instanceof EObject)) { + issues.addError(this, "slot '" + inputSlot + "' neither contains an EList nor an EObject", slotContent); + return; + } + + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); + + final URI fileURI = URI.createFileURI(modelFile);// EcoreUtil2.getURI(modelFile); + ResourceSetImpl rsImpl = new ResourceSetImpl(); + rsImpl.setURIConverter(new XmiWriterURIConverter(pathPrefix)); + Resource r = rsImpl.createResource(fileURI); + if (r instanceof XMIResource) { XMIResource xmiRes = (XMIResource) r; xmiRes.getDefaultSaveOptions().putAll(saveOptions); } - r.setURI(URI.createFileURI(modelFile)); - - if (slotContent instanceof Collection<?>) { - r.getContents().addAll((Collection) slotContent); - } else { - r.getContents().add((EObject)slotContent); - } - try { - // Fix: EMF-Resource builds wrong file name, if used on a file - // on windows (it places the Device-Carater immediately before - // the last Slash). So we write explicitly to the path if the - // URI is a file URI. - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=173604 - if (r.getURI().isFile()) { - File file = new File (pathPrefix + "/" + modelFile); - OutputStream os = new FileOutputStream(file); - r.save(os, null); - os.close(); - } - else { - r.save(null); - } - } catch (final IOException e) { - throw new ConfigurationException(e); - } - - } - - class XmiWriterURIConverter extends URIConverterImpl { - private String pathPrefix; - public XmiWriterURIConverter( String pathPrefix ) { - this.pathPrefix = pathPrefix; - } - @Override - protected OutputStream createFileOutputStream(String filename) throws IOException { - if ( pathPrefix != null ) { - pathPrefix = pathPrefix.replace('\\', '/'); - if ( !pathPrefix.endsWith("/")) pathPrefix += "/"; - filename = filename.replace('\\', '/'); - int lastSlashPos = filename.lastIndexOf("/"); - if ( lastSlashPos >= 0 ) { - filename = filename.substring(0,lastSlashPos+1)+pathPrefix+filename.substring(lastSlashPos+1); - } - } - return super.createFileOutputStream(filename); - } - } - + r.setURI(URI.createFileURI(modelFile)); + if (slotContent instanceof Collection<?>) { + r.getContents().addAll((Collection) slotContent); + } + else { + r.getContents().add((EObject) slotContent); + } + try { + // Fix: EMF-Resource builds wrong file name, if used on a file + // on windows (it places the Device-Carater immediately before + // the last Slash). So we write explicitly to the path if the + // URI is a file URI. + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=173604 + if (r.getURI().isFile()) { + File file = new File(pathPrefix + "/" + modelFile); + OutputStream os = new FileOutputStream(file); + r.save(os, null); + os.close(); + } + else { + r.save(null); + } + } + catch (final IOException e) { + throw new ConfigurationException(e); + } + + } + + class XmiWriterURIConverter extends URIConverterImpl { + private String pathPrefix; + + public XmiWriterURIConverter(String pathPrefix) { + this.pathPrefix = pathPrefix; + } + + @Override + protected OutputStream createFileOutputStream(String filename) throws IOException { + if (pathPrefix != null) { + pathPrefix = pathPrefix.replace('\\', '/'); + if (!pathPrefix.endsWith("/")) { + pathPrefix += "/"; + } + filename = filename.replace('\\', '/'); + int lastSlashPos = filename.lastIndexOf("/"); + if (lastSlashPos >= 0) { + filename = filename.substring(0, lastSlashPos + 1) + pathPrefix + + filename.substring(lastSlashPos + 1); + } + } + return super.createFileOutputStream(filename); + } + } + + /** + * @see org.openarchitectureware.workflow.WorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java index 6fee3ac7..2ec74df9 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckEValidatorAdapter.java @@ -1,14 +1,10 @@ /******************************************************************************* - * <copyright> - * Copyright (c) 2008 itemis AG and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation - * </copyright> *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java index 6868c7b0..b137681e 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckFileWithContext.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check; import java.util.ArrayList; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java index 1d3bdba5..dcbd524b 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/check/CheckRegistry.java @@ -1,14 +1,10 @@ /******************************************************************************* - * <copyright> - * Copyright (c) 2008 itemis AG and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation - * </copyright> *******************************************************************************/ package org.eclipse.xtend.typesystem.emf.check; diff --git a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/internal/EarlyStarter.java b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/internal/EarlyStarter.java index ab7e71cc..f0ae07ee 100644 --- a/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/internal/EarlyStarter.java +++ b/plugins/org.eclipse.xtend.typesystem.emf/src/org/eclipse/xtend/typesystem/emf/internal/EarlyStarter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/plugins/org.eclipse.xtend.util.stdlib/META-INF/MANIFEST.MF b/plugins/org.eclipse.xtend.util.stdlib/META-INF/MANIFEST.MF index 616e33f6..6938b399 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.xtend.util.stdlib/META-INF/MANIFEST.MF @@ -12,8 +12,9 @@ Require-Bundle: org.eclipse.emf.ecore, org.apache.commons.logging, org.eclipse.xtend, org.eclipse.emf.mwe.utils, - org.eclipse.xpand;resolution:=optional -Eclipse-LazyStart: true + org.eclipse.xpand;resolution:=optional, + org.eclipse.emf.ecore.xmi +LazyStart: true Export-Package: org.eclipse.xpand.util.stdlib, org.eclipse.xtend.util.stdlib, org.eclipse.xtend.util.stdlib.texttest, diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xpand/util/stdlib/TracingOutput.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xpand/util/stdlib/TracingOutput.java index 4ad9036b..b711cbb6 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xpand/util/stdlib/TracingOutput.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xpand/util/stdlib/TracingOutput.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.util.stdlib; @@ -16,18 +14,29 @@ import org.eclipse.xpand2.output.OutputImpl; import org.eclipse.xtend.util.stdlib.TraceComponent; public class TracingOutput extends OutputImpl { - + + /** + * @see org.eclipse.xpand2.output.OutputImpl#pushStatement(org.eclipse.internal.xtend.expression.ast.SyntaxElement, + * org.eclipse.xpand2.XpandExecutionContext) + */ @Override public void pushStatement(SyntaxElement stmt, XpandExecutionContext ctx) { super.pushStatement(stmt, ctx); } - + + /** + * @see org.eclipse.xpand2.output.OutputImpl#openFile(java.lang.String, + * java.lang.String) + */ @Override public void openFile(String path, String outletName) { super.openFile(path, outletName); - TraceComponent.reportFileOpen( path ); + TraceComponent.reportFileOpen(path); } - + + /** + * @see org.eclipse.xpand2.output.OutputImpl#closeFile() + */ @Override public void closeFile() { super.closeFile(); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CloningExtensions.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CloningExtensions.java index 067b983a..c93dec67 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CloningExtensions.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CloningExtensions.java @@ -1,18 +1,19 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.EcoreUtil; +/** + * Java helper class for Stdlib extension <tt>org::openarchitectureware::util::stdlib::cloning</tt>. + */ public class CloningExtensions { public static Object clone(Object original) { diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CounterExtensions.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CounterExtensions.java index 2afde713..4744317a 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CounterExtensions.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/CounterExtensions.java @@ -1,18 +1,19 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import java.util.HashMap; import java.util.Map; +/** + * Java helper class for Stdlib extension <tt>org::openarchitectureware::util::stdlib::counter</tt>. + */ public class CounterExtensions { private static int globalCounter = 0; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinder.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinder.java index 31a50267..4756eb1a 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinder.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinder.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -24,6 +22,7 @@ public class DanglingRefFinder { private Set<EObject> set = new HashSet<EObject>(); + @SuppressWarnings("unchecked") public void handle(EObject o, Issues issues) { if ( set.contains( o ) || shouldIgnore(o) ) return; set.add( o ); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinderComponent.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinderComponent.java index fddaae82..b35abefc 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinderComponent.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DanglingRefFinderComponent.java @@ -1,40 +1,51 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; -public class DanglingRefFinderComponent extends AbstractWorkflowComponent { - +public class DanglingRefFinderComponent extends AbstractWorkflowComponent2 { + + private static final String COMPONENT_NAME = "Dangling Reference Finder"; + private String modelSlot; - public void setModelSlot( String slot ) { + /** + * Sets the model slot. + * + * @param slot + * name of slot + */ + public void setModelSlot(String slot) { this.modelSlot = slot; } - - public void checkConfiguration(Issues issues) { - if (modelSlot == null ) issues.addError(this, "'modelSlot' not specified,"); + + @Override + protected void checkConfigurationInternal(Issues issues) { + if (modelSlot == null) { + issues.addError(this, "'modelSlot' not specified,"); + } } - + @Override - protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, - Issues issues) { - EObject root = (EObject)ctx.get(modelSlot); + protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { + EObject root = (EObject) ctx.get(modelSlot); DanglingRefFinder finder = new DanglingRefFinder(); finder.handle(root, issues); } - + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DuplicateHelper.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DuplicateHelper.java index f8c71284..d72cac23 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DuplicateHelper.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DuplicateHelper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DynamicEcoreHelper.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DynamicEcoreHelper.java index 90cde4b0..5a46c85a 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DynamicEcoreHelper.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/DynamicEcoreHelper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -61,6 +59,7 @@ public class DynamicEcoreHelper { object.eSet( object.eClass().getEStructuralFeature(feature) , newValue); } + @SuppressWarnings("unchecked") public void add(EObject object, String feature, EObject newValue) { ((Collection)object.eGet( object.eClass().getEStructuralFeature(feature) )).add(newValue); } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ElementPropertiesExtensions.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ElementPropertiesExtensions.java index 5717cbb3..671db25b 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ElementPropertiesExtensions.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ElementPropertiesExtensions.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -15,21 +13,21 @@ import java.util.Map; public class ElementPropertiesExtensions { - private static Map<Object, Map> outerMap = new HashMap<Object, Map>(); + private static Map<Object, Map<String,Object>> outerMap = new HashMap<Object, Map<String,Object>>(); public static void setProperty( Object element, String name, Object value ) { - Map innerMap = getInnerMap(element); + Map<String,Object> innerMap = getInnerMap(element); innerMap.put( name , value ); } public static Object getProperty( Object element, String name ) { - Map innerMap = getInnerMap(element); + Map<String,Object> innerMap = getInnerMap(element); Object value = innerMap.get( name ); return value; } - private static Map getInnerMap( Object element ) { - Map innerMap = outerMap.get(element); + private static Map<String,Object> getInnerMap( Object element ) { + Map<String,Object> innerMap = outerMap.get(element); if ( innerMap == null ) { innerMap = new HashMap<String, Object>(); outerMap.put(element, innerMap); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/EmfUtils.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/EmfUtils.java index e88a8382..0c85f690 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/EmfUtils.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/EmfUtils.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -19,9 +17,15 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.EStructuralFeature.Setting; import org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer; +import org.eclipse.emf.ecore.xmi.XMLResource; public class EmfUtils { + /** + * Retrieves objects that reference a given object + * @param target The target object + * @return A list of objects referencing the target + */ public static final List<EObject> getReferencingObjects(EObject target) { LinkedList<EObject> result = new LinkedList<EObject>(); Collection<EStructuralFeature.Setting> settings = CrossReferencer.find(target.eResource().getContents()).get(target); @@ -33,4 +37,17 @@ public class EmfUtils { } return result; } + + /** + * Retrieves an object's identifier. The object must be read from a + * XMLResource. + * + * @param obj An object + * @return The object's id. + * @since 4.3.1 + */ + public static String getID(EObject obj) { + return (obj.eResource() != null && obj.eResource() instanceof XMLResource) ? ((XMLResource) obj.eResource()).getID(obj) : null; + } + } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ExtIssueReporter.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ExtIssueReporter.java index 259d878b..2e1cabc9 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ExtIssueReporter.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/ExtIssueReporter.java @@ -1,69 +1,118 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import org.eclipse.emf.mwe.core.WorkflowContext; +import org.eclipse.emf.mwe.core.WorkflowInterruptedException; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; +/** + * Java helper class for Stdlib extension + * <tt>org::openarchitectureware::util::stdlib::issues</tt>. + */ +public class ExtIssueReporter extends AbstractWorkflowComponent2 { + private static final String ERROR_CONFIGURE = "You must run the org.eclipse.xtend.util.stdlib.ExtIssueReporter component before using the issue reporting utilities."; -public class ExtIssueReporter extends AbstractWorkflowComponent { + private static final String COMPONENT_NAME = "External Issue Reporter"; - static ThreadLocal tl = new ThreadLocal(); - + static ThreadLocal<Issues> tl = new ThreadLocal<Issues>(); + + @Override protected void checkConfigurationInternal(Issues arg0) { } + @Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor mon, Issues issues) { - tl.set( issues ); + tl.set(issues); } - + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ @Override public String getLogMessage() { return "setting up issue logging from within .ext and .xpt files"; } - - public static String reportError( String message ) { - getIssues().addError( message ); + + /** + * Reports an error. + * + * @param message + * the error message + * @return the passed in error message + */ + public static String reportError(String message) { + getIssues().addError(message); return message; } private static Issues getIssues() { - return ((Issues)tl.get()); + Issues issues = tl.get(); + if (issues == null) + throw new WorkflowInterruptedException(ERROR_CONFIGURE); + return issues; } - public static String reportWarning( String message ) { - getIssues().addWarning( message ); + /** + * Reports a warning. + * + * @param message + * the warning message + * @return the passed in warning message + */ + public static String reportWarning(String message) { + getIssues().addWarning(message); return message; } - public static String reportError( String qfn, String message ) { - if ( tl.get() == null ) { - System.err.println("you've forgotten to run the org.eclipse.internal.xtend.util.stdlib.ExtIssueReporter component before using the issue reporting utilities."); + /** + * Reports an error. + * + * @param qfn + * a qualified filename + * @param message + * the error message + * @return the passed in error message + */ + public static String reportError(String qfn, String message) { + if (tl.get() == null) { + System.err.println(ERROR_CONFIGURE); } - getIssues().addError( "["+qfn+"] "+message ); + getIssues().addError("[" + qfn + "] " + message); return message; } - public static String reportWarning( String qfn, String message ) { - if ( tl.get() == null ) { - System.err.println("you've forgotten to run the org.eclipse.internal.xtend.util.stdlib.ExtIssueReporter component before using the issue reporting utilities."); + /** + * Reports a warning. + * + * @param qfn + * a qualified filename + * @param message + * the warning message + * @return the passed in warning message + */ + public static String reportWarning(String qfn, String message) { + if (tl.get() == null) { + System.err.println(ERROR_CONFIGURE); } - getIssues().addWarning( "["+qfn+"] "+message ); + getIssues().addWarning("[" + qfn + "] " + message); return message; } - public void checkConfiguration(Issues issues) { - + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/GlobalVarExtensions.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/GlobalVarExtensions.java index 605eb2bc..7a50bdb5 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/GlobalVarExtensions.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/GlobalVarExtensions.java @@ -1,28 +1,38 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import java.util.HashMap; import java.util.Map; +/** + * Java helper class for Stdlib extension <tt>org::openarchitectureware::util::stdlib::globalvar</tt>. + */ public class GlobalVarExtensions { - private static Map vars = new HashMap(); + private static Map<String,Object> vars = new HashMap<String,Object>(); public static void storeGlobalVar(String s, Object o){ + if (o != null) { vars.put(s, o); + } else { + vars.remove(s); + } } public static Object getGlobalVar(String s){ return vars.get(s); } + public static Object removeGlobalVar(String s){ + return vars.remove(s); + } + + } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java index c531d0bb..da2cc452 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/IOExtensions.java @@ -1,18 +1,20 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +/** + * Java helper class for Stdlib extension <tt>org::openarchitectureware::util::stdlib::cloning</tt>. + * Contains extension functions for logging messages and errors. + */ public class IOExtensions { private final static Log log = LogFactory.getLog(IOExtensions.class); @@ -35,5 +37,8 @@ public class IOExtensions { public final static void error(final Object s) { log.error(s); } + public final static void throwError(final Object s) { + throw new IllegalStateException(""+s); + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/MessageLogger.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/MessageLogger.java index 6a7878ac..b0587758 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/MessageLogger.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/MessageLogger.java @@ -1,35 +1,54 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; -public class MessageLogger extends AbstractWorkflowComponent { - +/** + * Prints a message to the log. + */ +public class MessageLogger extends AbstractWorkflowComponent2 { + private static final Log LOG = LogFactory.getLog(MessageLogger.class); + + private static final String COMPONENT_NAME = "Message Logger"; + private String message; - public void setMessage( String m ) { - message = m; + /** + * Sets the message. + * + * @param msg + * the message + */ + public void setMessage(String msg) { + message = msg; } - - public void checkConfiguration(Issues issues) { + + @Override + protected void checkConfigurationInternal(Issues issues) { } - + @Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { - System.err.println(message); + LOG.info(message); } - + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PlatformHelper.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PlatformHelper.java index 83b2eecd..536d491c 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PlatformHelper.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PlatformHelper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesExtension.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesExtension.java index 81c3d73d..c0cdf360 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesExtension.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesExtension.java @@ -1,18 +1,19 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import java.util.Properties; import java.util.Map.Entry; +/** + * Java helper class for Stdlib extension <tt>org::openarchitectureware::util::stdlib::properties</tt>. + */ public class PropertiesExtension { private static final Properties p = new Properties(); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java index ee097c95..29ac670f 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/PropertiesReader.java @@ -1,51 +1,130 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; -import java.io.File; -import java.io.FileInputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; +import org.eclipse.emf.mwe.core.resources.ResourceLoader; +import org.eclipse.emf.mwe.core.resources.ResourceLoaderFactory; -public class PropertiesReader extends AbstractWorkflowComponent{ +/** + * Reads a property file and makes it accessible through the + * <tt>org::openarchitectureware::util::stdlib::properties</tt> extensions. + * + * <h2> + * Properties</h2> + * <table> + * <tr> + * <th>Property</th> + * <th>Type</th> + * <th>Mandatory</th> + * <th>Description</th> + * </tr> + * <tr> + * <td><tt>propertiesFile</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>The properties file to read.</td> + * </tr> + * </table> + * + * <h2>Example</h2> Workflow configuration: + * + * <pre> + * <component class="oaw.util.stdlib.PropertiesReader"> + * <propertiesFile value="src/config1.properties"/> + * <propertiesFile value="src/config2.properties"/> + * </component> + * </pre> + * + * Config file <tt>config.properties</tt>: + * + * <pre> + * shapes = box,polygon,ellipse,point + * </pre> + * + * Usage in an extension file: + * + * <pre> + * extension org::openarchitectureware::util::stdlib::properties; + * + * cached List[String] SHAPES () : getProperty("shapes").split(",").trim(); + * </pre> + * + */ +public class PropertiesReader extends AbstractWorkflowComponent2 { + private static final Log LOG = LogFactory.getLog(PropertiesReader.class); + private static final String COMPONENT_NAME = "Properties Reader"; - - - private String propertiesFile; + private List<String> propertiesFile; - public void checkConfiguration(Issues issues) { - if (propertiesFile==null || ! new File(propertiesFile).exists()){ - issues.addError("Propertiesfile not set or file does not exist: " + propertiesFile); + @Override + protected void checkConfigurationInternal(Issues issues) { + if (propertiesFile == null || propertiesFile.isEmpty()) { + issues.addError("propertiesFile not set. "); + } + else { + for (String uri : propertiesFile) { + URL url = ResourceLoaderFactory.createResourceLoader().getResource(uri); + if (url == null) { + issues.addError("propertiesFile '" + uri + "' not found."); + } + } } } @Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { - try { - Properties p = new Properties(); - p.load(new FileInputStream(propertiesFile)); - PropertiesExtension.setProperties(p); - - } catch (Exception e) { - issues.addError(e.getMessage(), e); + ResourceLoader rl = ResourceLoaderFactory.createResourceLoader(); + for (String uri : propertiesFile) { + try { + Properties p = new Properties(); + if (LOG.isDebugEnabled()) { + LOG.debug("Reading properties file " + uri); + } + p.load(rl.getResourceAsStream(uri)); + PropertiesExtension.setProperties(p); + } + catch (Exception e) { + issues.addError(e.getMessage(), e); + } } - } - - public final void setPropertiesFile( String propertiesFile ) { - this.propertiesFile = propertiesFile; + + /** + * Adds a properties file. + * + * @param propertiesFile + * A properties file + */ + public final void addPropertiesFile(String propFile) { + if (propertiesFile == null) { + propertiesFile = new ArrayList<String>(); + } + this.propertiesFile.add(propFile); + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotCopier.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotCopier.java index df6e9b63..2d2347f1 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotCopier.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotCopier.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -16,10 +14,44 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; -public class SlotCopier extends AbstractWorkflowComponent { +/** + * This component copies an element from one slot to another. The slot content + * is <i>not cloned</i>. <h2>Properties</h2> + * <table border="1"> + * <tr> + * <th>Property</th> + * <th>Type</th> + * <th>Mandatory</th> + * <th>Description</th> + * </tr> + * <tr> + * <td><tt>fromSlot</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>Source slot name.</td> + * </tr> + * <tr> + * <td><tt>toSlot</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>Destination slot name.</td> + * </tr> + * <tr> + * <td><tt>removeTopLevelList</tt></td> + * <td>boolean</td> + * <td>no</td> + * <td>If <code>true</code> the source slot must contain a list and the top + * level list is removed (i.e. the first element from the list is copied to the + * destination slot), otherwise it is not removed.</td> + * </tr> + * </table> + */ +public class SlotCopier extends AbstractWorkflowComponent2 { + + private static final String COMPONENT_NAME = "Slot Copier"; private String fromSlot; private String toSlot; @@ -27,49 +59,78 @@ public class SlotCopier extends AbstractWorkflowComponent { private Log log = LogFactory.getLog(getClass()); - - public void checkConfiguration(Issues issues) { - if ( (fromSlot == null) || fromSlot.trim().equals("") ) { + @Override + protected void checkConfigurationInternal(Issues issues) { + if ((fromSlot == null) || fromSlot.trim().equals("")) { issues.addError(this, "fromSlot not specified"); } - if ( (toSlot == null) || toSlot.trim().equals("") ) { + if ((toSlot == null) || toSlot.trim().equals("")) { issues.addError(this, "toSlot not specified"); } } + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ @Override public String getLogMessage() { - return "slot '"+fromSlot+"' -> slot '"+toSlot+"'"; + return "slot '" + fromSlot + "' -> slot '" + toSlot + "'"; } - + @Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor mon, Issues issues) { Object content = ctx.get(fromSlot); - if ( content == null ) { + if (content == null) { issues.addWarning(this, "fromSlot is null!"); - } else { - if ( (content instanceof List) && removeTopLevelList ) { - log.info("copying first element of "+content+" ["+content.getClass().getName()+"]"); - ctx.set( toSlot , ((List)content).get(0)); - } else { - log.info("copying "+content+" ["+content.getClass().getName()+"]"); - ctx.set( toSlot , content); - } - } + } + else { + if ((content instanceof List) && removeTopLevelList) { + log.info("copying first element of " + content + " [" + content.getClass().getName() + "]"); + ctx.set(toSlot, ((List<?>) content).get(0)); + } + else { + log.info("copying " + content + " [" + content.getClass().getName() + "]"); + ctx.set(toSlot, content); + } + } } + /** + * Sets the source slot. + * + * @param fromSlot + * name of slot + */ public void setFromSlot(String fromSlot) { this.fromSlot = fromSlot; } - - + /** + * Sets the destination slot. + * + * @param toSlot + * name of slot + */ public void setToSlot(String toSlot) { this.toSlot = toSlot; } + /** + * Enables or disables the removal of the top level list. + * + * @param removeTopLevelList + * If <code>true</code>, the top level list is removed, otherwise + * it is not removed. + */ public void setRemoveTopLevelList(boolean removeTopLevelList) { this.removeTopLevelList = removeTopLevelList; } + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotListAdder.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotListAdder.java index 93339a12..050ed818 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotListAdder.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotListAdder.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -18,71 +16,139 @@ import java.util.Set; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; -public class SlotListAdder extends AbstractWorkflowComponent { +/** + * This component copies an element from one slot to a list contained in another + * slot. + * + * <h2>Properties</h2> + * <table border="1"> + * <tr> + * <th>Property</th> + * <th>Type</th> + * <th>Mandatory</th> + * <th>Description</th> + * </tr> + * <td><tt>modelSlot</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>Source slot name.</td> + * </tr> + * <tr> + * <td><tt>listSlot</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>Target slot name. This slot contains a list of elements.</td> + * </tr> + * <tr> + * <tr> + * <td><tt>uniqueNames</tt></td> + * <td>boolean</td> + * <td>no</td> + * <td>If <code>true</code>, names have to be unique, otherwise not. Requires + * that <tt>modelSlot</tt> contains an <tt>EObject</tt>.</td> + * </tr> + * </table> + */ +public class SlotListAdder extends AbstractWorkflowComponent2 { + + private static final String COMPONENT_NAME = "Slot List Adder"; private String modelSlot; private String listSlot; - private Set nameSet = new HashSet(); + private Set<String> nameSet = new HashSet<String>(); private boolean uniqueNames; - + + /** + * Sets the list slot. + * + * @param listSlot + * name of slot + */ public void setListSlot(String listSlot) { this.listSlot = listSlot; } - + + /** + * Sets the model slot. + * + * @param modelSlot + * name of slot + */ public void setModelSlot(String modelSlot) { this.modelSlot = modelSlot; } - - public void setUniqueNames( boolean b ) { - uniqueNames = b; + + /** + * Sets if names have to be unique. + * + * @param uniqueNames + * If <code>true</code>, names have to be unique, otherwise not. + */ + public void setUniqueNames(boolean uniqueNames) { + this.uniqueNames = uniqueNames; } - - public void checkConfiguration(Issues issues) { - if ( modelSlot == null ) { + + @Override + protected void checkConfigurationInternal(Issues issues) { + if (modelSlot == null) { issues.addError(this, "no modelSlot specified."); } - if ( listSlot == null ) { + if (listSlot == null) { issues.addError(this, "no listSlot specified."); } } + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ @Override public String getLogMessage() { - return "adding contents of slot '"+modelSlot+"' to the list of stuff in '"+listSlot+"'"; + return "adding contents of slot '" + modelSlot + "' to the list of stuff in '" + listSlot + "'"; } - + + @SuppressWarnings("unchecked") @Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor mon, Issues issues) { Object listContent = ctx.get(listSlot); - if ( listContent == null ) { - issues.addWarning(this, "'"+listSlot+"' is empty, creating a new list."); + if (listContent == null) { + issues.addWarning("'" + listSlot + "' is empty, creating a new list.", this); listContent = new ArrayList(); - ctx.set( listSlot , listContent); + ctx.set(listSlot, listContent); } - if ( !(listContent instanceof Collection) ) { - issues.addError(this, "contents of '"+listSlot+"' slot is not a collection, but rather a '"+listSlot.getClass().getName()+"'"); + if (!(listContent instanceof Collection)) { + issues.addError("contents of '" + listSlot + "' slot is not a collection, but rather a '" + + listSlot.getClass().getName() + "'", this); return; } Object modelContent = ctx.get(modelSlot); - if ( modelContent == null ) { - issues.addWarning(this, "'"+modelSlot+"' is empty; not adding anything to the '"+listSlot+"' slot."); + if (modelContent == null) { + issues + .addWarning("'" + modelSlot + "' is empty; not adding anything to the '" + listSlot + "' slot.", + this); return; } - if ( uniqueNames ) { - EObject eo = (EObject)modelContent; - DynamicEcoreHelper h = new DynamicEcoreHelper( eo ); - String name = h.getName( eo ); - if ( !nameSet.contains(name) ) { - ((Collection)listContent).add( modelContent ); - nameSet.add( name ); - } - } else { - ((Collection)listContent).add( modelContent ); + if (uniqueNames) { + EObject eo = (EObject) modelContent; + DynamicEcoreHelper h = new DynamicEcoreHelper(eo); + String name = h.getName(eo); + if (!nameSet.contains(name)) { + ((Collection) listContent).add(modelContent); + nameSet.add(name); + } + } + else { + ((Collection) listContent).add(modelContent); } } - + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotPrinter.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotPrinter.java index d9d44644..95088234 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotPrinter.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SlotPrinter.java @@ -1,47 +1,137 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; +import java.util.Arrays; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; -public class SlotPrinter extends AbstractWorkflowComponent { - +/** + * This component prints a workflow context slot content to the log. <h2> + * Properties</h2> + * <table border="1"> + * <tr> + * <th>Property</th> + * <th>Type</th> + * <th>Mandatory</th> + * <th>Description</th> + * </tr> + * <tr> + * <td><tt>slotName</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>The name of a slot whose content should be dumped.</td> + * </tr> + * <tr> + * <td><tt>message</tt></td> + * <td>String</td> + * <td>no</td> + * <td>An optional message that will be prefixed to the log output.</td> + * </tr> + * <tr> + * <td><tt>level</tt></td> + * <td>String</td> + * <td>no</td> + * <td>The log level for the message. Valid values are + * <tt>TRACE, DEBUG, INFO, WARN</tt>.</td> + * </tr> + * </table> + */ +public class SlotPrinter extends AbstractWorkflowComponent2 { + private static final Log LOG = LogFactory.getLog(SlotPrinter.class); + private static final int TRACE = 0; + private static final int DEBUG = 1; + private static final int INFO = 2; + private static final int WARN = 3; + private static final String[] LEVELS = { "TRACE", "DEBUG", "INFO", "WARN" }; + + private static final String COMPONENT_NAME = "Slot Printer"; + private String slotName; private String message; - - public void setMessage( String m ) { - this.message = m; + private int level = INFO; + + /** + * Sets the message. + * + * @param msg + * the message + */ + public void setMessage(String msg) { + this.message = msg; } - - public void setSlotName( String name ) { + + /** + * Sets the slot name. + * + * @param name + * name of slot + */ + public void setSlotName(String name) { this.slotName = name; } - - public void checkConfiguration(Issues issues) { - if ( slotName == null ) { + + /** + * Sets the log level + * + * @param lvl + * The log level (TRACE, DEBUG, INFO, WARN, ERROR, FATAL). + */ + public void setLevel(String lvl) { + int i = Arrays.binarySearch(LEVELS, lvl); + if (i == -1) + throw new IllegalArgumentException(lvl); + level = i; + } + + @Override + protected void checkConfigurationInternal(Issues issues) { + if (slotName == null) { issues.addError(this, "slotName not specified"); } } - + @Override protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { StringBuffer b = new StringBuffer(); - if ( message != null ) b.append(message+": "); - b.append("(slot: "+slotName+")"); - b.append( ctx.get(slotName) ); - System.err.println(b.toString()); + if (message != null) { + b.append(message + ": "); + } + b.append("(slot: " + slotName + ")"); + b.append(ctx.get(slotName)); + + switch (level) { + case TRACE: + LOG.trace(b); + break; + case DEBUG: + LOG.debug(b); + break; + case INFO: + LOG.info(b); + break; + case WARN: + LOG.warn(b); + break; + } } - + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java new file mode 100644 index 00000000..10b9b9a6 --- /dev/null +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/SystemCommand.java @@ -0,0 +1,175 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.xtend.util.stdlib; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.eclipse.emf.mwe.core.WorkflowContext; +import org.eclipse.emf.mwe.core.issues.Issues; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; +import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; + +/** + * This component executes a system command. <h2> + * Properties</h2> + * <table border="1"> + * <tr> + * <th>Property</th> + * <th>Type</th> + * <th>Mandatory</th> + * <th>Description</th> + * </tr> + * <tr> + * <td><tt>command</tt></td> + * <td>String</td> + * <td>yes</td> + * <td>The command to execute.</td> + * </tr> + * <tr> + * <td><tt>directory</tt></td> + * <td>String</td> + * <td>no</td> + * <td>Execution directory.</td> + * </tr> + * <tr> + * <td><tt>arg</tt></td> + * <td>String</td> + * <td>no</td> + * <td>(multiple) command arguments.</td> + * </tr> + * <tr> + * <td><tt>env</tt></td> + * <td>String</td> + * <td>no</td> + * <td>(multiple) additional environment entries. Format: [key],[value]</td> + * </tr> + * </table> + * + * <h2>Example</h2> + * + * <pre> + * <component class="oaw.util.stdlib.SystemCommand"> + * <directory value="src-gen"/> + * <command value="sh"/> + * <arg value="processdot.sh"/> + * </component> + * </pre> + * + * @author Karsten Thoms + * @since 4.3.1 + */ +public class SystemCommand extends AbstractWorkflowComponent2 { + private final static Log log = LogFactory.getLog(SystemCommand.class); + + /** + * The execute command. + */ + private String command; + + private File directory; + + private boolean inheritEnvironment = false; + + private List<String> args = new ArrayList<String>(); + private List<String> enventry = new ArrayList<String>(); + + @Override + protected void checkConfigurationInternal(Issues issues) { + if (command == null) { + issues.addError("command not specified"); + } + } + + @Override + protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { + try { + int rc; + List<String> pbArgs = new ArrayList<String>(); + pbArgs.add(command); + pbArgs.addAll(args); + ProcessBuilder pb = new ProcessBuilder(pbArgs); + if (directory != null) { + pb.directory(directory); + } + for (String env : enventry) { + String[] keyvalue = env.split(","); + pb.environment().put(keyvalue[0], keyvalue[1]); + } + if (inheritEnvironment) { + log.debug("Inheriting system environment."); + pb.environment().putAll(System.getenv()); + } + if (log.isDebugEnabled()) { + log.debug("Environment:"); + log.debug(pb.environment()); + log.debug(System.getenv()); + } + log + .info("Running command '" + pb.command() + "' in directory " + pb.directory().getAbsolutePath() + + " ..."); + Process p = pb.start(); + BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); + + String lineRead; + while ((lineRead = br.readLine()) != null) { + log.info(lineRead); + } + + br = new BufferedReader(new InputStreamReader(p.getErrorStream())); + while ((lineRead = br.readLine()) != null) { + log.error(lineRead); + } + rc = p.waitFor(); + if (rc != 0) { + issues.addError("Error running '" + command + "'"); + return; + } + rc = p.exitValue(); + if (rc != 0) { + issues.addError("Execution of command failed with error."); + + } + else { + log.info("Execution of command was successful."); + } + } + catch (Exception re) { + issues.addError("Runtime error: " + re.getMessage()); + } + } + + public String getCommand() { + return command; + } + + public void setCommand(String command) { + this.command = command; + } + + public void setDirectory(File directory) { + this.directory = directory; + } + + public void addArg(String arg) { + args.add(arg); + } + + public void addEnv(String entry) { + if (!entry.matches("\\A[^,]+,.+\\z")) + throw new IllegalArgumentException(entry); + enventry.add(entry); + } + +} diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/TraceComponent.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/TraceComponent.java index e67845a9..c55a8310 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/TraceComponent.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/TraceComponent.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; @@ -31,70 +29,72 @@ import org.eclipse.xtend.util.stdlib.tracing.TraceStore; public class TraceComponent extends AbstractEMFWorkflowComponent { + private static final String COMPONENT_NAME = "Trace Component"; + private String traceModelSlotName; private String traceName; private static TraceStore traceStore = new TraceStore(); private static Stack<String> fileStack = new Stack<String>(); private static int tokenValue = 0; private static MapList cache = new MapList(); - + public static void createTrace(Object from, Object to, String kind) { - TraceElement t = new M2MTraceElement( kind, (EObject)from, (EObject)to ); - traceStore.add( t ); + TraceElement t = new M2MTraceElement(kind, (EObject) from, (EObject) to); + traceStore.add(t); } - + public static void createTrace(Object from, Collection to, String kind) { - TraceElement t = new M2MTraceElement( kind, (EObject)from, (Collection<EObject>)to ); - traceStore.add( t ); + TraceElement t = new M2MTraceElement(kind, (EObject) from, (Collection<EObject>) to); + traceStore.add(t); } - + public static void createTrace(Collection from, Object to, String kind) { - TraceElement t = new M2MTraceElement( kind, (Collection<EObject>)from, (EObject)to ); - traceStore.add( t ); + TraceElement t = new M2MTraceElement(kind, (Collection<EObject>) from, (EObject) to); + traceStore.add(t); } - - public static String createCodeTrace( Object from, String kind ) { - if ( !fileStack.isEmpty() ) { + + public static String createCodeTrace(Object from, String kind) { + if (!fileStack.isEmpty()) { String currentFile = fileStack.peek(); String token = createNewToken(); - TraceElement t = new M2CTraceElement( kind, (EObject)from, currentFile, token ); - traceStore.add( t ); + TraceElement t = new M2CTraceElement(kind, (EObject) from, currentFile, token); + traceStore.add(t); return token; } return "<unknown>"; } private static String createNewToken() { - return "TRACE_"+(tokenValue++); + return "TRACE_" + (tokenValue++); } public static Object getSingleTraceTarget(Object from, String kind) { - List traces = traceStore.getTraces( from, kind ); - if (traces.size() == 0 ) return null; - M2MTraceElement e = (M2MTraceElement)traces.get(0); + List traces = traceStore.getTraces(from, kind); + if (traces.size() == 0) + return null; + M2MTraceElement e = (M2MTraceElement) traces.get(0); return e.getTargets().get(0); } public static Object getTraceTargets(Object from, String kind) { - List traces = traceStore.getTraces( from, kind ); + List traces = traceStore.getTraces(from, kind); List targets = new ArrayList(); for (Iterator iterator = traces.iterator(); iterator.hasNext();) { M2MTraceElement te = (M2MTraceElement) iterator.next(); - targets.addAll( te.getTargets() ); + targets.addAll(te.getTargets()); } return targets; } @Override public String getLogMessage() { - return "building trace model in slot '"+traceModelSlotName+"'"; + return "building trace model in slot '" + traceModelSlotName + "'"; } - public static void clearTrace(Object p) { + public static void clearTrace() { traceStore.clear(); } - public void setTraceModelSlot(String slot) { this.traceModelSlotName = slot; } @@ -105,26 +105,30 @@ public class TraceComponent extends AbstractEMFWorkflowComponent { @Override public void checkConfiguration(Issues issues) { - if (traceModelSlotName == null) + if (traceModelSlotName == null) { issues.addError(this, "you have to specify a traceModelSlot"); - if (traceName == null) + } + if (traceName == null) { issues.addError(this, "you have to specify a traceName"); + } } - - protected void invokeInternal(WorkflowContext ctx, ProgressMonitor mon, Issues issues) { - setUseSingleGlobalResourceSet( true ); + @Override + public void invokeInternal(WorkflowContext ctx, ProgressMonitor mon, Issues issues) { + setUseSingleGlobalResourceSet(true); try { StandaloneSetup setup = new StandaloneSetup(); - setup.addRegisterEcoreFile("platform:/resource/org.eclipse.internal.xtend.util.stdlib/src/org/openarchitectureware/util/stdlib/trace.ecore"); + setup + .addRegisterEcoreFile("platform:/resource/eclipse.xtend.util.stdlib/src/org/openarchitectureware/util/stdlib/trace.ecore"); EPackage pack = setup.getPackage("http://openarchitectureware.org/trace"); DynamicEcoreHelper h = new DynamicEcoreHelper(pack); EObject model = h.create("Trace"); createElementList(h, model); createBySource(h, model); ctx.set(traceModelSlotName, model); - } catch (Exception e) { - issues.addError(this, e.getMessage() ); + } + catch (Exception e) { + issues.addError(this, e.getMessage()); } } @@ -136,7 +140,7 @@ public class TraceComponent extends AbstractEMFWorkflowComponent { Collection traces = cache.get(source); for (Iterator iterator = traces.iterator(); iterator.hasNext();) { EObject item = (EObject) iterator.next(); - h.add( bySource, "items", item); + h.add(bySource, "items", item); } h.add(model, "traceBySource", bySource); } @@ -144,39 +148,44 @@ public class TraceComponent extends AbstractEMFWorkflowComponent { private void createElementList(DynamicEcoreHelper h, EObject model) { EObject list = h.create("TraceList"); - h.set( model , "list", list); + h.set(model, "list", list); for (Iterator iter = traceStore.getAllTraces().iterator(); iter.hasNext();) { - TraceElement element = (TraceElement)iter.next(); + TraceElement element = (TraceElement) iter.next(); EObject item = null; - if ( element instanceof M2MTraceElement ) { - M2MTraceElement m2m = (M2MTraceElement)element; + if (element instanceof M2MTraceElement) { + M2MTraceElement m2m = (M2MTraceElement) element; item = h.create("M2MTraceItem"); - h.set( item, "kind", m2m.getKind()); - h.addAll( item, "from", m2m.getSources()); - h.addAll( item, "to", m2m.getTargets()); + h.set(item, "kind", m2m.getKind()); + h.addAll(item, "from", m2m.getSources()); + h.addAll(item, "to", m2m.getTargets()); h.add(list, "items", item); - } else { - M2CTraceElement m2c = (M2CTraceElement)element; + } + else { + M2CTraceElement m2c = (M2CTraceElement) element; item = h.create("M2CTraceItem"); - h.set( item, "kind", m2c.getKind()); - h.addAll( item, "from", m2c.getSources()); - h.set( item, "targetFile", m2c.getFileName()); - h.set( item, "token", m2c.getToken()); + h.set(item, "kind", m2c.getKind()); + h.addAll(item, "from", m2c.getSources()); + h.set(item, "targetFile", m2c.getFileName()); + h.set(item, "token", m2c.getToken()); h.add(list, "items", item); } - for (Iterator iterator = element.getSources().iterator(); iterator.hasNext();) { - EObject source = (EObject) iterator.next(); - cache.add( source, item ); + for (Iterator<EObject> iterator = element.getSources().iterator(); iterator.hasNext();) { + EObject source = iterator.next(); + cache.add(source, item); } } } public static void reportFileOpen(String path) { - fileStack.push( path ); + fileStack.push(path); } public static void reportFileClose() { fileStack.pop(); } + @Override + public String getComponentName() { + return COMPONENT_NAME; + } } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/UIDHelper.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/UIDHelper.java index fbaae9f8..828ebafe 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/UIDHelper.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/UIDHelper.java @@ -1,18 +1,19 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib; import java.util.HashMap; import java.util.Map; +/** + * Java helper class for Stdlib extension <tt>org::openarchitectureware::util::stdlib::uid</tt>. + */ public class UIDHelper { private static int counter; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/cloning.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/cloning.ext index 0f548145..048cad11 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/cloning.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/cloning.ext @@ -1,5 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ extension org::eclipse::xtend::util::stdlib::tracing; +/** + * Clones an object. + * @param original The object to clone + * @return The cloned object + */ Object clone( Object original ): JAVA org.eclipse.xtend.util.stdlib.CloningExtensions.clone(java.lang.Object); Object cloneWithTrace( Object original, String traceKind ): @@ -8,6 +21,11 @@ Object cloneWithTrace( Object original, String traceKind ): c ); +/** + * Clones a list of objects. + * @param l Source list + * @return A list of cloned objects. + */ List clone( List l ): l.collect( e| e.clone() ); List cloneWithTrace( List l, String traceKind ): l.collect( e| e.cloneWithTrace(traceKind) ); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/codetracing.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/codetracing.ext index fbd3578b..5271afa2 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/codetracing.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/codetracing.ext @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ extension org::eclipse::xtend::util::stdlib::naming; extension org::eclipse::xtend::util::stdlib::io; extension org::eclipse::xtend::util::stdlib::issues; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/collections.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/collections.ext index e7120d42..85e1381b 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/collections.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/collections.ext @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ Set removeDuplicatesByName( Set col ): JAVA org.eclipse.xtend.util.stdlib.DuplicateHelper.removeDuplicatesByName( java.util.Set ); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/counter.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/counter.ext index 35cb9ee7..7206fb8f 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/counter.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/counter.ext @@ -1,17 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: globalvar +// *** ------------------------------------------------------------------------ +// *** This library contains functions to work with counters. +// **************************************************************************** + +/** + * Increments a counter. + * @param o A key for this counter. If this function is called with a Null argument + * an anonymous counter is used. If no counter was registered for the key + * a new counter instance will be created and initialized with 0. + * @return The incremented counter. + */ int counterInc(Object o) : internalCounterInc(o); +/** + * Decrements a counter. + * @param o A key for this counter. If this function is called with a Null argument + * an anonymous counter is used. If no counter was registered for the key + * a new counter instance will be created and initialized with 0. + * @return The decremented counter. + */ int counterDec(Object o) : internalCounterDec(o); +/** + * Resets a counter. + * @param o A key for this counter. If this function is called with a Null argument + * the anonymous counter is resetted. If no counter was registered for the key + * a new counter instance will be created and initialized with 0. + * @return Always 0. + */ int counterReset(Object o) : internalCounterReset(o) -> 0; +/** + * Retrieves the current state of a counter. + * @param o A key for this counter. If this function is called with a Null argument + * the anonymous counter is used. + * @return Current counter value. + */ int counterGet(Object o) : internalCounterGet(o); +// -------------------------------- INTERNAL -------------------------------- + + private Void internalCounterReset(Object o) : JAVA org.eclipse.xtend.util.stdlib.CounterExtensions.counterReset(java.lang.Object); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/crossref.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/crossref.ext index c67b3117..fd6e9384 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/crossref.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/crossref.ext @@ -1,6 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: crossref +// *** ------------------------------------------------------------------------ +// *** This library contains functions to find crossreferences to EObjects. +// **************************************************************************** import emf; +/** + * Retrieves objects that reference a given object. + * @param target The target object. + * @return A list of objects referencing the target. + */ List[EObject] getReferencingObjects(EObject target) : JAVA org.eclipse.xtend.util.stdlib.EmfUtils.getReferencingObjects(org.eclipse.emf.ecore.EObject) ;
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/elementprops.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/elementprops.ext index acba2782..3dd9b081 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/elementprops.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/elementprops.ext @@ -1,5 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: elementprops +// *** ------------------------------------------------------------------------ +// *** This library contains functions for storing and retrieving dynamic +// *** properties on model elements. +// **************************************************************************** + +/** + * Sets a dynamic property on an element. + * @param element The element + * @param name Name of the property to set + * @param value The property value + */ Void setProperty( Object element, String name, Object value ): JAVA org.eclipse.xtend.util.stdlib.ElementPropertiesExtensions.setProperty(java.lang.Object,java.lang.String,java.lang.Object); +/** + * Retrieves a dynamic property from an element. + * @param elements The element + * @param name Property name + * @return The property value + */ Object getProperty( Object element, String name ): JAVA org.eclipse.xtend.util.stdlib.ElementPropertiesExtensions.getProperty(java.lang.Object,java.lang.String);
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/globalvar.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/globalvar.ext index 6a43c3ec..7ff4b470 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/globalvar.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/globalvar.ext @@ -1,3 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: globalvar +// *** ------------------------------------------------------------------------ +// *** This library contains functions to store and retrieve objects. +// **************************************************************************** + +/** + * Stores an object. + * @param s A key + * @param o The object to store. Pass null to remove the global var. + * @return Returns the stored object + */ +Object storeGlobalVar(String s, Object o) : + internalStoreGlobalVar(s,o) -> o +; + +/** + * Retrieves a stored object. + * @param s The key under which the object is stored. + * @return The stored object or null if no object was stored for the key. + */ +Object getGlobalVar(String s) : + internalGetGlobalVar(s) +; + +/** + * Removes a stored object from the global var store. + * @param s The key under which the object is stored. + * @return The stored object or null if no object was stored for the key. + */ +Object removeGlobalVar(String s) : + internalRemoveGlobalVar(s) +; + + +// -------------------------------- INTERNAL -------------------------------- + private Void internalStoreGlobalVar(String s, Object o) : JAVA org.eclipse.xtend.util.stdlib.GlobalVarExtensions.storeGlobalVar(java.lang.String, java.lang.Object) @@ -7,10 +53,6 @@ private Object internalGetGlobalVar(String s) : JAVA org.eclipse.xtend.util.stdlib.GlobalVarExtensions.getGlobalVar(java.lang.String) ; -storeGlobalVar(String s, Object o) : - internalStoreGlobalVar(s,o) -> o -; - -getGlobalVar(String s) : - internalGetGlobalVar(s) +private Object internalRemoveGlobalVar(String s) : + JAVA org.eclipse.xtend.util.stdlib.GlobalVarExtensions.removeGlobalVar(java.lang.String) ; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/io.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/io.ext index 17e9b0ea..c0e2fa6b 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/io.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/io.ext @@ -1,3 +1,18 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: io +// *** ------------------------------------------------------------------------ +// *** This library contains functions for dumping objects to the console or +// *** to stderr. +// **************************************************************************** private Void internalSyserr(Object s) : JAVA org.eclipse.xtend.util.stdlib.IOExtensions.syserr(java.lang.Object); @@ -14,17 +29,52 @@ private Void internalInfo(Object s) : private Void internalError(Object s) : JAVA org.eclipse.xtend.util.stdlib.IOExtensions.error(java.lang.Object); +/** + * Prints an Object to stderr with a prefix string. + * @param o The object that should be printed. null is allowed. + * @param prefix A prefix string for the message. + */ + syserr(Object o) : internalSyserr(o) -> o; +/** + * Prints an Object to stderr with a prefix string. + * @param o The object that should be printed. null is allowed. + * @param prefix A prefix string for the message. + */ syserr(Object o, String prefix) : internalSyserr(o, prefix) -> o; +/** + * Logs an object with DEBUG level to the logger. + * @param o The object to dump. + * @return The object o + */ debug(Object o) : internalDebug(o) -> o; +/** + * Logs an object with INFO level to the logger. + * @param o The object to dump. + * @return The object o + */ info(Object o) : internalInfo(o) -> o; +/** + * Logs an object with ERROR level to the logger. + * @param o The object to dump. + * @return The object o + */ error(Object o) : - internalError(o) -> o;
\ No newline at end of file + internalError(o) -> o; +/** + * Throws an IllegalStateMessage. + * @param o The exception message + * @return Nothing, since an exception is thrown. + */ +throwError(Object o) : + internalError(o) -> o; + +
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/issues.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/issues.ext index 34d63990..1a25e376 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/issues.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/issues.ext @@ -1,13 +1,49 @@ -extension org::eclipse::xtend::util::stdlib::io; +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: issues +// *** ------------------------------------------------------------------------ +// *** This library contains functions to report warnings and errors to +// *** the workflow. +// **************************************************************************** extension org::eclipse::xtend::util::stdlib::naming; -String reportError( String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportError(java.lang.String); +/** + * Reports a warning message to the workflow context. + * @param message A message + * @return The message + */ String reportWarning( String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportWarning(java.lang.String); -String reportError( Object object, String message ): reportErrorInternal( object.qualifiedName(), message ); +/** + * Reports a warning message and the qualified name of a context object to the workflow context. + * @param object A context object + * @param message A message + * @return The message + */ String reportWarning( Object object, String message ): reportWarningInternal( object.qualifiedName(), message ); -String reportErrorInternal( String qfn, String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportError(java.lang.String, java.lang.String); -String reportWarningInternal( String qfn, String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportWarning(java.lang.String, java.lang.String); +/** + * Reports an error message to the workflow context. + * @param message A message + * @return The message + */ +String reportError( String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportError(java.lang.String); + +String reportError( Object object, String message ): reportErrorInternal( object.qualifiedName(), message ); + + +// -------------------------------- INTERNAL -------------------------------- + + +private String reportErrorInternal( String qfn, String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportError(java.lang.String, java.lang.String); +private String reportWarningInternal( String qfn, String message ): JAVA org.eclipse.xtend.util.stdlib.ExtIssueReporter.reportWarning(java.lang.String, java.lang.String);
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/mixin.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/mixin.ext index 3025cae2..6913019f 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/mixin.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/mixin.ext @@ -1,9 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: naming +// *** ------------------------------------------------------------------------ +// *** This library contains functions for supporting mixin models. +// **************************************************************************** extension org::eclipse::xtend::util::stdlib::naming; extension org::eclipse::xtend::util::stdlib::issues; +/** + * Returns the corresponding mixin element for the context object; the mixin + * must be of type t and its name attribute must correspond to the qualified + * name of the context. If none is found, a workflow ERROR is raised and a + * null object is returned (so you can call additional operations on it + * without getting a null evaluation error). + * @param mixinModel The root element of the mixin model. + * @param ctx The context object. + * @param t The type of the mixin model element. + * @return The mixin model element corresponding to ctx. + */ Object getMandatoryMixin( Object mixinModel, Object ctx, oaw::Type t ): let m = getMixin( mixinModel, ctx, t ): m != null ? m : ( reportError( ctx, "no mixin of type "+t.name+" found in mixin model "+mixinModel.metaType.getName()+". Available mixins of that type are "+mixinModel.all(t) ) -> createEmpty(t) ); +/** + * Returns the corresponding mixin element for the context object; the mixin + * must be of type t and its name attribute must correspond to the qualified + * name of the context. If none is found, a null object is returned. + * @param mixinModel The root element of the mixin model. + * @param ctx The context object. + * @param t The type of the mixin model element. + * @return The mixin model element corresponding to ctx. + */ +Object getOptionalMixin( Object mixinModel, Object ctx, oaw::Type t ): + getMixin( mixinModel, ctx, t ); + + + +// -------------------------------- INTERNAL -------------------------------- + + private Collection all( Object container, oaw::Type t ): container.getEAllContents().select(e | t.isInstance(e) ).collect( e| e.getName() ); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/naming.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/naming.ext index ac1f43eb..b139c825 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/naming.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/naming.ext @@ -1,8 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: naming +// *** ------------------------------------------------------------------------ +// *** This library contains functions for evaluating names on model elements, +// *** e.g. computing qualified names from a containment hierarchy. +// *** These functions will only work for EMF based models. It is generally +// *** assumed that elements on which these functions are invoked on +// *** have a feature 'name' of type EString. +// **************************************************************************** extension org::eclipse::xtend::util::stdlib::io; +/** + * Returns the namespace, i.e. the qualified name minus the name of the element itself. + * @param this A model element. + * @return The qualified namespace name of the element. + */ String namespace(Object this): (getEContainer() != null) ? concat( getEContainer().namespace(), getName(getEContainer()) ) : null; + +/** + * Returns the qualified name (dot separated) of an element by evaluating its containment hierarchy. + * @param this A model element. + * @return The qualified name of the element. + */ String qualifiedName(Object this): concat( namespace(), getName() ); +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: naming +// *** ------------------------------------------------------------------------ +// *** This library contains functions for evaluating names on model elements, +// *** e.g. computing qualified names from a containment hierarchy. +// *** These functions will only work for EMF based models. It is generally +// *** assumed that elements on which these functions are invoked on +// *** have a feature 'name' of type EString. +// **************************************************************************** + +/** + * Tries to build a useful description of an element in the model; very useful for error reporting. + * @param this A model element. + * @return Location information about the element. + */ String loc(Object this): namespace() == null ? "["+this.metaType+", "+getName()+"]" : @@ -11,6 +55,12 @@ String loc(Object this): Object findChildByName( Object contextObject, String name, oaw::Type t ): contextObject.getEContents().selectFirst( e | t.isAssignableFrom(e.metaType) && e.getName() == name ); +/** + * Searches the candidates for an element with a specific name. + * @param candidates A collection of model elements. + * @param name The searched element name. + * @return The searched element or null if no element with that name is contained in the candidates collection. + */ Object findByName( Collection candidates, String name ): candidates.selectFirst( e | e.getName() == name ); @@ -30,7 +80,11 @@ Object resolveNameFromParent( Object ctx, String name ): Object findObjectByQualifiedName( Object root, String qName, oaw::Type t ): root.getEAllContents().selectFirst(e | t.isInstance(e) && e.qualifiedName() == qName ); - +/** + * Proves if a name is a qualified name. + * @param name A name string + * @return true if the name contains a dot. + */ boolean isQualifiedName( String name ): name.contains("."); private String getName( Object o ): o.metaType.getProperty("name").get(o); diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/platformhelper.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/platformhelper.ext index 105c64fb..cedc7b04 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/platformhelper.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/platformhelper.ext @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ String platformRootPath(Object ctx): JAVA org.eclipse.xtend.util.stdlib.PlatformHelper.getPlatformRootPath(java.lang.Object); String UrlifiedPlatformRootPath(Object ctx): platformRootPath(ctx).replaceAll(":", "|");
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/properties.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/properties.ext index a77441d4..03e1385c 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/properties.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/properties.ext @@ -1,8 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** openArchitectureWare stdlib extensions: properties +// *** ------------------------------------------------------------------------ +// *** This library contains functions accessing values from property files. +// **************************************************************************** + +/** + * Retrieves a property from class <tt>org.eclipse.xtend.util.stdlib.PropertiesExtension</tt>. + * Properties are populated by the <tt>org.eclipse.xtend.util.stdlib.PropertiesReader</tt> + * workflow component. + * @param key Property key + * @return Property value, if defined, else <tt>null</tt>. + */ +String getProperty(String key) : + internalGetProperty(key).toString() +; + + +// -------------------------------- INTERNAL -------------------------------- private Object internalGetProperty(String s) : JAVA org.eclipse.xtend.util.stdlib.PropertiesExtension.getProperty(java.lang.String) ; -String getProperty(String s) : - internalGetProperty(s).toString() -; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Failed.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Failed.java index 3e7499c5..45e6e4d4 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Failed.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Failed.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.texttest; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/FileTestComponent.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/FileTestComponent.java index 228c5bc6..e6cb617c 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/FileTestComponent.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/FileTestComponent.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.texttest; @@ -14,57 +12,64 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; -public abstract class FileTestComponent extends AbstractWorkflowComponent { +public abstract class FileTestComponent extends AbstractWorkflowComponent2 { private Issues issues; - - private final Log log = LogFactory.getLog(getClass()); - - public void checkConfiguration(Issues issues) { + + private final Log log = LogFactory.getLog(getClass()); + + @Override + protected void checkConfigurationInternal(Issues issues) { } @Override - protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, - Issues issues) { + protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { this.issues = issues; try { test(); log.info(" tests completed successfully."); - } catch ( Failed f ) { - issues.addError( f.getMessage() ); + } + catch (Failed f) { + issues.addError(f.getMessage()); log.info(" TESTS FAILED!"); } } + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ @Override public String getLogMessage() { return "running tests..."; } - + protected abstract void test(); - - protected boolean assertTrue( boolean condition, String message ) { - if (!condition) issues.addError(message); + + protected boolean assertTrue(boolean condition, String message) { + if (!condition) { + issues.addError(message); + } return condition; } - protected void assertTrueFatal( boolean condition, String message ) { - if (!condition) issues.addError(message); - throw new RuntimeException("TEST STOPPED: "+message); + protected void assertTrueFatal(boolean condition, String message) { + if (!condition) { + issues.addError(message); + } + throw new RuntimeException("TEST STOPPED: " + message); } - + protected Handle getHandleGenerated(String idlFileName) { Handle handle = new Handle(idlFileName); return handle; } - + protected Handle getHandleCompare(String idlFileName) { Handle handle = new Handle(idlFileName); return handle; } - } diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Handle.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Handle.java index fe8618fb..07868610 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Handle.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/texttest/Handle.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.texttest; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing.ext index 84d8998a..7c8fec24 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing.ext @@ -1,24 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + extension org::eclipse::xtend::util::stdlib::naming; extension org::eclipse::xtend::util::stdlib::io; extension org::eclipse::xtend::util::stdlib::issues; +/** + * Creates a trace between two elements. + * @param from Source element + * @param to Target element. + * @param kind Name for the trace from source to target. + * @param backKind Name for the trace from target back to source. + */ Void createTrace( Object from, Object to, String kind, String backKind ): createTrace( from, to, kind ) -> createTrace( to, from, backKind ); +/** + * Creates a trace between two elements. + * @param from Source element + * @param to Target element. + * @param kind Name for the trace. + */ Void createTrace( Object from, Object to, String kind ): JAVA org.eclipse.xtend.util.stdlib.TraceComponent.createTrace(java.lang.Object, java.lang.Object, java.lang.String); -Void clearTrace(Object ctx): - JAVA org.eclipse.xtend.util.stdlib.TraceComponent.clearTrace(java.lang.Object); +/** + * Clears all traces. + */ +Void clearTrace(): + JAVA org.eclipse.xtend.util.stdlib.TraceComponent.clearTrace(); +/** + * Finds the target of a trace. This function will report an error if no trace for the source + * element to the target of the specified kind can be found. + * @param from Source element. + * @param kind Trace kind name. + * @return The target element of that trace. + */ Object getSingleTraceTarget( Object from, String kind ): let t = getTargetInternal(from, kind): t != null ? t : reportError("cannot find a "+kind+" trace for "+from.qualifiedName() ); +/** + * Proves if a trace of a specific kind exists for some element. + * @param from Some model element. + * @param kind Name of the trace. + * @return true, if a trace of that kind exists for the element. + */ boolean hasTrace( Object from, String kind ): getTargetInternal(from, kind) != null; + +// -------------------------------- INTERNAL -------------------------------- + + + private Object getTargetInternal( Object from, String kind ): JAVA org.eclipse.xtend.util.stdlib.TraceComponent.getSingleTraceTarget(java.lang.Object, java.lang.String);
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2CTraceElement.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2CTraceElement.java index 4efd7f86..aab42c78 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2CTraceElement.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2CTraceElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.tracing; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2MTraceElement.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2MTraceElement.java index df9886fc..bdb99c7d 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2MTraceElement.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/M2MTraceElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.tracing; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/MapList.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/MapList.java index 864774b6..b3f4ed1e 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/MapList.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/MapList.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.tracing; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceElement.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceElement.java index 9a947f84..5617135b 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceElement.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.tracing; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceStore.java b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceStore.java index 3b75ec84..ed9a456c 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceStore.java +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/TraceStore.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.util.stdlib.tracing; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/html.xpt b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/html.xpt index 80dfd4d7..74d67746 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/html.xpt +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/html.xpt @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ «IMPORT trace» «EXTENSION org::eclipse::xtend::util::stdlib::naming» diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/util.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/util.ext index 30bb34c7..ce7c1aba 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/util.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/tracing/templates/util.ext @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ import trace; extension org::eclipse::xtend::util::stdlib::naming; diff --git a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/uid.ext b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/uid.ext index bf0260d8..0d25727e 100644 --- a/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/uid.ext +++ b/plugins/org.eclipse.xtend.util.stdlib/src/org/eclipse/xtend/util/stdlib/uid.ext @@ -1,4 +1,40 @@ -String createUID( Object o ): JAVA org.eclipse.xtend.util.stdlib.UIDHelper.createNewUID( java.lang.Object ); +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ + +// **************************************************************************** +// *** eclipse.xtend stdlib extensions: uid +// *** ------------------------------------------------------------------------ +// *** This library contains functions to create an retrieve unique identifiers +// *** for model elements. +// **************************************************************************** + +/** + * Retrieves an unique identifier for an object. Creates a new one on first access. + * @param o A model element or other object. + * @return The UID for this object. + */ cached String uid( Object o ): JAVA org.eclipse.xtend.util.stdlib.UIDHelper.uid( java.lang.Object ); + +/** + * Creates a unique identifier for an object. + * @param o A model element or other object. + * @return A newly created UID for this object. + */ +String createUID( Object o ): JAVA org.eclipse.xtend.util.stdlib.UIDHelper.createNewUID( java.lang.Object ); + +/** + * Retrieves an object's identifier. The object must be read from a + * XMLResource. + * + * @param obj An object + * @return The object's id. Returns null if the object was not load from a XMLResource. + */ +String xmlId (ecore::EObject o) : JAVA org.eclipse.xtend.util.stdlib.EmfUtils.getID( org.eclipse.emf.ecore.EObject );
\ No newline at end of file diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java index 62a7db13..6c130efd 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/CheckFastAnalyzer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.check.codeassist; @@ -33,7 +31,7 @@ import org.eclipse.xtend.typesystem.Type; public class CheckFastAnalyzer { private final static Pattern VALIDATE_PATTERN = Pattern - .compile("context\\s+([\\[\\]:\\w\\]]+)(#|\\s+)[^;]*\\z"); + .compile("context\\s+([\\[\\]:\\w\\]]+)\\s+[^;]*\\z"); private final static Pattern TYPEDECL_PATTERN = Pattern.compile("context\\s+[\\[\\]:\\w\\]]*\\z"); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/package.html new file mode 100644 index 00000000..3d4c5ae8 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/check/codeassist/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Codeassist implementation for the Check component +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java new file mode 100644 index 00000000..4dd0c5b1 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractExpressionVisitor.java @@ -0,0 +1,208 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xtend.expression.ast; + +public abstract class AbstractExpressionVisitor extends AbstractVisitor { + + @Override + public final Object visit(final ISyntaxElement ele) { + Object result = null; + if (result == null && ele instanceof BooleanOperation) { + result = visitBooleanOperation((BooleanOperation) ele); + } + if (result == null && ele instanceof Cast) { + result = visitCast((Cast) ele); + } + if (result == null && ele instanceof ConstructorCallExpression) { + result = visitConstructorCallExpression((ConstructorCallExpression) ele); + } + if (result == null && ele instanceof GlobalVarExpression) { + result = visitGlobalVarExpression((GlobalVarExpression) ele); + } + if (result == null && ele instanceof ChainExpression) { + result = visitChainExpression((ChainExpression) ele); + } + if (result == null && ele instanceof CollectionExpression) { + result = visitCollectionExpression((CollectionExpression) ele); + } + if (result == null && ele instanceof OperationCall) { + result = visitOperationCall((OperationCall) ele); + } + if (result == null && ele instanceof TypeSelectExpression) { + result = visitTypeSelectExpression((TypeSelectExpression) ele); + } + if (result == null && ele instanceof FeatureCall) { + result = visitFeatureCall((FeatureCall) ele); + } + if (result == null && ele instanceof IfExpression) { + result = visitIfExpression((IfExpression) ele); + } + if (result == null && ele instanceof LetExpression) { + result = visitLetExpression((LetExpression) ele); + } + if (result == null && ele instanceof SwitchExpression) { + result = visitSwitchExpression((SwitchExpression) ele); + } + if (result == null && ele instanceof ListLiteral) { + result = visitListLiteral((ListLiteral) ele); + } + if (result == null && ele instanceof BooleanLiteral) { + result = visitBooleanLiteral((BooleanLiteral) ele); + } + if (result == null && ele instanceof IntegerLiteral) { + result = visitIntegerLiteral((IntegerLiteral) ele); + } + if (result == null && ele instanceof NullLiteral) { + result = visitNullLiteral((NullLiteral) ele); + } + if (result == null && ele instanceof RealLiteral) { + result = visitRealLiteral((RealLiteral) ele); + } + if (result == null && ele instanceof StringLiteral) { + result = visitStringLiteral((StringLiteral) ele); + } + return result; + } + + protected Object visitBooleanOperation(BooleanOperation node) { + if (node.getLeft() != null) { + node.getLeft().accept(this); + } + if (node.getRight() != null) { + node.getRight().accept(this); + } + return node; + } + + protected Object visitCast(Cast node) { + if (node.getTarget() != null) { + node.getTarget().accept(this); + } + return node; + } + + protected Object visitConstructorCallExpression(ConstructorCallExpression node) { + return node; + } + + protected Object visitGlobalVarExpression(GlobalVarExpression node) { + return node; + } + + protected Object visitChainExpression(ChainExpression ce) { + if (ce.getFirst() != null) { + ce.getFirst().accept(this); + } + if (ce.getNext() != null) { + ce.getNext().accept(this); + } + return ce; + } + + protected Object visitFeatureCall(FeatureCall fc) { + if (fc.getTarget() != null) { + fc.getTarget().accept(this); + } + return fc; + } + + protected Object visitCollectionExpression(CollectionExpression node) { + if (node.getClosure() != null) { + node.getClosure().accept(this); + } + if (node.getTarget() != null) { + node.getTarget().accept(this); + } + return node; + } + + protected Object visitOperationCall(OperationCall oc) { + if (oc.getTarget() != null) { + oc.getTarget().accept(this); + } + if (oc.getParamsAsList() != null) { + for (Expression expr : oc.getParamsAsList()) { + expr.accept(this); + } + } + return oc; + } + + protected Object visitTypeSelectExpression(TypeSelectExpression node) { + if (node.getTarget() != null) { + node.getTarget().accept(this); + } + return node; + } + + protected Object visitIfExpression(IfExpression node) { + if (node.getCondition() != null) { + node.getCondition().accept(this); + } + if (node.getThenPart() != null) { + node.getThenPart().accept(this); + } + if (node.getElsePart() != null) { + node.getElsePart().accept(this); + } + return node; + } + + protected Object visitLetExpression(LetExpression node) { + if (node.getTargetExpression() != null) { + node.getTargetExpression().accept(this); + } + if (node.getVarExpression() != null) { + node.getVarExpression().accept(this); + } + return node; + } + + protected Object visitSwitchExpression(SwitchExpression node) { + for (Case caze : node.getCases()) { + if (caze.getCondition() != null) { + caze.getCondition().accept(this); + } + if (caze.getThenPart() != null) { + caze.getThenPart().accept(this); + } + } + if (node.getSwitchExpr() != null) { + node.getSwitchExpr().accept(this); + } + if (node.getDefaultExpr() != null) { + node.getDefaultExpr().accept(this); + } + return node; + } + + protected Object visitListLiteral(ListLiteral node) { + return node; + } + + protected Object visitBooleanLiteral(BooleanLiteral node) { + return node; + } + + protected Object visitIntegerLiteral(IntegerLiteral node) { + return node; + } + + protected Object visitNullLiteral(NullLiteral node) { + return node; + } + + protected Object visitRealLiteral(RealLiteral node) { + return node; + } + + protected Object visitStringLiteral(StringLiteral node) { + return node; + } +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractVisitor.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractVisitor.java new file mode 100644 index 00000000..51230c1b --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/AbstractVisitor.java @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.internal.xtend.expression.ast; + +public abstract class AbstractVisitor { + abstract public Object visit(final ISyntaxElement ele); +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java index f4a6d340..61dbf0df 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -23,16 +21,17 @@ import org.eclipse.xtend.typesystem.Type; */ public class BooleanLiteral extends Literal { - public BooleanLiteral( final Identifier literalValue) { - super(literalValue); - } + public BooleanLiteral(final Identifier literalValue) { + super(literalValue); + } - @Override - public Object evaluateInternal(final ExecutionContext ctx) { - return new Boolean(getLiteralValue().getValue()); - } + @Override + public Object evaluateInternal(final ExecutionContext ctx) { + return new Boolean(getLiteralValue().getValue()); + } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { - return ctx.getBooleanType(); - } + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + return ctx.getBooleanType(); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java index f43febbc..a01ba3fa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/BooleanOperation.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -81,7 +79,7 @@ public class BooleanOperation extends Expression { return ctx.handleNullEvaluation(this); return b; } else - throw new EvaluationException("Unkown Boolean operator " + operator.getValue(), this, ctx); + throw new EvaluationException("Unknown Boolean operator " + operator.getValue(), this, ctx); } private Boolean evaluateToBoolean(final Expression expr, final ExecutionContext ctx) { @@ -96,7 +94,8 @@ public class BooleanOperation extends Expression { return result; } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type l = left.analyze(ctx, issues); final Type r = right.analyze(ctx, issues); if (l == null || r == null) diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java index b752592f..29312ed1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Case.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java index 3bf6c4e4..dc4813f8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Cast.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -48,7 +46,7 @@ public class Cast extends Expression { return getTarget().evaluate(ctx); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type t = getTarget().analyze(ctx, issues); final Type toCast = findType(getType(), ctx, issues); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java index 325aa716..2e412b92 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ChainExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -39,9 +37,9 @@ public class ChainExpression extends Expression { return getNext().evaluate(ctx); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { getFirst().analyze(ctx, issues); - return getNext().analyze(ctx, issues); + return getNext()!=null ? getNext().analyze(ctx, issues) : null; } public Expression getFirst() { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java index 0ffc7432..2157d07b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/CollectionExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -33,222 +31,237 @@ import org.eclipse.xtend.typesystem.Type; * @author Arno Haase * @author Bernd Kolb */ +@SuppressWarnings("unchecked") public class CollectionExpression extends FeatureCall { - private Expression closure; + private Expression closure; - private Identifier eleName; + private Identifier eleName; - public CollectionExpression(final Identifier name, final Identifier eleName, final Expression closure) { - super(name,null); - this.eleName = eleName; - this.closure = closure; - } + public CollectionExpression(final Identifier name, final Identifier eleName, final Expression closure) { + super(name, null); + this.eleName = eleName; + this.closure = closure; + } - @Override + @Override protected String toStringInternal() { - return super.toStringInternal() + "(" + (eleName != null ? eleName.getValue() + "|" : "") + closure + ")"; - } + return super.toStringInternal() + "(" + (eleName != null ? eleName.getValue() + "|" : "") + closure + ")"; + } + + public Expression getClosure() { + return closure; + } - public Expression getClosure () { - return closure; - } - @Override - public Object evaluateInternal(final ExecutionContext ctx) { - Object targetObj = null; - if (getTarget() == null) { - final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); - if (v != null) { - targetObj = v.getValue(); - } - } else { - targetObj = getTarget().evaluate(ctx); - } - if (targetObj == null) - return ctx.handleNullEvaluation(this); - if (!(targetObj instanceof Collection)) { - throw new EvaluationException("Couldn't call '"+this.toString()+"' on an object of java type "+targetObj.getClass().getName(),this, ctx); - } - - if (getName().getValue().equals(SyntaxConstants.COLLECT)) - return executeCollect((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.SELECT)) - return executeSelect((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) - return executeSelectFirst((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.REJECT)) - return executeReject((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.EXISTS)) - return executeExists((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.NOT_EXISTS)) - return executeNotExists((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.FOR_ALL)) - return executeForAll((Collection) targetObj, ctx); - else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) - return executeSortBy((Collection) targetObj, ctx); - else - throw new EvaluationException("Unkown collection operation : " + getName().getValue(), this, ctx); - - } + public Object evaluateInternal(final ExecutionContext ctx) { + Object targetObj = null; + if (getTarget() == null) { + final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); + if (v != null) { + targetObj = v.getValue(); + } + } + else { + targetObj = getTarget().evaluate(ctx); + } + if (targetObj == null) + return ctx.handleNullEvaluation(this); + if (!(targetObj instanceof Collection)) + throw new EvaluationException("Couldn't call '" + toString() + "' on an object of java type " + + targetObj.getClass().getName(), this, ctx); + + if (getName().getValue().equals(SyntaxConstants.COLLECT)) + return executeCollect((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.SELECT)) + return executeSelect((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) + return executeSelectFirst((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.REJECT)) + return executeReject((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.EXISTS)) + return executeExists((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.NOT_EXISTS)) + return executeNotExists((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.FOR_ALL)) + return executeForAll((Collection) targetObj, ctx); + else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) + return executeSortBy((Collection) targetObj, ctx); + else + throw new EvaluationException("Unknown collection operation : " + getName().getValue(), this, ctx); + + } + @SuppressWarnings("unchecked") private Object executeSortBy(Collection collection, final ExecutionContext ctx) { List<Object> result = new ArrayList<Object>(); result.addAll(collection); - Collections.sort(result, new Comparator<Object> () { + Collections.sort(result, new Comparator<Object>() { + @SuppressWarnings("unchecked") public int compare(Object o1, Object o2) { final Object a = closure.evaluate(ctx.cloneWithVariable(new Variable(getElementName(), o1))); final Object b = closure.evaluate(ctx.cloneWithVariable(new Variable(getElementName(), o2))); - if (a==b) - return 0; - if (a==null) - return -1; - if (b==null) - return 1; - if (a instanceof Comparable) - return ((Comparable)a).compareTo(b); + if (a == b) + return 0; + if (a == null) + return -1; + if (b == null) + return 1; + if (a instanceof Comparable) + return ((Comparable) a).compareTo(b); return a.toString().compareTo(b.toString()); - }}); + } + }); return result; } private Object executeForAll(final Collection collection, ExecutionContext ctx) { - if ( collection.size()== 0) return Boolean.FALSE; - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); - final Object result = closure.evaluate(ctx); - if (!(result instanceof Boolean) || !((Boolean) result).booleanValue()) - return Boolean.FALSE; - } - return Boolean.TRUE; - } - - private Object executeExists(final Collection collection, ExecutionContext ctx) { - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) - return Boolean.TRUE; - } - return Boolean.FALSE; - } - - private Object executeNotExists(final Collection collection, ExecutionContext ctx) { - Boolean bool = (Boolean) executeExists(collection, ctx); - return Boolean.valueOf(!bool); - } + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); + final Object result = closure.evaluate(ctx); + if (!(result instanceof Boolean) || !((Boolean) result).booleanValue()) + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + private Object executeExists(final Collection collection, ExecutionContext ctx) { + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) + return Boolean.TRUE; + } + return Boolean.FALSE; + } + private Object executeNotExists(final Collection collection, ExecutionContext ctx) { + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + ctx = ctx.cloneWithVariable(new Variable(getElementName(), iter.next())); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) + return Boolean.FALSE; + } + return Boolean.TRUE; + } + + @SuppressWarnings("unchecked") private Object executeReject(final Collection collection, ExecutionContext ctx) { - final Collection resultCol = new ArrayList(collection); - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - resultCol.remove(ele); - } - } - return resultCol; - } - - private Object executeSelect(final Collection collection, ExecutionContext ctx) { - final Collection<Object> resultCol = new ArrayList<Object>(); - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - resultCol.add(ele); - } - } - return resultCol; - } - - private Object executeSelectFirst(final Collection collection, ExecutionContext ctx) { - final Collection<Object> resultCol = new ArrayList<Object>(); - for (final Iterator iter = collection.iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - final Object result = closure.evaluate(ctx); - if (result instanceof Boolean && ((Boolean) result).booleanValue()) { - resultCol.add(ele); - } - } - if ( resultCol.size() == 0 ) return null; - return resultCol.iterator().next(); - } + final Collection resultCol = new ArrayList(collection); + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) { + resultCol.remove(ele); + } + } + return resultCol; + } + private Object executeSelect(final Collection collection, ExecutionContext ctx) { + final Collection<Object> resultCol = new ArrayList<Object>(); + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) { + resultCol.add(ele); + } + } + return resultCol; + } + + private Object executeSelectFirst(final Collection collection, ExecutionContext ctx) { + final Collection<Object> resultCol = new ArrayList<Object>(); + for (final Iterator iter = collection.iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + final Object result = closure.evaluate(ctx); + if (result instanceof Boolean && ((Boolean) result).booleanValue()) { + resultCol.add(ele); + } + } + if (resultCol.size() == 0) + return null; + return resultCol.iterator().next(); + } + + @SuppressWarnings("unchecked") private Object executeCollect(final Collection collection, ExecutionContext ctx) { - final Collection<Object> resultCol = new ArrayList<Object>(); - for (final Iterator iter = Collections.unmodifiableCollection(collection).iterator(); iter.hasNext();) { - final Object ele = iter.next(); - ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); - resultCol.add(closure.evaluate(ctx)); - } - return resultCol; - } - - @Override - public Type analyze(ExecutionContext ctx, final Set<AnalysationIssue> issues) { - Type targetType = null; - if (getTarget() == null) { - final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); - if (v != null) { - targetType = (Type) v.getValue(); - } - } else { - targetType = getTarget().analyze(ctx, issues); - } - if (targetType == null) - return null; - - if (!(targetType instanceof ParameterizedType)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Collection type expected! was : " - + targetType, getTarget())); - return null; - } - - final Type innerType = ((ParameterizedType) targetType).getInnerType(); - Type result = null; - ctx = ctx.cloneWithVariable(new Variable(getElementName(), innerType)); - final Type closureType = closure.analyze(ctx, issues); - if (getName().getValue().equals(SyntaxConstants.COLLECT)) { - if (targetType.getName().startsWith(BuiltinMetaModel.SET)) - return ctx.getSetType(closureType); - else if (targetType.getName().startsWith(BuiltinMetaModel.LIST)) - return ctx.getListType(closureType); - else - return ctx.getCollectionType(closureType); - } else if (getName().getValue().equals(SyntaxConstants.SELECT) - || getName().getValue().equals(SyntaxConstants.REJECT) - ) { - return targetType; - } else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) { - return innerType; - } else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) { - return ctx.getListType(innerType); - }else if (getName().getValue().equals(SyntaxConstants.TYPE_SELECT)) { - if (closureType == null) - return null; - return ctx.getListType(closureType); - } else if (getName().getValue().equals(SyntaxConstants.EXISTS) - || getName().getValue().equals(SyntaxConstants.NOT_EXISTS) - || getName().getValue().equals(SyntaxConstants.FOR_ALL)) { - if (!ctx.getBooleanType().isAssignableFrom(closureType)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Boolean type expected! was : " - + closureType, closure)); - } - result = ctx.getBooleanType(); - } else { - issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Unknown operation : " - + getName().getValue(), this)); - } - return result; - } - - public String getElementName() { - return eleName != null ? eleName.getValue() : SyntaxConstants.DEFAULT_ELE_NAME; - } + final Collection<Object> resultCol = new ArrayList<Object>(); + for (final Iterator iter = Collections.unmodifiableCollection(collection).iterator(); iter.hasNext();) { + final Object ele = iter.next(); + ctx = ctx.cloneWithVariable(new Variable(getElementName(), ele)); + resultCol.add(closure.evaluate(ctx)); + } + return resultCol; + } + + @Override + public Type analyzeInternal(ExecutionContext ctx, final Set<AnalysationIssue> issues) { + Type targetType = null; + if (getTarget() == null) { + final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); + if (v != null) { + targetType = (Type) v.getValue(); + } + } + else { + targetType = getTarget().analyze(ctx, issues); + } + if (targetType == null) + return null; + + if (!(targetType instanceof ParameterizedType)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Collection type expected! was : " + + targetType, getTarget())); + return null; + } + + final Type innerType = ((ParameterizedType) targetType).getInnerType(); + Type result = null; + ctx = ctx.cloneWithVariable(new Variable(getElementName(), innerType)); + final Type closureType = closure.analyze(ctx, issues); + if (getName().getValue().equals(SyntaxConstants.COLLECT)) { + if (targetType.getName().startsWith(BuiltinMetaModel.SET)) + return ctx.getSetType(closureType); + else if (targetType.getName().startsWith(BuiltinMetaModel.LIST)) + return ctx.getListType(closureType); + else + return ctx.getCollectionType(closureType); + } + else if (getName().getValue().equals(SyntaxConstants.SELECT) + || getName().getValue().equals(SyntaxConstants.REJECT)) + return targetType; + else if (getName().getValue().equals(SyntaxConstants.SELECTFIRST)) + return innerType; + else if (getName().getValue().equals(SyntaxConstants.SORT_BY)) + return ctx.getListType(innerType); + else if (getName().getValue().equals(SyntaxConstants.TYPE_SELECT)) { + if (closureType == null) + return null; + return ctx.getListType(closureType); + } + else if (getName().getValue().equals(SyntaxConstants.EXISTS) + || getName().getValue().equals(SyntaxConstants.NOT_EXISTS) + || getName().getValue().equals(SyntaxConstants.FOR_ALL)) { + if (!ctx.getBooleanType().isAssignableFrom(closureType)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Boolean type expected! was : " + + closureType, closure)); + } + result = ctx.getBooleanType(); + } + else { + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, "Unknown operation : " + + getName().getValue(), this)); + } + return result; + } + + public String getElementName() { + return eleName != null ? eleName.getValue() : SyntaxConstants.DEFAULT_ELE_NAME; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java index 8ab20d88..f018f6f4 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ConstructorCallExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -19,45 +17,46 @@ import org.eclipse.xtend.typesystem.Type; /** * @author Bernd Kolb - * + * */ public class ConstructorCallExpression extends Expression { - private Identifier type; - - public ConstructorCallExpression(final Identifier type) { - this.type = type; - } - - public Identifier getType () { - return type; - } - - public String getTypeName () { - return type.getValue(); - } - - @Override - protected Object evaluateInternal(final ExecutionContext ctx) { - final Type t = ctx.getTypeForName(type.getValue()); - if (t != null) - return t.newInstance(); - else - throw new EvaluationException("Couldn't find type " + type, this, ctx); - } - - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { - final Type t = ctx.getTypeForName(type.getValue()); - if (t == null) { - issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Type not found : " + type, type)); - } - // TODO add isAbstract to Type and check it here! - return t; - } - - @Override + private Identifier type; + + public ConstructorCallExpression(final Identifier type) { + this.type = type; + } + + public Identifier getType() { + return type; + } + + public String getTypeName() { + return type.getValue(); + } + + @Override + protected Object evaluateInternal(final ExecutionContext ctx) { + final Type t = ctx.getTypeForName(type.getValue()); + if (t != null) + return t.newInstance(); + else + throw new EvaluationException("Couldn't find type " + type, this, ctx); + } + + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + final Type t = ctx.getTypeForName(type.getValue()); + if (t == null) { + issues.add(new AnalysationIssue(AnalysationIssue.TYPE_NOT_FOUND, "Type not found : " + type, type)); + } + // TODO add isAbstract to Type and check it here! + return t; + } + + @Override protected String toStringInternal() { - return "new " + getTypeName(); - } + return "new " + getTypeName(); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java index 7c01076c..21cbe18c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/DeclaredParameter.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -21,8 +19,7 @@ public class DeclaredParameter extends SyntaxElement { private Identifier name; - public DeclaredParameter(final Identifier type, - final Identifier name) { + public DeclaredParameter(final Identifier type, final Identifier name) { this.type = type; this.name = name; } @@ -39,4 +36,43 @@ public class DeclaredParameter extends SyntaxElement { public String toString() { return type.getValue() + " " + name.getValue(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null) + return false; + + if (getClass() != obj.getClass()) + return false; + + DeclaredParameter other = (DeclaredParameter) obj; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + + if (type == null) { + if (other.type != null) + return false; + } + else if (!type.equals(other.type)) + return false; + + return true; + } + } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java index 984368eb..271d45b7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Expression.java @@ -1,18 +1,17 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; import java.util.Set; +import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; import org.eclipse.xtend.expression.AnalysationIssue; import org.eclipse.xtend.expression.Analyzable; import org.eclipse.xtend.expression.Evaluatable; @@ -22,11 +21,10 @@ import org.eclipse.xtend.typesystem.Type; /** * @author Bernd Kolb - * + * */ public abstract class Expression extends SyntaxElement implements Analyzable, Evaluatable { - protected Type findType(final Identifier type, final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type toCast = ctx.getTypeForName(type.getValue()); if (toCast == null) { @@ -36,24 +34,61 @@ public abstract class Expression extends SyntaxElement implements Analyzable, Ev } public final Object evaluate(final ExecutionContext ctx) { + Object evaluateInternal = null; try { - Object evaluateInternal = evaluateInternal(ctx); + ProgressMonitor monitor = ctx.getMonitor(); + if (monitor != null && monitor.isCanceled()) + return null; + + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + evaluateInternal = evaluateInternal(ctx); return evaluateInternal; - } catch (final EvaluationException ex) { + } + catch (final EvaluationException ex) { ctx.handleRuntimeException(ex, this, null); return null; - } catch (final RuntimeException ex) { - EvaluationException evalex = new EvaluationException(ex.getMessage(),this, ctx); + } + catch (final RuntimeException ex) { + EvaluationException evalex = new EvaluationException(ex.getMessage(), this, ctx); ctx.handleRuntimeException(evalex, this, null); return null; } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(evaluateInternal); + } + } + } + + public Type analyze(ExecutionContext ctx, Set<AnalysationIssue> issues) { + Type val = null; + try { + if (ctx.getCallback() != null) { + ctx.getCallback().pre(this, ctx); + } + val = analyzeInternal(ctx, issues); + return val; + } + catch (final RuntimeException ex) { + issues.add(new AnalysationIssue(AnalysationIssue.INTERNAL_ERROR, ex.getMessage(), this)); + return null; + } + finally { + if (ctx.getCallback() != null) { + ctx.getCallback().post(val); + } + } } - + + protected abstract Type analyzeInternal(ExecutionContext ctx, Set<AnalysationIssue> issues); + @Override public final String toString() { return toStringInternal(); } - + protected abstract String toStringInternal(); protected abstract Object evaluateInternal(ExecutionContext ctx); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java index 88c8f0cb..ff1981aa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/FeatureCall.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -32,6 +30,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Arno Haase * @author Bernd Kolb */ +@SuppressWarnings("unchecked") public class FeatureCall extends Expression { private Expression target; @@ -176,7 +175,8 @@ public class FeatureCall extends Expression { * * otherwise it's a property */ - public Type analyze(final ExecutionContext ctx, + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { Type targetType = null; if (target == null) { @@ -257,7 +257,7 @@ public class FeatureCall extends Expression { protected Type findType(final Object value, final ExecutionContext ctx) { final Type t = ctx.getType(value); if (t == null) - throw new EvaluationException("Unkown object type : " + throw new EvaluationException("Unknown object type : " + value.getClass().getName(), this, ctx); return t; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java index a57a5b2f..bc4cf1aa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/GlobalVarExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -47,7 +45,7 @@ public class GlobalVarExpression extends Expression { return o.getValue(); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getObjectType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java index 33033c8b..7e3c8242 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ISyntaxElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -23,4 +21,5 @@ public interface ISyntaxElement { public String getNameString(ExecutionContext context); + public Object accept(final AbstractVisitor visitor); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java index 622f78b0..7465dd11 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Identifier.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -61,4 +59,28 @@ public class Identifier extends SyntaxElement { public String toString() { return getValue(); } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((getValue() == null) ? 0 : getValue().hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + + if (obj == null) + return false; + + if (getClass() != obj.getClass()) + return false; + + Identifier other = (Identifier) obj; + return getValue().equals(other.getValue()); + } + } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java index c8c975c6..ae14f64f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IfExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -68,7 +66,7 @@ public class IfExpression extends Expression { } } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type conditionType = getCondition().analyze(ctx, issues); if (conditionType != null && !conditionType.equals(ctx.getBooleanType())) { issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, "Boolean expected", getCondition())); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java index 2510b5ff..d2ed30b8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/IntegerLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -32,7 +30,7 @@ public class IntegerLiteral extends Literal { return new Long(getLiteralValue().getValue()); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getIntegerType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java index da20027d..76d9ec25 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/LetExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -57,7 +55,7 @@ public class LetExpression extends Expression { return targetExpression.evaluate(ctx); } - public Type analyze(ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type t = varExpression.analyze(ctx, issues); if (t == null) return null; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java index d4fd48da..22de5f83 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/ListLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -51,7 +49,7 @@ public class ListLiteral extends Expression { return col; } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { Type t = null; for (int i = 0; i < elements.length; i++) { final Expression element = elements[i]; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java index 96da0c5f..48ae5018 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/Literal.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java index 4af6fa8a..a166302f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/NullLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -32,7 +30,7 @@ public class NullLiteral extends Literal { return null; } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getVoidType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java index 6979bd18..34111eb4 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/OperationCall.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -171,7 +169,7 @@ public class OperationCall extends FeatureCall { } @Override - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { final Type[] paramTypes = new Type[getParams().length]; if (getParams().length > 0) { for (int i = 0; i < getParams().length; i++) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java index 8ccf87b0..6e28f9b8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/RealLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -32,7 +30,7 @@ public class RealLiteral extends Literal { return new Double(getLiteralValue().getValue()); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getRealType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java index d7401574..3648f2ad 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/StringLiteral.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -33,7 +31,7 @@ public class StringLiteral extends Literal { return getValue(); } - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { return ctx.getStringType(); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java index 570bcb70..269a6b9a 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SwitchExpression.java @@ -1,22 +1,23 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; +import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Set; import org.eclipse.xtend.expression.AnalysationIssue; import org.eclipse.xtend.expression.ExecutionContext; +import org.eclipse.xtend.expression.ExpressionFacade; import org.eclipse.xtend.typesystem.Type; /** @@ -26,79 +27,90 @@ import org.eclipse.xtend.typesystem.Type; */ public class SwitchExpression extends Expression { - private Expression switchExpr = null; - - private Expression defaultExpr = null; - - private List<Case> cases = null; - - public SwitchExpression(final Expression switchExpr, - final List<Case> cases, final Expression defaultExpr) { - this.switchExpr = switchExpr; - this.cases = cases; - this.defaultExpr = defaultExpr; - } - - @Override - protected Object evaluateInternal(final ExecutionContext ctx) { - Object switchVal = Boolean.TRUE; - if (switchExpr != null) - switchVal = switchExpr.evaluate(ctx); - for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { - final Case c = iter.next(); - final Object caseCondVal = c.getCondition().evaluate(ctx); - if ((switchVal != null && switchVal.equals(caseCondVal)) || switchVal == caseCondVal) - return c.getThenPart().evaluate(ctx); - } - return defaultExpr.evaluate(ctx); - } - - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { - Type condType = ctx.getBooleanType(); - if (switchExpr != null) - condType = switchExpr.analyze(ctx, issues); - if (condType == null) - return null; - Type returnType = defaultExpr.analyze(ctx, issues); - if (returnType == null) - return null; - for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { - final Case c = iter.next(); - final Type caseCondType = c.getCondition().analyze(ctx, issues); - if (caseCondType != null) { - if (!condType.isAssignableFrom(caseCondType)) { - issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, condType.getName() - + " expected!", c.getCondition())); - } - } - final Type caseThenType = c.getThenPart().analyze(ctx, issues); - if (caseThenType != null) { - if (!returnType.isAssignableFrom(caseThenType)) { - if (caseThenType.isAssignableFrom(returnType)) { - returnType = caseThenType; - } else { - returnType = ctx.getObjectType(); - } - } - } - } - return returnType; - } - - public List<Case> getCases() { - return cases; - } - - public Expression getDefaultExpr() { - return defaultExpr; - } - - public Expression getSwitchExpr() { - return switchExpr; - } - - @Override + private Expression switchExpr = null; + + private Expression defaultExpr = null; + + private List<Case> cases = null; + + public SwitchExpression(final Expression switchExpr, final List<Case> cases, final Expression defaultExpr) { + this.switchExpr = switchExpr; + this.cases = cases; + this.defaultExpr = defaultExpr; + } + + @Override + protected Object evaluateInternal(final ExecutionContext ctx) { + Object switchVal = Boolean.TRUE; + if (switchExpr != null) { + switchVal = switchExpr.evaluate(ctx); + } + for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { + final Case c = iter.next(); + final Object caseCondVal = c.getCondition().evaluate(ctx); + if ((switchVal != null && equals(switchVal, caseCondVal, ctx)) || switchVal == caseCondVal) + return c.getThenPart().evaluate(ctx); + } + return defaultExpr.evaluate(ctx); + } + + private boolean equals(Object switchVal, final Object caseCondVal, ExecutionContext ctx) { + + Map<String, Object> props = new HashMap<String, Object>(); + props.put("swtch", switchVal); + props.put("cse", caseCondVal); + return (Boolean) new ExpressionFacade(ctx).evaluate("swtch==cse", props); + } + + @Override + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + Type condType = ctx.getBooleanType(); + if (switchExpr != null) { + condType = switchExpr.analyze(ctx, issues); + } + if (condType == null) + return null; + Type returnType = defaultExpr.analyze(ctx, issues); + if (returnType == null) + return null; + for (final Iterator<Case> iter = cases.iterator(); iter.hasNext();) { + final Case c = iter.next(); + final Type caseCondType = c.getCondition().analyze(ctx, issues); + if (caseCondType != null) { + if (!condType.isAssignableFrom(caseCondType)) { + issues.add(new AnalysationIssue(AnalysationIssue.INCOMPATIBLE_TYPES, condType.getName() + + " expected!", c.getCondition())); + } + } + final Type caseThenType = c.getThenPart().analyze(ctx, issues); + if (caseThenType != null) { + if (!returnType.isAssignableFrom(caseThenType)) { + if (caseThenType.isAssignableFrom(returnType)) { + returnType = caseThenType; + } + else { + returnType = ctx.getObjectType(); + } + } + } + } + return returnType; + } + + public List<Case> getCases() { + return cases; + } + + public Expression getDefaultExpr() { + return defaultExpr; + } + + public Expression getSwitchExpr() { + return switchExpr; + } + + @Override protected String toStringInternal() { - return "switch " + switchExpr.toStringInternal() ; - } + return "switch " + switchExpr.toStringInternal(); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java index 8e89f10d..b9d4ea48 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/SyntaxElement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -60,4 +58,8 @@ public abstract class SyntaxElement implements ISyntaxElement { public String getNameString(ExecutionContext context) { return toString(); } + + public final Object accept(final AbstractVisitor visitor) { + return visitor.visit(this); + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java index 3620303a..ea624c8c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/TypeSelectExpression.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.ast; @@ -69,7 +67,7 @@ public class TypeSelectExpression extends FeatureCall { final Collection<Object> resultCol = new ArrayList<Object>(); final Type t = ctx.getTypeForName(typeLiteral.getValue()); if (t == null) - throw new EvaluationException("Unkown type '" + typeLiteral + "'", typeLiteral, ctx); + throw new EvaluationException("Unknown type '" + typeLiteral + "'", typeLiteral, ctx); for (final Iterator<?> iter = collection.iterator(); iter.hasNext();) { final Object ele = iter.next(); if (ele!=null && t.isAssignableFrom(ctx.getType(ele))) { @@ -80,7 +78,7 @@ public class TypeSelectExpression extends FeatureCall { } @Override - public Type analyze(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { + public Type analyzeInternal(final ExecutionContext ctx, final Set<AnalysationIssue> issues) { Type targetType = null; if (getTarget() == null) { final Variable v = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/package.html new file mode 100644 index 00000000..5413c988 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/ast/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +AST of the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java index a35e908f..0c45c635 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/CharacterScanner.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java index 25abe946..ee0730b5 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExpressionProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; @@ -143,12 +141,12 @@ public class ExpressionProposalComputer implements ProposalComputer { // members and extensions on implicit variable (this) final Variable implicitVariable = ctx.getVariable(ExecutionContext.IMPLICIT_VARIABLE); - if (implicitVariable != null) { + if (implicitVariable != null && implicitVariable.getValue()!=null) { implicitVariableType = (Type) implicitVariable.getValue(); proposals.addAll(getAllMemberProposals(implicitVariableType, prefix, ctx, factory)); for (StaticProperty p : implicitVariableType.getAllStaticProperties()) { if (p.getName().startsWith(prefix)) { - proposals.add(factory.createStaticPropertyProposal((StaticProperty) p, prefix, false)); + proposals.add(factory.createStaticPropertyProposal(p, prefix, false)); } } } @@ -160,17 +158,15 @@ public class ExpressionProposalComputer implements ProposalComputer { if (extension.getParameterTypes().size() >= 1) { Type firstParameterType = extension.getParameterTypes().get(0); - if (implicitVariable != null) { + if (implicitVariable != null && implicitVariable.getValue()!=null) { implicitVariableType = (Type) implicitVariable.getValue(); if (implicitVariableType.isAssignableFrom(firstParameterType) || firstParameterType.isAssignableFrom(implicitVariableType)) { skip = true; - System.out.println("SKIP"); } } } if (!skip) { - System.out.println("NOSKIP"); proposals.add(factory.createExtensionProposal(extension, prefix)); } } @@ -184,12 +180,13 @@ public class ExpressionProposalComputer implements ProposalComputer { if (implicitVariableType!=null) { for (StaticProperty p : implicitVariableType.getAllStaticProperties()) { if (p.getName().startsWith(prefix)) { - proposals.add(factory.createStaticPropertyProposal((StaticProperty) p, prefix, false)); + proposals.add(factory.createStaticPropertyProposal(p, prefix, false)); } } } } - } else { + } + else { // members and extensions on targetType proposals.addAll(getAllMemberProposals(implicitVariableType, prefix, ctx, factory)); } @@ -221,11 +218,14 @@ public class ExpressionProposalComputer implements ProposalComputer { v.forEach = true; v.expression = expressionString; vars.push(v); - } else if (m.group(4) != null) { + } + else if (m.group(4) != null) { vars.push(null); - } else if (m.group(5) != null) { + } + else if (m.group(5) != null) { vars.pop(); - } else + } + else throw new IllegalStateException("Match:" + m.group()); } for (final Iterator<LazyVar> iter = vars.iterator(); iter.hasNext();) { @@ -240,12 +240,14 @@ public class ExpressionProposalComputer implements ProposalComputer { targetType = ((ParameterizedType) var.getValue()).getInnerType(); } } - } else { + } + else { targetType = new ExpressionFacade(ctx).analyze(expressionString, new HashSet<AnalysationIssue>()); if (v.forEach) { if (targetType instanceof ParameterizedType) { targetType = ((ParameterizedType) targetType).getInnerType(); - } else { + } + else { targetType = null; } } @@ -262,41 +264,43 @@ public class ExpressionProposalComputer implements ProposalComputer { /** * Computes the list of proposals for a type. These proposals are: * <ol> - * <li>Owned features of the type: {@link Property}, {@link StaticProperty} or {@link Operation}. + * <li>Owned features of the type: {@link Property}, {@link StaticProperty} + * or {@link Operation}. * <li>Extensions whose first parameter is of type <code>targetType</code> * <li>For parametrized types all features of the parameter type * </ol> * - * @param targetType Type to search for proposals - * @param prefix A prefix the proposals must match - * @param ctx Current execution context - * @param factory Factory to use for proposal creation - * @return All proposals matching <code>prefix</code> for <code>targetType</code> + * @param targetType + * Type to search for proposals + * @param prefix + * A prefix the proposals must match + * @param ctx + * Current execution context + * @param factory + * Factory to use for proposal creation + * @return All proposals matching <code>prefix</code> for + * <code>targetType</code> */ - private final static List<Object> getAllMemberProposals(Type targetType, final String prefix, final ExecutionContext ctx, - final ProposalFactory factory) { + private final static List<Object> getAllMemberProposals(Type targetType, final String prefix, + final ExecutionContext ctx, final ProposalFactory factory) { final List<Object> result = new ArrayList<Object>(); + final Set<String> nameCache = new HashSet<String>(); if (targetType != null) { - Set<? extends Callable> s = targetType.getAllFeatures(); - for (final Callable f : s) { - if (f.getName().toLowerCase().startsWith(prefix.toLowerCase())) { - if (f instanceof Property) { - result.add(factory.createPropertyProposal((Property) f, prefix, false)); - } else if (f instanceof Operation) { - if (Character.isJavaIdentifierStart(f.getName().charAt(0))) { - result.add(factory.createOperationProposal((Operation) f, prefix, false)); - } - } - } + Set<? extends Callable> s; + result.addAll(addFeatureProposals(targetType, prefix, factory, nameCache)); + Set<? extends Type> superTypes = targetType.getSuperTypes(); + for (final Type t : superTypes) { + result.addAll(addFeatureProposals(targetType, prefix, factory, nameCache)); } - // get all extensions whose first parameter is compatible with 'targetType' + // get all extensions whose first parameter is compatible with + // 'targetType' Set<? extends Extension> extensions = ctx.getAllExtensions(); for (Extension extension : extensions) { if (extension.getName().toLowerCase().startsWith(prefix.toLowerCase())) { if (extension.getParameterTypes().size() >= 1) { Type firstParameterType = extension.getParameterTypes().get(0); - if (targetType.equals(firstParameterType)) { + if (firstParameterType.isAssignableFrom(targetType)) { result.add(factory.createExtensionOnMemberPositionProposal(extension, prefix, false)); } } @@ -310,7 +314,8 @@ public class ExpressionProposalComputer implements ProposalComputer { if (f.getName().toLowerCase().startsWith(prefix.toLowerCase())) { if (f instanceof Property) { result.add(factory.createPropertyProposal((Property) f, prefix, true)); - } else if (f instanceof Operation) { + } + else if (f instanceof Operation) { if (Character.isJavaIdentifierStart(f.getName().charAt(0))) { result.add(factory.createOperationProposal((Operation) f, prefix, true)); } @@ -329,45 +334,78 @@ public class ExpressionProposalComputer implements ProposalComputer { return result; } + private static List<Object> addFeatureProposals(Type targetType, final String prefix, + final ProposalFactory factory, Set<String> nameCache) { + List<Object> result = new ArrayList<Object>(); + Set<? extends Callable> s = targetType.getAllFeatures(); + for (final Callable f : s) { + Object proposal = null; + if (f.getName().toLowerCase().startsWith(prefix.toLowerCase())) { + if (f instanceof Property) { + proposal = factory.createPropertyProposal((Property) f, prefix, false); + } + else if (f instanceof Operation) { + if (Character.isJavaIdentifierStart(f.getName().charAt(0))) { + proposal = factory.createOperationProposal((Operation) f, prefix, false); + } + } + } + if (proposal != null && !factory.isDuplicate(nameCache, proposal)) { + factory.addToCache(nameCache, proposal); + result.add(proposal); + } + } + return result; + } + private static List<Object> getAllCollectionOperations(final String prefix, final ProposalFactory f) { final List<Object> result = new ArrayList<Object>(); final String marked = "expression-with-e"; String s = "select(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "reject(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "selectFirst(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "collect(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "exists(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "notExists(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "forAll(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "sortBy(e|" + marked + ")"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf(marked), marked.length())); + } s = "typeSelect(Type)"; - if (s.startsWith(prefix)) + if (s.startsWith(prefix)) { result.add(f.createCollectionSpecificOperationProposal(s, s, prefix, s.indexOf("Type"), "Type".length())); + } return result; } @@ -401,17 +439,21 @@ public class ExpressionProposalComputer implements ProposalComputer { if (isOperand(t)) { if (lastWasOperator) { lastWasOperator = false; - } else { // two operands in sequence -> stopper! + } + else { // two operands in sequence -> stopper! scanner.nextToken(); stop = true; } - } else if (".".equals(t.getText())) { + } + else if (".".equals(t.getText())) { if (!lastWasOperator) { lastWasOperator = true; - } else + } + else // errorneous expression return new String[] { prefix, expr }; - } else if (isBlockCloser(t) && lastWasOperator) { + } + else if (isBlockCloser(t) && lastWasOperator) { lastWasOperator = false; final Stack<CommonToken> s = new Stack<CommonToken>(); s.push(t); @@ -421,7 +463,8 @@ public class ExpressionProposalComputer implements ProposalComputer { return new String[] { prefix, expr }; if (temp.getType() == t.getType()) { s.push(temp); - } else if (isOpposite(temp, t)) { + } + else if (isOpposite(temp, t)) { s.pop(); } } @@ -436,7 +479,8 @@ public class ExpressionProposalComputer implements ProposalComputer { scanner.nextToken(); } } - } else { + } + else { scanner.nextToken(); // go one forward stop = true; } @@ -445,18 +489,18 @@ public class ExpressionProposalComputer implements ProposalComputer { } } return new String[] { prefix, expr }; - } catch (final Exception e) { + } + catch (final Exception e) { return new String[] { prefix, expr }; } } private final static boolean isMethodName(final CommonToken token) { - if (token != null) { + if (token != null) return token.getType() == XtendLexer.Identifier || methodNames.contains(token.getText()); - } else { + else return false; } - } private final static boolean isOpposite(final CommonToken left, final CommonToken right) { final String temp = blockTokens.get(left.getText()); @@ -470,9 +514,8 @@ public class ExpressionProposalComputer implements ProposalComputer { } private final static boolean isOperand(final CommonToken t) { - return t.getType() == XtendLexer.Identifier || - t.getType() == XtendLexer.IntLiteral || - t.getType() == XtendLexer.StringLiteral || operands.contains(t.getText()); + return t.getType() == XtendLexer.Identifier || t.getType() == XtendLexer.IntLiteral + || t.getType() == XtendLexer.StringLiteral || operands.contains(t.getText()); } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java index 9bb62dd3..b66d18e6 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ExtensionImportProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; @@ -25,6 +23,7 @@ public class ExtensionImportProposalComputer { return p; } + @SuppressWarnings("unchecked") public List<Object> computeProposals(String part, ExecutionContext ctx, ProposalFactory factory, Set<String> extensionFileNames) { String prefix = computePrefix(part); List result = new ArrayList(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java index 145ddf75..26c183a4 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/LazyVar.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java index 042b4738..8bf89e60 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/Proposal.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java index afeb978b..1a1ef6e2 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java index 5b70b292..8f524ac9 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactory.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; +import java.util.Set; + import org.eclipse.internal.xtend.xtend.ast.Extension; import org.eclipse.xtend.typesystem.Operation; import org.eclipse.xtend.typesystem.Property; @@ -22,9 +22,13 @@ public interface ProposalFactory { /** * Creates an proposal for a static property - * @param p The property for which a proposal should be created - * @param prefix Current evaluation text prefix - * @param onCollection <code>true</code>: Proposal is computed on a collection + * + * @param p + * The property for which a proposal should be created + * @param prefix + * Current evaluation text prefix + * @param onCollection + * <code>true</code>: Proposal is computed on a collection * @return A proposal for the content assist */ public Object createStaticPropertyProposal(StaticProperty p, String prefix, boolean onCollection); @@ -33,7 +37,7 @@ public interface ProposalFactory { public Object createCollectionSpecificOperationProposal(String insertString, String displayString, String prefix, int cursor, int marked); - + public Object createDefinitionProposal(final String insertStr, final String displayStr, final String prefix); public Object createExtensionProposal(Extension p, String prefix); @@ -56,4 +60,7 @@ public interface ProposalFactory { public Object createExtensionImportProposal(final String insertStr, final String displayStr, final String prefix, final int cursor, final int marked); + public boolean isDuplicate(Set<String> nameCache, Object proposal); + + public void addToCache(Set<String> nameCache, Object proposal); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java index 262d9d9a..1d8943a7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalFactoryDefaultImpl.java @@ -1,16 +1,16 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; +import java.util.Set; + import org.eclipse.internal.xtend.xtend.ast.Extension; import org.eclipse.xtend.expression.Variable; import org.eclipse.xtend.typesystem.Operation; @@ -80,4 +80,31 @@ public class ProposalFactoryDefaultImpl implements ProposalFactory { return new ProposalImpl(prefix, insertStr, displayStr, displayStr); } + public boolean isDuplicate(Set<String> nameCache, Object proposal) { + if (nameCache == null || proposal == null) + throw new IllegalArgumentException(); + + ProposalImpl p = castToProposal(proposal); + if (p != null) { + if (nameCache.contains(p.getDisplayString())) + return true; + else + return false; + } + return true; + } + + public void addToCache(Set<String> nameCache, Object proposal) { + ProposalImpl p = castToProposal(proposal); + if (p != null) { + nameCache.add(p.getDisplayString()); + } + } + + private ProposalImpl castToProposal(Object obj) { + if (obj instanceof ProposalImpl) + return (ProposalImpl) obj; + + return null; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java index 7db665bf..c4438a0e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ProposalImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java index de289da6..0fe705c8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/ReverseScanner.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java index 20837669..19f834dc 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/TypeProposalComputer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/package.html new file mode 100644 index 00000000..70ef09d6 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/codeassist/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Parser for the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java index b8e953d1..62e46328 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/BaseSpecialTreatment.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java index 77625c26..d08bf381 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/EvaluatedElementWrapper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java index fe71a2d9..1c46e413 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionElementAdapter.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.debug; @@ -27,6 +25,7 @@ import org.eclipse.emf.mwe.core.debug.processing.ElementAdapter; import org.eclipse.internal.xtend.expression.ast.ChainExpression; import org.eclipse.internal.xtend.expression.ast.Expression; import org.eclipse.internal.xtend.expression.ast.FeatureCall; +import org.eclipse.internal.xtend.expression.ast.ISyntaxElement; import org.eclipse.internal.xtend.expression.ast.Literal; import org.eclipse.internal.xtend.expression.ast.OperationCall; import org.eclipse.internal.xtend.type.baseimpl.PolymorphicResolver; @@ -92,15 +91,17 @@ public class ExpressionElementAdapter implements ElementAdapter { public boolean shallSuspend(Object element, int flag) { boolean result = true; - for (BaseSpecialTreatment special : specials) + for (BaseSpecialTreatment special : specials) { result &= !(special.shallNotSuspend(element, flag, context)); + } return result; } public SyntaxElement createElementTO(Object element) { - SyntaxElement to = pres.getStartPresentation((org.eclipse.internal.xtend.expression.ast.SyntaxElement) element, context); - for (BaseSpecialTreatment special : specials) + SyntaxElement to = pres.getStartPresentation((ISyntaxElement) element, context); + for (BaseSpecialTreatment special : specials) { special.adaptSyntaxElement(to, element); + } return to; } @@ -132,9 +133,8 @@ public class ExpressionElementAdapter implements ElementAdapter { } public List<NameValuePair> getVariables(Object element) { - if (element instanceof ChainExpression || element instanceof Literal) { + if (element instanceof ChainExpression || element instanceof Literal) return Collections.EMPTY_LIST; - } if (element instanceof OperationCall) { ArrayList<NameValuePair> result = getAllVisibleVariables(); @@ -161,9 +161,8 @@ public class ExpressionElementAdapter implements ElementAdapter { return result; } - if (element instanceof FeatureCall) { + if (element instanceof FeatureCall) return evaluateFeatureCall((FeatureCall) element); - } if (element instanceof Collection) { List<NameValuePair> result = new ArrayList<NameValuePair>(); Collection col = (Collection) element; @@ -216,9 +215,12 @@ public class ExpressionElementAdapter implements ElementAdapter { return getAllPropertiesFor(type, evaluate); } - // Hint: We don't use the AbstractTypeImpl collection of all properties, because it collects methods with the - // same name from superclasses twice. We take only the most specialized method here (as in Java) - // Is this a bug or intended that way in AbstractTypeImpl? (TODO: ask Sven or Arno) + // Hint: We don't use the AbstractTypeImpl collection of all properties, + // because it collects methods with the + // same name from superclasses twice. We take only the most specialized + // method here (as in Java) + // Is this a bug or intended that way in AbstractTypeImpl? (TODO: ask Sven + // or Arno) private List<NameValuePair> getAllPropertiesFor(Type type, Object element) { ArrayList<NameValuePair> result = new ArrayList<NameValuePair>(); @@ -228,7 +230,8 @@ public class ExpressionElementAdapter implements ElementAdapter { Object value = null; try { value = p.get(element); - } catch (Exception e) { + } + catch (Exception e) { value = "Error: " + e.getMessage(); } if (value != null) { @@ -250,15 +253,17 @@ public class ExpressionElementAdapter implements ElementAdapter { public final Set<Callable> getAllFeatures(Type type) { Map<String, Callable> allFeatures; - if (typeCache.containsKey(type)) + if (typeCache.containsKey(type)) { allFeatures = typeCache.get(type); + } else { allFeatures = new HashMap<String, Callable>(); Callable[] contribs = ((AbstractTypeImpl) type).getContributedFeatures(); addIfNotExist(allFeatures, Arrays.asList(contribs)); for (Type superType : type.getSuperTypes()) { - if (superType != null) + if (superType != null) { addIfNotExist(allFeatures, getAllFeatures(superType)); + } } typeCache.put(type, allFeatures); } @@ -270,8 +275,9 @@ public class ExpressionElementAdapter implements ElementAdapter { private void addIfNotExist(Map<String, Callable> all, Collection<Callable> more) { for (Callable one : more) { String name = one.getName(); - if (!all.containsKey(name)) + if (!all.containsKey(name)) { all.put(name, one); + } } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java index 00b3fa53..e1b1f029 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/ExpressionModelPresentation.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java index 94ad4a33..d3bce726 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/NoResourceSpecial.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005 - 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.debug; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/package.html new file mode 100644 index 00000000..1d6fbb8c --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/debug/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Debugger support for the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/package.html new file mode 100644 index 00000000..52d87ac9 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java index 0bfbc7fb..4fb99031 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/ExpressionFactory.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java index fff1a1d0..b46a410c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/SyntaxConstants.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.expression.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/package.html new file mode 100644 index 00000000..4cdd6270 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/expression/parser/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:35 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Parser for the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java index 1472b72d..88531fc1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/BuiltinMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; @@ -21,20 +19,7 @@ import java.util.Map; import java.util.Set; import org.eclipse.internal.xtend.expression.parser.SyntaxConstants; -import org.eclipse.internal.xtend.type.baseimpl.types.BooleanTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.CollectionTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.FeatureTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.IntegerTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.ListTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.ObjectTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.OperationTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.PropertyTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.RealTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.SetTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.StaticPropertyTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.StringTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.TypeTypeImpl; -import org.eclipse.internal.xtend.type.baseimpl.types.VoidType; +import org.eclipse.internal.xtend.type.baseimpl.types.*; import org.eclipse.internal.xtend.util.Cache; import org.eclipse.xtend.expression.TypeSystem; import org.eclipse.xtend.typesystem.MetaModel; @@ -182,58 +167,128 @@ public final class BuiltinMetaModel implements MetaModel { _knownTypes = new HashSet<Type>(_builtinTypes.values()); } + /** + * Returns the name of the metamodel. + * + * @return name of metamodel + */ public String getName() { return "built-in"; } + /** + * Returns the type for objects. + * + * @return type for objects + */ public final Type getObjectType() { return objectType; } + /** + * Returns the type for boolean objects. + * + * @return type for boolean objects + */ public final Type getBooleanType() { return booleanType; } + /** + * Returns the type for integer objects. + * + * @return type for integer objects + */ public final Type getIntegerType() { return integerType; } + /** + * Returns the type for real objects. + * + * @return type for real objects + */ public Type getRealType() { return realType; } + /** + * Returns the type for string objects. + * + * @return type for string objects + */ public final Type getStringType() { return stringType; } + /** + * Returns the type for type objects. + * + * @return type for type objects + */ public final Type getTypeType() { return typeType; } + /** + * Returns the type for feature objects. + * + * @return type for feature objects + */ public final Type getFeatureType() { return featureType; } + /** + * Returns the type for property objects. + * + * @return type for property objects + */ public final Type getPropertyType() { return propertyType; } + /** + * Returns the type for operation objects. + * + * @return type for operation objects + */ public final Type getOperationType() { return operationType; } + /** + * Returns the type for static property objects. + * + * @return type for static property objects + */ public Type getStaticPropertyType() { return staticPropertyType; } + /** + * Returns the type for collection objects. + * + * @return type for collection objects + */ public final ParameterizedType getCollectionType(final Type innerType) { return new CollectionTypeImpl(innerType, getTypeSystem(), BuiltinMetaModel.COLLECTION); } + /** + * Returns the type for list objects. + * + * @return type for list objects + */ public final ParameterizedType getListType(final Type innerType) { return new ListTypeImpl(innerType, getTypeSystem(), BuiltinMetaModel.LIST); } + /** + * Returns the type for set objects. + * + * @return type for set objects + */ public final ParameterizedType getSetType(final Type innerType) { return new SetTypeImpl(innerType, getTypeSystem(), BuiltinMetaModel.SET); } @@ -242,57 +297,55 @@ public final class BuiltinMetaModel implements MetaModel { @Override protected Type createNew(Object obj) { - if (obj == null) { + if (obj == null) return getVoidType(); - } - if (obj instanceof Set) { + if (obj instanceof Set) return getSetType(getObjectType()); - } - if (obj instanceof List) { + if (obj instanceof List) return getListType(getObjectType()); - } - if (obj instanceof Collection) { + if (obj instanceof Collection) return getCollectionType(getObjectType()); - } // datatypes - if (stringType.isInstance(obj)) { + if (stringType.isInstance(obj)) return stringType; - } - if (integerType.isInstance(obj)) { + if (integerType.isInstance(obj)) return integerType; - } - if (booleanType.isInstance(obj)) { + if (booleanType.isInstance(obj)) return booleanType; - } - if (realType.isInstance(obj)) { + if (realType.isInstance(obj)) return realType; - } - if (typeType.isInstance(obj)) { + if (typeType.isInstance(obj)) return typeType; - } - if (propertyType.isInstance(obj)) { + if (propertyType.isInstance(obj)) return propertyType; - } - if (operationType.isInstance(obj)) { + if (operationType.isInstance(obj)) return operationType; - } - if (staticPropertyType.isInstance(obj)) { + if (staticPropertyType.isInstance(obj)) return staticPropertyType; - } - + return objectType; } }; + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getType(java.lang.Object) + */ public Type getType(final Object obj) { return typeCache.get(obj); } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeForName(java.lang.String) + */ public Type getTypeForName(final String typeName) { return _builtinTypes.get(typeName); } HashSet<Type> _knownTypes; + + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getKnownTypes() + */ public Set<Type> getKnownTypes() { return _knownTypes; } @@ -303,23 +356,35 @@ public final class BuiltinMetaModel implements MetaModel { final char c = javaclassname.charAt(i); if (c == '.') { sb.append(SyntaxConstants.NS_DELIM); - } else { + } + else { sb.append(c); } } return sb.toString(); } + /** + * Returns the type for void objects. + * + * @return type for void objects + */ public Type getVoidType() { return voidType; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#setTypeSystem(org.eclipse.xtend.expression.TypeSystem) + */ public void setTypeSystem(final TypeSystem typeSystem) { if (typeSystem != null) { this.typeSystem = typeSystem; } } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getNamespaces() + */ public Set<String> getNamespaces() { // TODO: provide real implementation return new HashSet<String>(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java index 43ef87b6..36a610f5 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/FeatureImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java index 01907b30..b204b918 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/OperationImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; @@ -24,6 +22,7 @@ public abstract class OperationImpl extends FeatureImpl implements Operation { private Type owner; + @SuppressWarnings("unchecked") public OperationImpl(final Type owner, final String name, final Type returnType, final Type... paramTypes) { super(name, returnType); this.paramTypes = paramTypes == null ? new ArrayList() : Arrays.asList(paramTypes); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java index 1a39cc60..3dafe851 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PolymorphicResolver.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; @@ -61,6 +59,7 @@ public class PolymorphicResolver { return getFeature(callables, Callable.class, name, paramTypes); } + @SuppressWarnings("unchecked") public static <T> Set<T> select(final Set<? extends Callable> features, final Class<T> type) { final Set<T> result = new HashSet<T>(); for (Callable callable : features) { @@ -71,6 +70,7 @@ public class PolymorphicResolver { return result; } + @SuppressWarnings("unchecked") public final static Callable getFeature(final Set<? extends Callable> features, final Class type, final String name, final List<? extends Type> paramTypes) { final List<Callable> possFeatures = new ArrayList<Callable>(); @@ -88,12 +88,25 @@ public class PolymorphicResolver { else if (possFeatures.isEmpty()) return null; else { - // sort features by specialization - Collections.sort(possFeatures, paramFeatureComparator); - if (paramFeatureComparator.compare(possFeatures.get(1), possFeatures.get(0)) > 0) { - return possFeatures.get(0); + // remove assignable features + for (int c1 = 0; c1 < possFeatures.size() - 1; ++c1) { + Callable feature1 = possFeatures.get(c1); + for (int c2 = c1 + 1; c2 < possFeatures.size(); ++c2) { + Callable feature2 = possFeatures.get(c2); + if (paramFeatureComparator.compare(feature2, feature1) > 0) { + possFeatures.remove(c2); + --c2; + } else if (paramFeatureComparator.compare(feature1, feature2) > 0) { + possFeatures.remove(c1); + --c1; + break; + } + } } + if (possFeatures.size() == 1) + return possFeatures.get(0); + for (Callable callable : possFeatures) { if (callable instanceof Extension) { throw new RuntimeException("Ambiguous operations " + possFeatures.get(0).toString() + " and " + possFeatures.get(1).toString() diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java index 1dcae7d8..c7a85a28 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/PropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java index 7df5a017..8d65b02c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/StaticPropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java index 84c114a1..e8ab1ef8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/TypesComparator.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/package.html new file mode 100644 index 00000000..e0886998 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Basic abstractions of the type system +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java index 022d8490..e37a178f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BooleanTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -28,6 +26,7 @@ public final class BooleanTypeImpl extends BuiltinBaseType implements Type { return o instanceof Boolean; } + @SuppressWarnings("unchecked") @Override public Object convert(final Object src, final Class targetType) { if (targetType == Boolean.class || targetType == Boolean.TYPE) diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java index b27d7da1..92193adc 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/BuiltinBaseType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java index e34e8358..bc988ec8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/CollectionTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -19,6 +17,8 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.eclipse.internal.xtend.type.baseimpl.OperationImpl; import org.eclipse.internal.xtend.type.baseimpl.PropertyImpl; import org.eclipse.xtend.expression.TypeSystem; @@ -30,298 +30,316 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class CollectionTypeImpl extends BuiltinBaseType implements ParameterizedType { - private Type innerType; - - public CollectionTypeImpl(final Type innerType, final TypeSystem ts, final String name) { - super(ts, name); - this.innerType = innerType; - } - - public Type getInnerType() { - return innerType; - } - - public ParameterizedType cloneWithInnerType(final Type innerType) { - return (ParameterizedType) getTypeSystem().getCollectionType(innerType); - } - - @Override - protected boolean internalIsAssignableFrom(final Type t) { - return super.internalIsAssignableFrom(t); - } - - public boolean isInstance(final Object o) { - return o instanceof Collection; - } - - public Object newInstance() { - return new ArrayList<Object>(); - } - - @Override - public Feature[] getContributedFeatures() { - return new Feature[] { - new OperationImpl(this, "toList", getTypeSystem().getListType(getInnerType())) { - - @Override - public String getDocumentation() { - return "converts this collection to List"; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - return new ArrayList<Object>(((Collection<?>) target)); - } - - @Override - public Type getReturnType(final Type targetType, final Type[] paramTypes) { - if (!(targetType instanceof ParameterizedType)) - return getReturnType(); - final TypeSystem ts = getTypeSystem(); - return ts.getListType(((ParameterizedType) targetType).getInnerType()); - } - }, - - new OperationImpl(this, "toSet", getTypeSystem().getSetType(getInnerType())) { - - @Override - public String getDocumentation() { - return "converts this collection to Set"; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - return new java.util.HashSet<Object>((Collection<?>) target); - } - - @Override - public Type getReturnType(final Type targetType, final Type[] paramTypes) { - if (!(targetType instanceof ParameterizedType)) - return getReturnType(); - final TypeSystem ts = getTypeSystem(); - return ts.getSetType(((ParameterizedType) targetType).getInnerType()); - } - }, - - new OperationImpl(this, "toString", getTypeSystem().getStringType(), getTypeSystem() - .getStringType() ) { - - @Override - public String getDocumentation() { - return "concatenates each contained element (using toString()), separated by the specified String."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - final StringBuffer buff = new StringBuffer(); - for (final Iterator<?> iter = ((Collection<?>) target).iterator(); iter.hasNext();) { - buff.append(iter.next().toString()); - if (iter.hasNext()) { - buff.append(params[0].toString()); - } - } - return buff.toString(); - } - }, - - new PropertyImpl(this, "size", getTypeSystem().getIntegerType()) { - - @Override - public String getDocumentation() { - return "returns the size of this Collection"; - } - - public Object get(final Object target) { - return new Long(((Collection<?>) target).size()); - } - }, - - new PropertyImpl(this, "isEmpty", getTypeSystem().getBooleanType()) { - - @Override - public String getDocumentation() { - return "returns true if this Collection is empty"; - } - - public Object get(final Object target) { - return new Boolean(((Collection<?>) target).size() == 0); - } - }, - - new OperationImpl(this, "add", this, getInnerType() ) { - - @Override - public String getDocumentation() { - return "adds an element to the Collection (modifies it!). returns this Collection."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - ((Collection<Object>) target).add(params[0]); - return target; - } - }, - - new OperationImpl(this, "addAll", this, getTypeSystem().getCollectionType( - getInnerType()) ) { - - @Override - public String getDocumentation() { - return "adds all elements to the Collection (modifies it!). returns this Collection."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - ((Collection<?>) target).addAll((Collection) params[0]); - return target; - } - }, - - new OperationImpl(this, "contains", getTypeSystem().getBooleanType(), getTypeSystem() - .getObjectType() ) { - - @Override - public String getDocumentation() { - return "returns true if this collection contains the specified object. otherwise false. returns this Collection."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - return Boolean.valueOf(((Collection) target).contains(params[0])); - } - }, - - new OperationImpl(this, "containsAll", getTypeSystem().getBooleanType(), getTypeSystem() - .getCollectionType(getTypeSystem().getObjectType()) ) { - - @Override - public String getDocumentation() { - return "returns true if this collection contains each element contained in the specified collection. otherwise false. returns this Collection."; - } + private static final Log LOG = LogFactory.getLog(CollectionTypeImpl.class); + + private Type innerType; + + public CollectionTypeImpl(final Type innerType, final TypeSystem ts, final String name) { + super(ts, name); + this.innerType = innerType; + } + + public Type getInnerType() { + return innerType; + } + + public ParameterizedType cloneWithInnerType(final Type innerType) { + return (ParameterizedType) getTypeSystem().getCollectionType(innerType); + } + + @Override + protected boolean internalIsAssignableFrom(final Type t) { + return super.internalIsAssignableFrom(t); + } + + public boolean isInstance(final Object o) { + return o instanceof Collection; + } + + public Object newInstance() { + return new ArrayList<Object>(); + } + + @Override + public Feature[] getContributedFeatures() { + return new Feature[] { + new OperationImpl(this, "toList", getTypeSystem().getListType(getInnerType())) { + + @Override + public String getDocumentation() { + return "converts this collection to List"; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + if (target == null) { + LOG.warn("toList called with Null argument. Will return an empty list."); + return new ArrayList<Object>(0); + } + return new ArrayList<Object>(((Collection<?>) target)); + } + + @Override + public Type getReturnType(final Type targetType, final Type[] paramTypes) { + if (!(targetType instanceof ParameterizedType)) + return getReturnType(); + final TypeSystem ts = getTypeSystem(); + return ts.getListType(((ParameterizedType) targetType).getInnerType()); + } + }, + + new OperationImpl(this, "toSet", getTypeSystem().getSetType(getInnerType())) { + + @Override + public String getDocumentation() { + return "converts this collection to Set"; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + if (target == null) { + LOG.warn("toSet called with Null argument. Will return an empty set."); + return new ArrayList<Object>(0); + } + return new java.util.LinkedHashSet<Object>((Collection<?>) target); + } + + @Override + public Type getReturnType(final Type targetType, final Type[] paramTypes) { + if (!(targetType instanceof ParameterizedType)) + return getReturnType(); + final TypeSystem ts = getTypeSystem(); + return ts.getSetType(((ParameterizedType) targetType).getInnerType()); + } + }, + + new OperationImpl(this, "toString", getTypeSystem().getStringType(), getTypeSystem().getStringType()) { + + @Override + public String getDocumentation() { + return "concatenates each contained element (using toString()), separated by the specified String."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + final StringBuffer buff = new StringBuffer(); + for (final Iterator<?> iter = ((Collection<?>) target).iterator(); iter.hasNext();) { + buff.append(iter.next().toString()); + if (iter.hasNext()) { + buff.append(params[0].toString()); + } + } + return buff.toString(); + } + }, + + new PropertyImpl(this, "size", getTypeSystem().getIntegerType()) { + + @Override + public String getDocumentation() { + return "returns the size of this Collection"; + } + + public Object get(final Object target) { + return new Long(((Collection<?>) target).size()); + } + }, + + new PropertyImpl(this, "isEmpty", getTypeSystem().getBooleanType()) { + + @Override + public String getDocumentation() { + return "returns true if this Collection is empty"; + } + + public Object get(final Object target) { + if (target == null) { + LOG.warn("isEmpty called with Null argument. Will return true."); + return Boolean.TRUE; + } + return new Boolean(((Collection<?>) target).size() == 0); + } + }, + + new OperationImpl(this, "add", this, getInnerType()) { + + @Override + public String getDocumentation() { + return "adds an element to the Collection (modifies it!). returns this Collection."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + ((Collection<Object>) target).add(params[0]); + return target; + } + }, + + new OperationImpl(this, "addAll", this, getTypeSystem().getCollectionType(getInnerType())) { + + @Override + public String getDocumentation() { + return "adds all elements to the Collection (modifies it!). returns this Collection."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + ((Collection<?>) target).addAll((Collection) params[0]); + return target; + } + }, + + new OperationImpl(this, "contains", getTypeSystem().getBooleanType(), getTypeSystem().getObjectType()) { + + @Override + public String getDocumentation() { + return "returns true if this collection contains the specified object. otherwise false. returns this Collection."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + return Boolean.valueOf(((Collection) target).contains(params[0])); + } + }, + + new OperationImpl(this, "containsAll", getTypeSystem().getBooleanType(), getTypeSystem() + .getCollectionType(getTypeSystem().getObjectType())) { + + @Override + public String getDocumentation() { + return "returns true if this collection contains each element contained in the specified collection. otherwise false. returns this Collection."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + return Boolean.valueOf(((Collection) target).containsAll((Collection) params[0])); + } + }, + + new OperationImpl(this, "remove", this, getTypeSystem().getObjectType()) { + + @Override + public String getDocumentation() { + return "removes the specified element from this Collection if contained (modifies it!). returns this Collection."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + ((Collection) target).remove(params[0]); + return target; + } + }, + + new OperationImpl(this, "removeAll", this, getTypeSystem().getObjectType()) { + + @Override + public String getDocumentation() { + return "removes all elements contained in the specified collection from this Collection if contained (modifies it!). returns this Collection."; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + ((Collection) target).removeAll((Collection) params[0]); + return target; + } + }, + + new OperationImpl(this, "union", getTypeSystem().getSetType(getInnerType()), getTypeSystem() + .getCollectionType(getTypeSystem().getObjectType())) { + + @Override + public String getDocumentation() { + return "returns a new Set, containing all elements from this and the specified Collection"; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + final Set r = new HashSet((Collection) target); + if (params != null && params[0] != null) { + r.addAll((Collection) params[0]); + } + else { + LOG.warn("Invoking union() with Null as argument. Will return the source collection."); + } + return r; + } + }, + + new OperationImpl(this, "without", getTypeSystem().getSetType(getInnerType()), getTypeSystem() + .getCollectionType(getTypeSystem().getObjectType())) { + + @Override + public String getDocumentation() { + return "returns a new Set, containing all elements from this Collection without the elements from specified Collection"; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + final Set r = new HashSet((Collection) target); + r.removeAll((Collection) params[0]); + return r; + } + }, + + new OperationImpl(this, "intersect", getTypeSystem().getSetType(getInnerType()), getTypeSystem() + .getCollectionType(getTypeSystem().getObjectType())) { + + @Override + public String getDocumentation() { + return "returns a new Set, containing only the elements contained in this and the specified Collection"; + } + + @Override + public Object evaluateInternal(final Object target, final Object[] params) { + final Set r = new HashSet((Collection) target); + r.retainAll((Collection) params[0]); + return r; + } + }, + + new OperationImpl(this, "flatten", getTypeSystem().getListType(getTypeSystem().getObjectType()), + new Type[0]) { + + @Override + public String getDocumentation() { + return "returns a flattened List."; + } @Override - public Object evaluateInternal(final Object target, final Object[] params) { - return Boolean.valueOf(((Collection) target).containsAll((Collection) params[0])); - } - }, - - new OperationImpl(this, "remove", this, getTypeSystem().getObjectType() ) { - - @Override - public String getDocumentation() { - return "removes the specified element from this Collection if contained (modifies it!). returns this Collection."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - ((Collection) target).remove(params[0]); - return target; - } - }, - - new OperationImpl(this, "removeAll", this, getTypeSystem().getObjectType() ) { - - @Override - public String getDocumentation() { - return "removes all elements contained in the specified collection from this Collection if contained (modifies it!). returns this Collection."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - ((Collection) target).removeAll((Collection) params[0]); - return target; - } - }, - - new OperationImpl(this, "union", getTypeSystem().getSetType(getInnerType()), - getTypeSystem().getCollectionType(getTypeSystem().getObjectType())) { - - @Override - public String getDocumentation() { - return "returns a new Set, containing all elements from this and the specified Collection"; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - final Set r = new HashSet((Collection) target); - r.addAll((Collection) params[0]); - return r; - } - }, - - new OperationImpl(this, "without", getTypeSystem().getSetType(getInnerType()), - getTypeSystem().getCollectionType(getTypeSystem().getObjectType()) ) { - - @Override - public String getDocumentation() { - return "returns a new Set, containing all elements from this Collection without the elements from specified Collection"; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - final Set r = new HashSet((Collection) target); - r.removeAll((Collection) params[0]); - return r; - } - }, - - new OperationImpl(this, "intersect", getTypeSystem().getSetType(getInnerType()), - getTypeSystem().getCollectionType(getTypeSystem().getObjectType()) ) { - - @Override - public String getDocumentation() { - return "returns a new Set, containing only the elements contained in this and the specified Collection"; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - final Set r = new HashSet((Collection) target); - r.retainAll((Collection) params[0]); - return r; - } - }, - - new OperationImpl(this, "flatten", getTypeSystem().getListType(getTypeSystem().getObjectType()), - new Type[0]) { - - @Override - public String getDocumentation() { - return "returns a flatten List."; - } - - @Override - public Object evaluateInternal(final Object target, final Object[] params) { - return flattenRec((Collection) target); - } - - public List<Object> flattenRec(final Collection col) { - final List<Object> result = new ArrayList<Object>(); - for (final Object element : col) { - if (element instanceof Collection) { - result.addAll(flattenRec((Collection) element)); - } else { - result.add(element); - } - } - return result; - } - } - - }; - } - - @Override - public Set<Type> getSuperTypes() { - return Collections.singleton(getTypeSystem().getObjectType()); - } - - @Override - public String toString() { - String s = getName(); - if (innerType != null) { - s += "[" + innerType + "]"; - } - return s; - } + public Object evaluateInternal(final Object target, final Object[] params) { + return flattenRec((Collection) target); + } + + public List<Object> flattenRec(final Collection col) { + final List<Object> result = new ArrayList<Object>(); + for (final Object element : col) { + if (element instanceof Collection) { + result.addAll(flattenRec((Collection) element)); + } + else { + result.add(element); + } + } + return result; + } + } + + }; + } + + @Override + public Set<Type> getSuperTypes() { + return Collections.singleton(getTypeSystem().getObjectType()); + } + + @Override + public String toString() { + String s = getName(); + if (innerType != null) { + s += "[" + innerType + "]"; + } + return s; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java index 9f3af2ee..66cfb932 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/FeatureTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java index c80ec008..b59a242b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/IntegerTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -189,7 +187,7 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type { @Override public String getDocumentation() { return "returns a List of Integers starting with the value of the target expression, up to " - + "the value of the specified Integer, incremented by one." + + "the value of the specified Integer, incremented by one.<br/>" + "e.g. '1.upTo(5)' evaluates to {1,2,3,4,5}"; } @@ -210,7 +208,7 @@ public final class IntegerTypeImpl extends BuiltinBaseType implements Type { @Override public String getDocumentation() { return "returns a List of Integers starting with the value of the target expression, up to " - + "the value of the first paramter, incremented by the second parameter." + + "the value of the first paramter, incremented by the second parameter.<br/>" + "e.g. '1.upTo(10, 2)' evaluates to {1,3,5,7,9}"; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java index c77fdf6b..857d75d8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ListTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -69,7 +67,7 @@ public class ListTypeImpl extends CollectionTypeImpl implements Type { } return null; } - }, new OperationImpl(this, "reverse", getInnerType(), new Type[0]) { + }, new OperationImpl(this, "reverse", getTypeSystem().getCollectionType(getInnerType()), new Type[0]) { @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target instanceof List) { @@ -90,6 +88,7 @@ public class ListTypeImpl extends CollectionTypeImpl implements Type { return null; } }, new OperationImpl(this, "withoutFirst", this, new Type[0]) { + @SuppressWarnings("unchecked") @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target instanceof List) { @@ -103,6 +102,7 @@ public class ListTypeImpl extends CollectionTypeImpl implements Type { return null; } }, new OperationImpl(this, "withoutLast", this, new Type[0]) { + @SuppressWarnings("unchecked") @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target instanceof List) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java index 474e3292..48c85b61 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/ObjectTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -25,6 +23,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class ObjectTypeImpl extends BuiltinBaseType implements Type { public ObjectTypeImpl(final TypeSystem ts, final String name) { @@ -111,6 +110,7 @@ public class ObjectTypeImpl extends BuiltinBaseType implements Type { + "or greater than the specified object."; } + @SuppressWarnings("unchecked") @Override public Object evaluateInternal(final Object target, final Object[] params) { if (target == null) diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java index 5086c001..e5aa603c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/OperationTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java index f9016d42..03de84da 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/PropertyTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java index 0280c048..32893b08 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/RealTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java index 67616037..2b95b70f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/SetTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java index 6971038a..862eb563 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StaticPropertyTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java index abc8d176..924a4c79 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/StringTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -30,6 +28,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class StringTypeImpl extends BuiltinBaseType implements Type { final Log log = LogFactory.getLog(getClass()); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java index 165737cf..fd011c75 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/TypeTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; @@ -25,6 +23,7 @@ import org.eclipse.xtend.typesystem.Type; * @author Sven Efftinge (http://www.efftinge.de) * @author Arno Haase */ +@SuppressWarnings("unchecked") public class TypeTypeImpl extends BuiltinBaseType { public TypeTypeImpl(final TypeSystem ts, final String name) { @@ -157,7 +156,7 @@ public class TypeTypeImpl extends BuiltinBaseType { } }, - new OperationImpl(this, "newInstance", getTypeSystem().getObjectType(), new Type[0]) { + new OperationImpl(this, "newInstance", getTypeSystem().getObjectType()) { @Override public Object evaluateInternal(final Object target, final Object[] params) { return ((Type) target).newInstance(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java index 9e29701a..9c3ee7ad 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/VoidType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.baseimpl.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/package.html new file mode 100644 index 00000000..fbe7d91a --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/baseimpl/types/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Basic builtin types +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java index ada5aa34..af1e36ba 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaBeansMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java index ba7ce7da..d7786633 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; @@ -36,10 +34,16 @@ public class JavaMetaModel implements MetaModel, TypeFinder { private TypeSystem typeSystem; + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeSystem() + */ public TypeSystem getTypeSystem() { return typeSystem; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#setTypeSystem(org.eclipse.xtend.expression.TypeSystem) + */ public void setTypeSystem(final TypeSystem typeSystem) { if (typeSystem != null) { this.typeSystem = typeSystem; @@ -59,13 +63,12 @@ public class JavaMetaModel implements MetaModel, TypeFinder { @Override protected Type createNew(Class<?> clazz) { JavaTypeImpl impl = new JavaTypeImpl(JavaMetaModel.this, clazz, getName(clazz), _strategy); - if (List.class.isAssignableFrom(clazz)) { + if (List.class.isAssignableFrom(clazz)) return typeSystem.getListType(typeSystem.getObjectType()); - } else if (Set.class.isAssignableFrom(clazz)) { + else if (Set.class.isAssignableFrom(clazz)) return typeSystem.getSetType(typeSystem.getObjectType()); - } else if (Collection.class.isAssignableFrom(clazz)) { + else if (Collection.class.isAssignableFrom(clazz)) return typeSystem.getCollectionType(typeSystem.getObjectType()); - } return impl; } }; @@ -84,7 +87,8 @@ public class JavaMetaModel implements MetaModel, TypeFinder { try { Class<?> loadedClass = ResourceLoaderFactory.createResourceLoader().loadClass(classname); return loadedClass == null ? NOCLASS : loadedClass; - } catch (Exception e1) { + } + catch (Exception e1) { // FIXME: This catch block should really be removed - the // built-in ResosurceLoader implementation // never throws an exception, and contributed implementations @@ -94,6 +98,9 @@ public class JavaMetaModel implements MetaModel, TypeFinder { } }; + /** + * @see org.eclipse.internal.xtend.type.impl.java.TypeFinder#builtinAwareGetTypeForName(java.lang.String) + */ public Type builtinAwareGetTypeForName(final String typeName) { Type type = typeSystem.getTypeForName(typeName); if (type == null) { @@ -102,14 +109,19 @@ public class JavaMetaModel implements MetaModel, TypeFinder { return type; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getTypeForName(java.lang.String) + */ public Type getTypeForName(final String typeName) { final Class<?> clazz = classCache.get(typeName); - if (clazz == NOCLASS) { + if (clazz == NOCLASS) return null; - } return getTypeForClass(clazz); } + /** + * @see org.eclipse.internal.xtend.type.impl.java.TypeFinder#builtinAwareGetType(java.lang.Object) + */ public Type builtinAwareGetType(final Object obj) { Type type = typeSystem.getType(obj); if (type == null) { @@ -118,13 +130,18 @@ public class JavaMetaModel implements MetaModel, TypeFinder { return type; } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getType(java.lang.Object) + */ public Type getType(final Object obj) { - if (obj == null) { + if (obj == null) return null; - } return getTypeForClass(obj.getClass()); } + /** + * @see org.eclipse.internal.xtend.type.impl.java.TypeFinder#builtinAwareGetTypeForClass(java.lang.Class) + */ public Type builtinAwareGetTypeForClass(final Class<?> clazz) { Type type = typeSystem.getTypeForName(getName(clazz)); if (type == null) { @@ -133,19 +150,40 @@ public class JavaMetaModel implements MetaModel, TypeFinder { return type; } + /** + * Returns the corresponding type for an <code>EClass</code> object. + * + * @param clazz + * the <code>EClass</code> object + * @return the corresponding type + */ public Type getTypeForClass(final Class<?> clazz) { return cache.get(clazz); } + /** + * @see org.eclipse.xtend.typesystem.MetaModel#getKnownTypes() + */ public Set<Type> getKnownTypes() { final Collection<Type> col = cache.getValues(); return (Set<Type>) (col instanceof Set ? col : new HashSet<Type>(col)); } + /** + * Returns the metamodel name. + * + * @return the metamodel name + */ public String getName() { return _name; } + /** + * Sets the type strategy. + * + * @param strategy + * the type strategy + */ public void setTypeStrategy(final JavaTypeStrategy strategy) { _strategy = strategy; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java index 053c5067..41e2bdef 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaOperationImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java index 66d4ac02..348f34e5 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaPropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java index d92dcb6a..ec516e6b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaStaticPropertyImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java index f5785f77..59211233 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; @@ -54,6 +52,7 @@ public class JavaTypeImpl extends AbstractTypeImpl implements Type { return features; } + @SuppressWarnings("unchecked") @Override public Set<Type> getSuperTypes() { if (superTypes == null) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java index 514c3e68..420b3e0c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/JavaTypeStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java index 7bc9be0b..bde02afa 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/TypeFinder.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java index a3062cc5..578f1d26 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/JavaBeansStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.java.beans; @@ -54,6 +52,7 @@ public class JavaBeansStrategy implements JavaTypeStrategy { * <li> Java5 enumeration literals for defined enum types * </ul> */ + @SuppressWarnings("unchecked") public Feature[] getFeatures(final TypeFinder typeFinder, final Class clazz, final Type t) { final List<FeatureImpl> result = new ArrayList<FeatureImpl>(); @@ -80,45 +79,80 @@ public class JavaBeansStrategy implements JavaTypeStrategy { if (pd.getReadMethod() != null) { usedMethods.add(pd.getReadMethod()); } - result.add(new JavaPropertyImpl(t, propName, typeFinder.builtinAwareGetTypeForClass(pd.getPropertyType()), pd.getReadMethod(), pd + // Problem: pd.getPropertyType() does not allow to get information about generics. When having a generic collection as property type + // the property type is just of the collection interface, e.g. java.util.List + result.add(new JavaPropertyImpl(t, pd.getName(), typeFinder.builtinAwareGetTypeForClass(pd.getPropertyType()), pd.getReadMethod(), pd .getWriteMethod())); } } - final Method[] meths = clazz.getDeclaredMethods(); + Set<Class<?>> classSet = new HashSet<Class<?>>(); + List<Method> methodList = new ArrayList<Method>(); + + if (Modifier.isPublic(clazz.getModifiers())) { + classSet.add(clazz); + } else { + Set<Class<?>> superClasses = getSuperClasses(clazz); + if (superClasses != null) { + classSet = superClasses; + } else { + classSet.add(clazz.getEnclosingClass()); + } + } + + // Methods + for (final Class<?> c : classSet) { + final Method[] meths = c.getDeclaredMethods(); for (int i = 0; i < meths.length; i++) { final Method method = meths[i]; - if (Modifier.isPublic(method.getModifiers()) && !usedMethods.contains(method)) { - // leave the accessor methods in: they don't hurt, and this way + if (Modifier.isPublic(method.getModifiers()) + && !usedMethods.contains(method)) { + // leave the accessor methods in: they don't hurt, and this + // way // we can e.g. call "set" methods try { // special handling for accessor method for boolean // properties, whose return type is // the wrapper type 'Boolean' (not 'boolean') if (isNonStandardBooleanProperty(method)) { - handleNonStandardBooleanProperty(typeFinder, t, result, pdArr, method); + handleNonStandardBooleanProperty(typeFinder, t, + result, pdArr, method); } else { - Type returnType = typeFinder.builtinAwareGetTypeForClass(method.getReturnType()); - result.add(new JavaOperationImpl(t, method.getName(), returnType, createTypes(method.getParameterTypes(), typeFinder), method)); + Type returnType = typeFinder + .builtinAwareGetTypeForClass(method + .getReturnType()); + result + .add(new JavaOperationImpl(t, method + .getName(), returnType, + createTypes(method + .getParameterTypes(), + typeFinder), method)); } } catch (final RuntimeException e) { // ignore } } } + } // staticProps - final Field[] fields = clazz.getFields(); + for (final Class<?> c : classSet) { + final Field[] fields = c.getFields(); for (int i = 0; i < fields.length; i++) { final Field field = fields[i]; final int mod = field.getModifiers(); - if (Modifier.isPublic(mod) && Modifier.isStatic(mod) && Modifier.isFinal(mod)) { - result.add(new JavaStaticPropertyImpl(t, field.getName(), typeFinder.builtinAwareGetTypeForClass(field.getType()), field)); + if (Modifier.isPublic(mod) && Modifier.isStatic(mod) + && Modifier.isFinal(mod)) { + result.add(new JavaStaticPropertyImpl(t, field.getName(), + typeFinder.builtinAwareGetTypeForClass(field + .getType()), field)); + } } } // Java 5 enums - final Object[] enumValues = clazz.getEnumConstants(); + for (final Class<?> c : classSet) { + final Object[] enumValues = c.getEnumConstants(); if (enumValues != null) { for (Object o : enumValues) { final Enum<?> curEnum = (Enum<?>) o; @@ -129,7 +163,7 @@ public class JavaBeansStrategy implements JavaTypeStrategy { }); } } - + } return result.toArray(new Feature[result.size()]); } @@ -205,4 +239,19 @@ public class JavaBeansStrategy implements JavaTypeStrategy { return result; } + private Set<Class<?>> getSuperClasses(Class<?> clazz) { + final Set<Class<?>> superClasses = new HashSet<Class<?>>(); + final Class<?> superClass = clazz.getSuperclass(); + if (superClass != null) { + superClasses.add(superClass); + } + + final Class<?>[] superInterfaces = clazz.getInterfaces(); + if (superInterfaces != null) { + for (Class<?> i: superInterfaces) { + superClasses.add(i); + } + } + return superClasses; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/package.html new file mode 100644 index 00000000..41c65580 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/beans/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Classes for Java beans support +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/package.html new file mode 100644 index 00000000..33218b35 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/java/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Typesystem implementation for Java types +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java index 2dac33ab..db6b671f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/OAWClassicStrategy.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.type.impl.oawclassic; @@ -38,6 +36,7 @@ public class OAWClassicStrategy implements JavaTypeStrategy { return false; } + @SuppressWarnings("unchecked") public Feature[] getFeatures(final TypeFinder typeFinder, final Class clazz, final Type owner) { final List<FeatureImpl> result = new ArrayList<FeatureImpl>(); final Method[] methods = clazz.getMethods(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/package.html new file mode 100644 index 00000000..a6f148d1 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/type/impl/oawclassic/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Typesystem implementation for oAW classic +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java index 5d6f886c..dc8e1c0e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Cache.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java index e1910f3f..83e2da6e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/DoubleKeyCache.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java index 41e082de..d11d4fa6 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/EncodingDetector.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java index 8bcf64bf..aaaa4fb2 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/HigherOrder.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; @@ -19,6 +17,7 @@ import org.eclipse.xtend.expression.ExecutionContextImpl; import org.eclipse.xtend.expression.ExpressionFacade; public class HigherOrder { + @SuppressWarnings("unchecked") public static <T> Collection<T> select(Collection<T> col, String closure) { return (Collection<T>) facade().evaluate("x.select("+closure+")", Collections.singletonMap("x", col)); } @@ -35,6 +34,7 @@ public class HigherOrder { return (Boolean)facade().evaluate("x.select("+closure+")", Collections.singletonMap("x", col)); } + @SuppressWarnings("unchecked") public static <T> T first(Collection<T> col, String closure) { Collection<T> re = (Collection<T>) facade().evaluate("x.select("+closure+")", Collections.singletonMap("x", col)); if (re!=null && re.size()>0) { diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java index be86ce3a..32412285 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Pair.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java index 70640709..9aa37822 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/ProfileCollector.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; @@ -51,7 +49,7 @@ public class ProfileCollector { _out = new PrintWriter (new OutputStreamWriter (out, "utf-8")); _out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); - _out.println("<m2t-profile>"); + _out.println("<oaw-profile>"); } catch (UnsupportedEncodingException exc) {} } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java index 1fc32276..94cbd3af 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/StringHelper.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java index 1a86df32..8cb5bd74 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/TripleKeyCache.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java index be97ba2b..7b350eb2 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/Triplet.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.util; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java index e0e9aed6..9da5f832 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetDetector.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java index 37278da0..e102e3c7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetMatch.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java index 8f7ed015..f2a18f67 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_2022.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java index e513a371..feac31ad 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_UTF8.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java index cb0725b1..5e8c7e48 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_Unicode.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java index 59306e5e..3c3f34d8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_mbcs.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java index 92ff0d21..e9956564 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecog_sbcs.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java index c29d6e50..9ec97635 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/internal/icu/CharsetRecognizer.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.util.internal.icu; /** This code was taken from the com.ibm.icu library (3.6.1). We needed to copy it to have not diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/package.html new file mode 100644 index 00000000..99f551c6 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/util/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Utility classes +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java index 49a88fa0..d2892902 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendAdvice.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java index cf8a5a65..75da47b8 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendFile.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java index 9a891181..766e632f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/XtendResourceParser.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java index 4403a857..9c08df58 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/AbstractExtension.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java index 54eb9e1a..091ecdbd 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Around.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java index 6fa9137e..036114ed 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Check.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java index 5e89b383..3ab0c7b1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/CreateExtensionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java index 080c297f..8848c841 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExpressionExtensionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java index c1e3a853..f57be676 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/Extension.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java index 1ab696c6..15c04e7f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ExtensionFile.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java index 2865ea71..077fc9e1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/ImportStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java index 0812da62..7a541906 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/ast/JavaExtensionStatement.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.ast; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java index 7a38a11c..8ec34609 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/FastAnalyzer.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java index cd8ce0d6..032ccba1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/codeassist/Partition.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.codeassist; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java index e235e4fa..627335fd 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ErrorHandler.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java index 7249e593..5d37e4cf 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ExtensionFactory.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java index 06571dd2..33f01fb1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/GeneratorLauncher.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 itemis AG (http://www.itemis.eu) and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java index 7edf7f39..3bf62cbf 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseException.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java index ea3aba5d..99eefa02 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/ParseFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java index e9708509..befe0897 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/SyntaxError.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java index 7489881c..65371e8c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendError.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java index 82c2eb2e..e5ceb261 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLexer.java @@ -1,4 +1,11 @@ -// $ANTLR 3.0 /Users/huebner/Entwicklung/workspace-oaw5/org.eclipse.xtend/bin/org/eclipse/internal/xtend/xtend/parser/Xtend.g 2008-11-24 17:55:04 +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java index 733707bc..bfd1d748 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendLocationAddingParser.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java index ab44d964..419c25b0 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/parser/XtendParser.java @@ -1,4 +1,11 @@ -// $ANTLR 3.0 /Users/huebner/Entwicklung/workspace-oaw5/org.eclipse.xtend/bin/org/eclipse/internal/xtend/xtend/parser/Xtend.g 2008-11-24 17:55:03 +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.internal.xtend.xtend.parser; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java index 7e552762..b670d831 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContext.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java index afdd4069..bfe98460 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/AdviceContextType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java index ea21a825..fda9f4ea 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/internal/xtend/xtend/types/XtendMetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.internal.xtend.xtend.types; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java index 70675207..3ad88074 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendComponent.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; @@ -33,182 +31,235 @@ import org.eclipse.xtend.expression.Variable; public class XtendComponent extends AbstractExpressionsUsingWorkflowComponent { - String extensionFile = null; - - private final Log log = LogFactory.getLog(getClass()); - - private final List<String> extensionAdvices = new ArrayList<String>(); - - /** Stores the value of the 'invoke' property. Needed for error analysis. */ - private String invokeExpression; - - private String expression = null; - - private String collectProfileSummary = null; - - private String verboseProfileFilename = null; - - private String outputSlot = WorkflowContext.DEFAULT_SLOT; - - @Override - public void addExtensionAdvice(final String extensionAdvices) { - if (!this.extensionAdvices.contains(extensionAdvices)) - this.extensionAdvices.add(extensionAdvices); - } - - @Override - public void checkConfiguration(final Issues issues) { - super.checkConfiguration(issues); - - // Try to create detailed error message (see Bug#172567) - final String compPrefix = getId() != null ? getId() + ": " : ""; - - if (invokeExpression == null || invokeExpression.trim().length() == 0) { - issues.addError(compPrefix + "Property 'invoke' not specified."); - return; - } else if (extensionFile == null) { - issues - .addError(compPrefix - + "Error parsing property 'invoke': Could not extract name of the extension file."); - return; - } - if (getExtFileIS() == null && expression == null) { - issues - .addError(compPrefix - + "Property 'invoke' not specified properly. AbstractExtension file '" - + extensionFile + "' not found."); - return; - } else if (expression == null) { - issues - .addError(compPrefix - + "Error parsing property 'invoke': Could not extract the expression to invoke in extension file '" - + extensionFile + "'."); - return; - } - - } - - @Override - public String getLogMessage() { - return "executing '" + extensionFile + "'"; - } - - @Override - public void invokeInternal2(final WorkflowContext ctx, - final ProgressMonitor monitor, final Issues issues) { - - final InputStream in = getExtFileIS(); - if (in == null) { - issues.addError("Cannot find extension file: " + extensionFile); - return; - } - - try { - in.close(); - } catch (final IOException e) { - log.error("could not close extension file", e); - } - - OutputStream verboseProfileOutputStream = null; - - if (verboseProfileFilename != null) { - try { - verboseProfileOutputStream = - new BufferedOutputStream(new FileOutputStream( - verboseProfileFilename)); - ProfileCollector.getInstance().setDetailedLoggingWriter( - verboseProfileOutputStream); - } catch (final IOException exc) { - log.warn("could not open profiling log file", exc); - } - } - - ExecutionContextImpl ec = getExecutionContext(ctx); - - for (final String advice : extensionAdvices) { - final String[] allAdvices = advice.split(","); - for (final String string : allAdvices) { - ec.registerExtensionAdvices(string.trim()); - } - } - - ec = (ExecutionContextImpl) ec.cloneWithResource(new Resource() { - private String name = "noName"; - - public String getFullyQualifiedName() { - return name; - } - - public String[] getImportedExtensions() { - return new String[] { extensionFile }; - } - - public String[] getImportedNamespaces() { - return new String[0]; - } - - public void setFullyQualifiedName(final String fqn) { - name = fqn; - } - }); - final String[] slots = ctx.getSlotNames(); - for (final String element : slots) { - ec = - (ExecutionContextImpl) ec.cloneWithVariable(new Variable( - element, ctx.get(element))); - } - - if (monitor != null) { - ec.setMonitor(monitor); - } - - final Object result = new ExpressionFacade(ec).evaluate(expression); - ctx.set(outputSlot, result); - - ProfileCollector.getInstance().finish(); - if ("true".equalsIgnoreCase(collectProfileSummary)) { - log.info("profiling info: \n" - + ProfileCollector.getInstance().toString()); - } - - if (verboseProfileOutputStream != null) { - try { - verboseProfileOutputStream.close(); - } catch (final IOException exc) { - log.warn("problem closing profile log file", exc); - } - } - } - - public void setCollectProfileSummary(final String c) { - collectProfileSummary = c; - } - - public void setInvoke(final String invoke) { - invokeExpression = invoke; - final int i = invoke.lastIndexOf("::"); - if (i != -1) { - extensionFile = invoke.substring(0, i); - expression = invoke.substring(i + 2); - } else { - expression = invoke; - } - } - - public void setOutputSlot(final String outputSlot) { - this.outputSlot = outputSlot; - } - - public void setVerboseProfileFilename(final String f) { - verboseProfileFilename = f; - } - - private InputStream getExtFileIS() { - final InputStream in = - ResourceLoaderFactory.createResourceLoader() - .getResourceAsStream( - extensionFile.replace("::", "/") + ".ext"); - return in; - } + private static final String COMPONENT_NAME = "Xtend Component"; + + private final Log log = LogFactory.getLog(getClass()); + + String extensionFile = null; + + private final List<String> extensionAdvices = new ArrayList<String>(); + + /** Stores the value of the 'invoke' property. Needed for error analysis. */ + private String invokeExpression; + + private String expression = null; + + private String collectProfileSummary = null; + + private String verboseProfileFilename = null; + + private String outputSlot = WorkflowContext.DEFAULT_SLOT; + + /** + * Adds an extension advice. + * + * @param extensionAdvice + * the advice + */ + @Override + public void addExtensionAdvice(final String extensionAdvice) { + if (!extensionAdvices.contains(extensionAdvice)) { + extensionAdvices.add(extensionAdvice); + } + } + + /** + * @see org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent#checkConfigurationInternal(org.eclipse.emf.mwe.core.issues.Issues) + */ + @Override + public void checkConfigurationInternal(final Issues issues) { + super.checkConfigurationInternal(issues); + + // Try to create detailed error message (see Bug#172567) + final String compPrefix = getId() != null ? getId() + ": " : ""; + + if (invokeExpression == null || invokeExpression.trim().length() == 0) { + issues.addError(compPrefix + "Property 'invoke' not specified."); + return; + } + if (extensionFile == null) { + issues.addError(compPrefix + + "Error parsing property 'invoke': Could not extract name of the extension file."); + return; + } + + final InputStream in = getExtFileIS(); + if (in == null || expression == null) { + issues.addError(compPrefix + "Property 'invoke' not specified properly. AbstractExtension file '" + + extensionFile + "' not found."); + return; + } + + try { + in.close(); + } + catch (final IOException e) { + log.error("I/O exception", e); + } + + if (expression == null) { + issues.addError(compPrefix + + "Error parsing property 'invoke': Could not extract the expression to invoke in extension file '" + + extensionFile + "'."); + return; + } + + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ + @Override + public String getLogMessage() { + return "executing '" + extensionFile + "'"; + } + + /** + * @see org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent#invokeInternal2(org.eclipse.emf.mwe.core.WorkflowContext, + * org.eclipse.emf.mwe.core.monitor.ProgressMonitor, + * org.eclipse.emf.mwe.core.issues.Issues) + */ + @Override + public void invokeInternal2(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { + + final InputStream in = getExtFileIS(); + if (in == null) { + issues.addError("Cannot find extension file: " + extensionFile); + return; + } + else { + try { + in.close(); + } + catch (final IOException e) { + log.error("I/O exception", e); + } + } + + OutputStream verboseProfileOutputStream = null; + + if (verboseProfileFilename != null) { + try { + verboseProfileOutputStream = new BufferedOutputStream(new FileOutputStream(verboseProfileFilename)); + ProfileCollector.getInstance().setDetailedLoggingWriter(verboseProfileOutputStream); + } + catch (final IOException exc) { + log.warn("could not open profiling log file", exc); + } + } + + ExecutionContextImpl ec = getExecutionContext(ctx); + + for (final String advice : extensionAdvices) { + final String[] allAdvices = advice.split(","); + for (final String string : allAdvices) { + ec.registerExtensionAdvices(string.trim()); + } + } + + ec = (ExecutionContextImpl) ec.cloneWithResource(new Resource() { + private String name = "noName"; + + public String getFullyQualifiedName() { + return name; + } + + public String[] getImportedExtensions() { + return new String[] { extensionFile }; + } + + public String[] getImportedNamespaces() { + return new String[0]; + } + + public void setFullyQualifiedName(final String fqn) { + name = fqn; + } + }); + final String[] slots = ctx.getSlotNames(); + for (final String slot : slots) { + ec = (ExecutionContextImpl) ec.cloneWithVariable(new Variable(slot, ctx.get(slot))); + } + + if (monitor != null) { + ec.setMonitor(monitor); + } + + final Object result = new ExpressionFacade(ec).evaluate(expression); + ctx.set(outputSlot, result); + + ProfileCollector.getInstance().finish(); + if ("true".equalsIgnoreCase(this.collectProfileSummary)) { + log.info("profiling info: \n" + ProfileCollector.getInstance().toString()); + } + + if (verboseProfileOutputStream != null) { + try { + verboseProfileOutputStream.close(); + } + catch (final IOException exc) { + log.warn("problem closing profile log file", exc); + } + } + } + + /** + * Sets the collect profile summary. + * + * @param summary + * the summary + */ + public void setCollectProfileSummary(final String summary) { + collectProfileSummary = summary; + } + + /** + * Sets the invoke expression. + * + * @param invokeExpr + * the invoke expression + */ + public void setInvoke(final String invokeExpr) { + invokeExpression = invokeExpr; + final int i = invokeExpr.lastIndexOf("::"); + if (i != -1) { + extensionFile = invokeExpr.substring(0, i); + expression = invokeExpr.substring(i + 2); + } + else { + expression = invokeExpr; + } + } + + /** + * Sets the output slot. + * + * @param outputSlot + * the output slot + */ + public void setOutputSlot(final String outputSlot) { + this.outputSlot = outputSlot; + } + + /** + * Sets the filename for the verbose profile. + * + * @param fileName + * the filename + */ + public void setVerboseProfileFilename(final String fileName) { + verboseProfileFilename = fileName; + } + + @Override + public String getComponentName() { + return COMPONENT_NAME; + } + + private InputStream getExtFileIS() { + final InputStream in = ResourceLoaderFactory.createResourceLoader().getResourceAsStream( + extensionFile.replace("::", "/") + ".ext"); + return in; + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java index e8d9e488..780c0c9d 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendResourceParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendResourceParser.java new file mode 100644 index 00000000..175da5d5 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/XtendResourceParser.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.xtend; + +import java.io.Reader; + +import org.eclipse.internal.xtend.xtend.parser.ParseFacade; +import org.eclipse.xtend.expression.Resource; +import org.eclipse.xtend.expression.ResourceParser; + +public class XtendResourceParser implements ResourceParser { + + public Resource parse(final Reader in, final String fileName) { + return ParseFacade.file(in, fileName); + } + +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java index a04ede86..c71f9f6f 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckComponent.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; @@ -29,100 +27,152 @@ import org.eclipse.xtend.expression.ExpressionFacade; public class CheckComponent extends AbstractExpressionsUsingWorkflowComponent { - private String expression = null; - - private List<String> checkFiles = new ArrayList<String>(); - - private boolean abortOnError = true; - - private boolean warnIfNothingChecked = false; - - private String emfAllChildrenSlot; + private static final String COMPONENT_NAME = "Check component"; + + private String expression = null; + + private List<String> checkFiles = new ArrayList<String>(); + + private boolean abortOnError = true; + + private boolean warnIfNothingChecked = false; + + private String emfAllChildrenSlot; + + /** + * Sets if execution should be aborted on error. + * + * @param abortOnError + * If <code>true</code>, the execution is aborted on error, + * otherwise, the execution is continued normally. + */ + public void setAbortOnError(final boolean abortOnError) { + this.abortOnError = abortOnError; + } + + /** + * Adds a check file. + * + * @param checkFile + * the check file + */ + public void addCheckFile(final String checkFile) { + this.checkFiles.add(checkFile); + } + + /** + * Sets the expression to check. This property only works for non-EMF based + * models. For EMF based models, use + * <code>setEmfAllChildrenSlot(String)</code>. + * + * @param expression + * the expression to check + */ + public void setExpression(final String expression) { + this.expression = expression; + } + + /** + * Sets if a warning should be issued if nothing has been checked. + * + * @param warn + * If <code>true</code>, a warning is issued in case nothing has + * been checked, otherwise no warning is issued. + */ + public void setWarnIfNothingChecked(boolean warn) { + warnIfNothingChecked = warn; + } + + /** + * Sets the expression for the <code>emfAllChildren</code> property. This + * property only works for EMF based models. For all other kinds of models + * use <code>setExpression(String)</code>. + * + * @param childExpression + * the expression + */ + public void setEmfAllChildrenSlot(final String childExpression) { + emfAllChildrenSlot = childExpression; + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getLogMessage() + */ + @Override + public String getLogMessage() { + StringBuilder b = new StringBuilder(); + if (emfAllChildrenSlot != null) { + b.append("slot " + emfAllChildrenSlot + " "); + } + else { + b.append("expression " + expression + " "); + } + b.append("check file(s): "); + for (String f : checkFiles) { + b.append(f + " "); + } + return b.toString(); + } + + /** + * @see org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent#getComponentName() + */ + @Override + public String getComponentName() { + return COMPONENT_NAME; + } + + @Override + protected void invokeInternal2(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { + final ExecutionContextImpl executionContext = getExecutionContext(ctx); + if (monitor != null) { + executionContext.setMonitor(monitor); + } - public void setAbortOnError(final boolean abortOnError) { - this.abortOnError = abortOnError; - } + final Collection<?> model = getExpressionResult(executionContext, ctx, expression); - public void addCheckFile(final String checkFile) { - this.checkFiles.add(checkFile); - } + for (String checkFile : checkFiles) { + CheckFacade.checkAll(checkFile, model, executionContext, issues, warnIfNothingChecked); + } - public void setExpression(final String expression) { - this.expression = expression; - } + if (abortOnError && issues.hasErrors()) + throw new WorkflowInterruptedException("Errors during validation."); + } - public void setWarnIfNothingChecked(boolean b) { - warnIfNothingChecked = b; - } + @Override + protected void checkConfigurationInternal(final Issues issues) { + super.checkConfigurationInternal(issues); - public void setEmfAllChildrenSlot(final String childExpression) { - emfAllChildrenSlot = childExpression; - } - - public String getLogMessage() { - StringBuilder b = new StringBuilder(); - if ( emfAllChildrenSlot != null ) { - b.append("slot "+emfAllChildrenSlot+" "); - } else { - b.append("expression "+expression+" "); - } - b.append( "check file(s): "); - for (String f: checkFiles) { - b.append( f+" "); + if ((expression == null) && (emfAllChildrenSlot != null)) { + expression = emfAllChildrenSlot + ".eAllContents.union( {" + emfAllChildrenSlot + "} )"; + } + else if ((expression != null) && (emfAllChildrenSlot == null)) { + // ok - do nothing, expression already has a reasonable value + } + else { + issues.addError(this, "You have to set one of the properties 'expression' and 'emfAllChildrenSlot'!"); + } + if (checkFiles.isEmpty()) { + issues.addError(this, "Property 'checkFile' not set!"); + } + } + + private Collection<?> getExpressionResult(final ExecutionContext exeCtx, final WorkflowContext context, + final String expression2) { + final ExpressionFacade f = new ExpressionFacade(exeCtx); + final Map<String, Object> ctx = new HashMap<String, Object>(); + final String[] names = context.getSlotNames(); + for (int i = 0; i < names.length; i++) { + final String name = names[i]; + ctx.put(name, context.get(name)); } - return b.toString(); - } - - - @Override - protected void invokeInternal2(final WorkflowContext ctx, final ProgressMonitor monitor, final Issues issues) { - final ExecutionContextImpl executionContext = getExecutionContext(ctx); - if (monitor!=null) { - executionContext.setMonitor(monitor); - } - - final Collection<?> model = getExpressionResult(executionContext, ctx, expression); - - for (String checkFile : checkFiles) { - CheckFacade.checkAll(checkFile, model, executionContext, issues, warnIfNothingChecked); - } - - if (abortOnError && issues.hasErrors()) - throw new WorkflowInterruptedException("Errors during validation."); - } - - - - public void checkConfiguration(final Issues issues) { - super.checkConfiguration(issues); - - if ((expression == null) && (emfAllChildrenSlot != null)) { - expression = emfAllChildrenSlot + ".eAllContents.union( {" + emfAllChildrenSlot + "} )"; - } else if ((expression != null) && (emfAllChildrenSlot == null)) { - // ok - do nothing, expression already has a reasonable value - } else { - issues.addError(this, "You have to set one of the properties 'expression' and 'emfAllChildrenSlot'!"); - } - if (checkFiles.isEmpty()) { - issues.addError(this, "Property 'checkFile' not set!"); - } - } - - private Collection<?> getExpressionResult(final ExecutionContext exeCtx, final WorkflowContext context, final String expression2) { - final ExpressionFacade f = new ExpressionFacade(exeCtx); - final Map<String, Object> ctx = new HashMap<String, Object>(); - final String[] names = context.getSlotNames(); - for (int i = 0; i < names.length; i++) { - final String name = names[i]; - ctx.put(name, context.get(name)); - } - final Object result = f.evaluate(expression2, ctx); - if (result instanceof Collection) - return (Collection<?>) result; - else if (result == null) - return Collections.EMPTY_SET; - else - return Collections.singleton(result); - - } + final Object result = f.evaluate(expression2, ctx); + if (result instanceof Collection) + return (Collection<?>) result; + else if (result == null) + return Collections.EMPTY_SET; + else + return Collections.singleton(result); + + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckFacade.java index cf5b2b29..5dd4a397 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckFacade.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; @@ -43,8 +41,11 @@ public class CheckFacade { public final static void checkAll(final String checkFile, final Collection<?> toCheck, final ExecutionContext ctx, final Issues issues, boolean warnIfNothingChecked) { - - final InputStream in = ResourceLoaderFactory.createResourceLoader().getResourceAsStream(CheckUtils.getJavaResourceName(checkFile)); - checkAll(checkFile,in, toCheck, ctx, issues, warnIfNothingChecked); + ExtensionFile file = (ExtensionFile) ctx.getResourceManager().loadResource(checkFile, "chk"); + if (file != null) { + file.check(ctx, toCheck, issues, warnIfNothingChecked); + } else { + issues.addError("Could not load Check file '"+checkFile+"'."); + } } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckUtils.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckUtils.java index 834f2a4d..0bfd0e81 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckUtils.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/CheckUtils.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.check; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/package.html new file mode 100644 index 00000000..5cf9dea5 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/check/package.html @@ -0,0 +1,11 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:37 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of the check component which allows to define constraints that are validated +for the metamodel +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java new file mode 100644 index 00000000..672e6f00 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowAdvice.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.xtend.expression; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.mwe.core.WorkflowComponent; +import org.eclipse.emf.mwe.core.ao.AbstractWorkflowAdvice; +import org.eclipse.emf.mwe.core.issues.Issues; +import org.eclipse.xtend.expression.AbstractExpressionsUsingWorkflowComponent.GlobalVarDef; +import org.eclipse.xtend.typesystem.MetaModel; + +/** + * Base class for workflow advices for components which use expressions. + * + * @author Karsten Thoms + * @since 4.3.1 + */ +public abstract class AbstractExpressionsUsingWorkflowAdvice extends AbstractWorkflowAdvice { + protected final List<MetaModel> metaModels = new ArrayList<MetaModel>(); + + private List<GlobalVarDef> globalVarDefs = new ArrayList<GlobalVarDef>(); + + /** + * Adds a metamodel. + * + * @param metaModel + * the metamodel. + */ + public void addMetaModel(final MetaModel metaModel) { + assert metaModel != null; + metaModels.add(metaModel); + } + + /** + * Adds a global variable definition. + * + * @param def + * the definition + */ + public void addGlobalVarDef(GlobalVarDef def) { + globalVarDefs.add(def); + } + + /** + * @see org.eclipse.emf.mwe.core.ao.AbstractWorkflowAdvice#weave(org.eclipse.emf.mwe.core.WorkflowComponent, + * org.eclipse.emf.mwe.core.issues.Issues) + */ + @Override + public void weave(WorkflowComponent c, Issues issues) { + if (!(c instanceof AbstractExpressionsUsingWorkflowComponent)) { + issues.addError(this, "advice target is not a expression based WorkflowComponent component."); + } + else { + AbstractExpressionsUsingWorkflowComponent wc = (AbstractExpressionsUsingWorkflowComponent) c; + for (MetaModel metamodel : metaModels) { + wc.addMetaModel(metamodel); + } + for (GlobalVarDef globalVar : globalVarDefs) { + wc.addGlobalVarDef(globalVar); + } + } + } +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java index dafbd095..a12fe48c 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AbstractExpressionsUsingWorkflowComponent.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; @@ -21,47 +19,46 @@ import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.WorkflowContext; import org.eclipse.emf.mwe.core.WorkflowInterruptedException; import org.eclipse.emf.mwe.core.issues.Issues; -import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent; +import org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; import org.eclipse.internal.xtend.expression.ast.SyntaxElement; import org.eclipse.internal.xtend.util.Pair; import org.eclipse.xtend.typesystem.MetaModel; -public abstract class AbstractExpressionsUsingWorkflowComponent extends - AbstractWorkflowComponent { +public abstract class AbstractExpressionsUsingWorkflowComponent extends AbstractWorkflowComponent2 { protected final Log log = LogFactory.getLog(getClass()); protected final List<MetaModel> metaModels = new ArrayList<MetaModel>(); protected final List<GlobalVarDef> globalVarDefs = new ArrayList<GlobalVarDef>(); - protected final List<String> _advice = new ArrayList<String>(); - - public void addAdvice (String advice) { - for (String singleAdvice: advice.split (",")) { - singleAdvice = singleAdvice.trim(); - if (singleAdvice.length() == 0) - continue; - - if (!_advice.contains (singleAdvice)) - _advice.add (singleAdvice); - } - } - - public void addAdvices (String advice) { - addAdvices (advice); - } - - public void addExtensionAdvice (String advice) { - addAdvice (advice); - } - - public void addExtensionAdvices (String advice) { - addExtensionAdvice (advice); - } - - - + protected final List<String> _advice = new ArrayList<String>(); + + public void addAdvice(String advice) { + for (String singleAdvice : advice.split(",")) { + singleAdvice = singleAdvice.trim(); + if (singleAdvice.length() == 0) { + continue; + } + + if (!_advice.contains(singleAdvice)) { + _advice.add(singleAdvice); + } + } + } + + public void addAdvices(String advice) { + addAdvices(advice); + } + + public void addExtensionAdvice(String advice) { + addAdvice(advice); + } + + public void addExtensionAdvices(String advice) { + addExtensionAdvice(advice); + } + public void addMetaModel(final MetaModel metaModel) { assert metaModel != null; metaModels.add(metaModel); @@ -98,8 +95,7 @@ public abstract class AbstractExpressionsUsingWorkflowComponent extends ExecutionContextImpl ec = new ExecutionContextImpl(); for (String slot : ctx.getSlotNames()) { - ec = (ExecutionContextImpl) ec.cloneWithVariable(new Variable(slot, - ctx.get(slot))); + ec = (ExecutionContextImpl) ec.cloneWithVariable(new Variable(slot, ctx.get(slot))); } for (MetaModel mm : metaModels) { ec.registerMetaModel(mm); @@ -114,11 +110,17 @@ public abstract class AbstractExpressionsUsingWorkflowComponent extends return result; } + protected Callback callback; + + public void setCallback(Callback callback) { + this.callback = callback; + } + protected ExecutionContextImpl getExecutionContext(final WorkflowContext ctx) { - final ExecutionContextImpl executionContext = new ExecutionContextImpl( - new ResourceManagerDefaultImpl(), null, new TypeSystemImpl(), - new HashMap<String, Variable>(), getGlobalVars(ctx), null, - null, null, getNullEvaluationHandler(),null); + + final ExecutionContextImpl executionContext = new ExecutionContextImpl(getResourceManager(), null, + new TypeSystemImpl(), new HashMap<String, Variable>(), getGlobalVars(ctx), null, exceptionHandler, + null, getNullEvaluationHandler(), null, callback); for (MetaModel mm : metaModels) { executionContext.registerMetaModel(mm); } @@ -131,10 +133,10 @@ public abstract class AbstractExpressionsUsingWorkflowComponent extends return null; } - public void checkConfiguration(Issues issues) { + @Override + protected void checkConfigurationInternal(Issues issues) { if (metaModels.isEmpty()) { - issues - .addWarning("no metamodels specified (use 'metaModel' property)!"); + issues.addWarning("no metamodels specified (use 'metaModel' property)!"); } } @@ -173,67 +175,66 @@ public abstract class AbstractExpressionsUsingWorkflowComponent extends } @Override - protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, - Issues issues) { + protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, final Issues issues) { try { + if (exceptionHandler == null) { + exceptionHandler = new ExceptionHandler() { + public void handleRuntimeException(RuntimeException ex, SyntaxElement element, + ExecutionContext ctx, Map<String, Object> additionalContextInfo) { + issues.addError(AbstractExpressionsUsingWorkflowComponent.this, ex.getMessage(), element); + throw ex; + } + }; + } invokeInternal2(ctx, monitor, issues); - } catch (EvaluationException e) { - log.error("Error in Component" + (getId()==null?" ":" "+getId()) + " of type " - + getClass().getName() + ": \n\t" + - "" +toString(e, debugExpressions)); - throw new WorkflowInterruptedException(); + } + catch (EvaluationException e) { + log.error("Error in Component" + (getId() == null ? " " : " " + getId()) + " of type " + + getClass().getName() + ": \n\t" + "" + toString(e, debugExpressions)); + throw new WorkflowInterruptedException(e.getMessage()); } } public String toString(EvaluationException ex, List<Debug> debugEntries) { - StringBuffer result = new StringBuffer("EvaluationException : " - + ex.getMessage() + "\n"); + StringBuffer result = new StringBuffer("EvaluationException : " + ex.getMessage() + "\n"); int widest = 0; for (Pair<SyntaxElement, ExecutionContext> ele : ex.getXtendStackTrace()) { - int temp = EvaluationException.getLocationString(ele.getFirst()) - .length(); - if (temp > widest) + int temp = EvaluationException.getLocationString(ele.getFirst()).length(); + if (temp > widest) { widest = temp; + } } String indent = ""; - for (int l = 0; l < widest + 7; l++) + for (int l = 0; l < widest + 7; l++) { indent += " "; + } for (int i = 0, x = ex.getXtendStackTrace().size(); i < x; i++) { - Pair<SyntaxElement, ExecutionContext> ele = ex.getXtendStackTrace() - .get(i); - StringBuffer msg = new StringBuffer(EvaluationException - .getLocationString(ele.getFirst())); + Pair<SyntaxElement, ExecutionContext> ele = ex.getXtendStackTrace().get(i); + StringBuffer msg = new StringBuffer(EvaluationException.getLocationString(ele.getFirst())); for (int j = msg.length(); j < widest; j++) { msg.append(" "); } - if (debugEntries.size() > i - && debugEntries.get(i).getExpression() != null) { + if (debugEntries.size() > i && debugEntries.get(i).getExpression() != null) { Debug d = debugEntries.get(i); try { - msg.append(" -- debug '").append(d.getExpression()).append( - "' = "); - msg.append(new ExpressionFacade(ele.getSecond()) - .evaluate("let x = " + d.getExpression() - + " : x!=null ? x.toString() : 'null'")); - } catch (Exception e) { + msg.append(" -- debug '").append(d.getExpression()).append("' = "); + msg.append(new ExpressionFacade(ele.getSecond()).evaluate("let x = " + d.getExpression() + + " : x!=null ? x.toString() : 'null'")); + } + catch (Exception e) { msg.append("Exception : ").append(e.getMessage()); } msg.append("\n"); } - if (dumpContext || debugEntries.size() > i - && debugEntries.get(i).isDumpContext()) { + if (dumpContext || debugEntries.size() > i && debugEntries.get(i).isDumpContext()) { ExpressionFacade f = new ExpressionFacade(ele.getSecond()); msg.append(" -- context dump : "); - Iterator<String> iter = ele.getSecond().getVisibleVariables() - .keySet().iterator(); + Iterator<String> iter = ele.getSecond().getVisibleVariables().keySet().iterator(); while (iter.hasNext()) { String v = iter.next(); - msg.append(v).append(" = ").append( - f - .evaluate(v + "!=null?" + v - + ".toString():'null'")); + msg.append(v).append(" = ").append(f.evaluate(v + "!=null?" + v + ".toString():'null'")); if (iter.hasNext()) { msg.append(", \n"); } @@ -254,14 +255,32 @@ public abstract class AbstractExpressionsUsingWorkflowComponent extends return result.toString(); } - protected void invokeInternal2(WorkflowContext ctx, - ProgressMonitor monitor, Issues issues) { + protected void invokeInternal2(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) { }; protected boolean exceptionsOnNullEvaluation = false; + protected ExceptionHandler exceptionHandler = null; + public void setExceptionsOnNullEvaluation(boolean exceptionsOnNullEvaluation) { this.exceptionsOnNullEvaluation = exceptionsOnNullEvaluation; } + public void setExceptionHandler(final ExceptionHandler exceptionHandler) { + this.exceptionHandler = exceptionHandler; + } + + private ResourceManager resourceManager; + + public ResourceManager getResourceManager() { + if (resourceManager == null) { + resourceManager = new ResourceManagerDefaultImpl(); + } + return resourceManager; + } + + public void setResourceManager(ResourceManager resourceManager) { + this.resourceManager = resourceManager; + } + } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java index 5b7b6b13..45ca195d 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/AnalysationIssue.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Analyzable.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Analyzable.java index 393297e0..0c62a86b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Analyzable.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Analyzable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java new file mode 100644 index 00000000..58fea7e1 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Callback.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ +package org.eclipse.xtend.expression; + +import org.eclipse.internal.xtend.expression.ast.SyntaxElement; + +/** + * an instance of this interface can be injected into the execution context. It + * is notified before and after analyzation/evaluation of each AST node. + * + * @author Sven Efftinge + */ +public interface Callback { + /** + * @param ele + * @param ctx + */ + void pre(SyntaxElement ele, ExecutionContext ctx); + + /** + * @param expressionResult + * the result of the evaluation (an instance of {@link Type} in + * analyzation phase) if syntax element was an instance of + * {@link Expression} + */ + void post(Object expressionResult); +} diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Evaluatable.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Evaluatable.java index c955d099..e1b4f3c6 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Evaluatable.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Evaluatable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/EvaluationException.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/EvaluationException.java index 3b28ed73..5022b0b0 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/EvaluationException.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/EvaluationException.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionHandler.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionHandler.java index d0b15724..0d810173 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionHandler.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionHandler.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionRaisingNullEvaluationHandler.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionRaisingNullEvaluationHandler.java index a5c8426b..b1f0fd2e 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionRaisingNullEvaluationHandler.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExceptionRaisingNullEvaluationHandler.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContext.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContext.java index 339fa24e..b3b9ff02 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContext.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContext.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; @@ -75,4 +73,6 @@ public interface ExecutionContext extends TypeSystem { void handleRuntimeException (RuntimeException ex, SyntaxElement element, Map<String,Object> additionalContextInfo); Object handleNullEvaluation(SyntaxElement element); + public Callback getCallback(); + } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContextImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContextImpl.java index 7df9e229..4aeedfe6 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContextImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExecutionContextImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; @@ -23,6 +21,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.eclipse.emf.mwe.core.monitor.ProgressMonitor; +import org.eclipse.internal.xtend.expression.ast.AbstractVisitor; import org.eclipse.internal.xtend.expression.ast.DeclaredParameter; import org.eclipse.internal.xtend.expression.ast.Identifier; import org.eclipse.internal.xtend.expression.ast.SyntaxElement; @@ -46,7 +45,7 @@ import org.eclipse.xtend.typesystem.Type; public class ExecutionContextImpl implements ExecutionContext { private final static Log log = LogFactory.getLog(ExecutionContextImpl.class); - protected final ResourceManager resourceManager; + protected ResourceManager resourceManager; private final Map<String, Variable> variables = new HashMap<String, Variable>(); @@ -67,7 +66,9 @@ public class ExecutionContextImpl implements ExecutionContext { protected ExceptionHandler exceptionHandler; - protected NullEvaluationHandler nullEvaluationHandler = null; + protected NullEvaluationHandler nullEvaluationHandler; + + protected Callback callback; public ExecutionContextImpl() { this((Map<String, Variable>) null); @@ -78,26 +79,29 @@ public class ExecutionContextImpl implements ExecutionContext { } public ExecutionContextImpl(Map<String, Variable> globalVars) { - this(new ResourceManagerDefaultImpl(), null, new TypeSystemImpl(), new HashMap<String, Variable>(), globalVars, null, - null, null, null, null); + this(new ResourceManagerDefaultImpl(), null, new TypeSystemImpl(), new HashMap<String, Variable>(), globalVars, + null, null, null, null, null, null); } public ExecutionContextImpl(TypeSystemImpl ts, Map<String, Variable> globalVars) { - this(new ResourceManagerDefaultImpl(), null, ts, new HashMap<String, Variable>(), globalVars, null, null, null, null, - null); + this(new ResourceManagerDefaultImpl(), null, ts, new HashMap<String, Variable>(), globalVars, null, null, null, + null, null, null); } - public ExecutionContextImpl(ResourceManager resourceManager, TypeSystemImpl typeSystem, Map<String, Variable> globalVars) { - this(resourceManager, null, typeSystem, new HashMap<String, Variable>(), globalVars, null, null, null, null, null); + public ExecutionContextImpl(ResourceManager resourceManager, TypeSystemImpl typeSystem, + Map<String, Variable> globalVars) { + this(resourceManager, null, typeSystem, new HashMap<String, Variable>(), globalVars, null, null, null, null, + null, null); } public ExecutionContextImpl(ResourceManager resourceManager, Resource resource, TypeSystemImpl typeSystem, Map<String, Variable> variables, Map<String, Variable> globalVars, ProgressMonitor monitor, ExceptionHandler exceptionHandler, List<Around> advices, NullEvaluationHandler neh2, - Map<Resource, Set<Extension>> extensionPerResourceMap) { + Map<Resource, Set<Extension>> extensionPerResourceMap, Callback callback) { if (extensionPerResourceMap != null) { this.allExtensionsPerResource = extensionPerResourceMap; - } else { + } + else { this.allExtensionsPerResource = new HashMap<Resource, Set<Extension>>(); } this.resourceManager = resourceManager; @@ -114,16 +118,17 @@ public class ExecutionContextImpl implements ExecutionContext { } this.nullEvaluationHandler = neh2; + this.callback = callback; + } + + public Callback getCallback() { + return callback; } public void registerMetaModel(final MetaModel mm) { typeSystem.registerMetaModel(mm); } - public List<MetaModel> getMetaModels () { - return typeSystem.getMetaModels(); - } - public Operation findOperation(final String name, final Object target, final Object[] params) { return typeSystem.findOperation(name, target, params); } @@ -214,7 +219,7 @@ public class ExecutionContextImpl implements ExecutionContext { public ExecutionContextImpl cloneContext() { return new ExecutionContextImpl(resourceManager, currentResource, typeSystem, variables, globalVars, monitor, - exceptionHandler, registeredExtensionAdvices, nullEvaluationHandler, allExtensionsPerResource); + exceptionHandler, registeredExtensionAdvices, nullEvaluationHandler, allExtensionsPerResource, callback); } public void setFileEncoding(final String encoding) { @@ -288,9 +293,8 @@ public class ExecutionContextImpl implements ExecutionContext { for (final String extension : extensions) { final Object o = resourceManager.loadResource(extension, XtendFile.FILE_EXTENSION); final XtendFile extFile = (XtendFile) o; - if (extFile == null) { + if (extFile == null) throw new RuntimeException("Unable to load extension file : " + extension); - } final ExecutionContext ctx = cloneWithResource(extFile); final List<Extension> extensionList = extFile.getPublicExtensions(resourceManager, ctx); for (final Extension element : extensionList) { @@ -325,23 +329,21 @@ public class ExecutionContextImpl implements ExecutionContext { } public void preTask(Object element) { - if (monitor == null) { + if (monitor == null) return; - } monitor.preTask(element, this); } public void postTask(Object element) { - if (monitor == null) { + if (monitor == null) return; - } monitor.postTask(element, this); } - public void handleRuntimeException(RuntimeException ex, SyntaxElement element, Map<String, Object> additionalContextInfo) { - if (this.exceptionHandler == null) { + public void handleRuntimeException(RuntimeException ex, SyntaxElement element, + Map<String, Object> additionalContextInfo) { + if (this.exceptionHandler == null) throw ex; - } exceptionHandler.handleRuntimeException(ex, element, this, additionalContextInfo); } @@ -353,14 +355,14 @@ public class ExecutionContextImpl implements ExecutionContext { public void registerExtensionAdvices(final String fullyQualifiedName) { final XtendFile ext = (XtendFile) resourceManager.loadResource(fullyQualifiedName, XtendFile.FILE_EXTENSION); - if (ext == null) { + if (ext == null) throw new IllegalArgumentException("Couldn't find extension file '" + fullyQualifiedName + "'"); - } final List<Around> as = ext.getArounds(); for (Around around : as) { if (registeredExtensionAdvices.contains(around)) { - log.warn("advice " + around.toString() + " already registered!"); - } else { + log.warn("advice " + around.toString() + " allready registered!"); + } + else { registeredExtensionAdvices.add(around); } } @@ -410,9 +412,11 @@ public class ExecutionContextImpl implements ExecutionContext { public Object evaluate(Object[] parameters, ExecutionContext ctx) { - ctx = ctx.cloneWithVariable(new Variable(Around.CONTEXT_PARAM_NAME, new AdviceContext(delegate, ctx, parameters))); + ctx = ctx.cloneWithVariable(new Variable(Around.CONTEXT_PARAM_NAME, new AdviceContext(delegate, ctx, + parameters))); for (int i = 0; i < advice.getParams().size(); i++) { - ctx = ctx.cloneWithVariable(new Variable(advice.getParams().get(i).getName().getValue(), parameters[i])); + ctx = ctx + .cloneWithVariable(new Variable(advice.getParams().get(i).getName().getValue(), parameters[i])); } ctx = ctx.cloneWithResource(advice.getParent()); return advice.getExpression().evaluate(ctx); @@ -503,12 +507,14 @@ public class ExecutionContextImpl implements ExecutionContext { return delegate.getQualifiedName(); } + public final Object accept(final AbstractVisitor visitor) { + return visitor.visit(this); + } } public Object handleNullEvaluation(SyntaxElement element) { - if (nullEvaluationHandler != null) { + if (nullEvaluationHandler != null) return nullEvaluationHandler.handleNullEvaluation(element, this); - } return null; } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java index 0c0431de..54a52089 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ExpressionFacade.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/NullEvaluationHandler.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/NullEvaluationHandler.java index 9d366b5f..a2ffe8ab 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/NullEvaluationHandler.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/NullEvaluationHandler.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java index 2509edf0..9a4daa28 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Resource.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManager.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManager.java index bd5a9462..5b10eb74 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManager.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManager.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java index a54a2666..d9e78624 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceManagerDefaultImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; @@ -40,9 +38,11 @@ public class ResourceManagerDefaultImpl implements ResourceManager { private final Map<String, Resource> resources = new HashMap<String, Resource>(); public ResourceManagerDefaultImpl() { + XtendResourceParser xtendResourceParser = new XtendResourceParser(); registeredParsers.put(XtendFile.FILE_EXTENSION, - new XtendResourceParser()); - registeredParsers.put(CheckUtils.FILE_EXTENSION, new XtendResourceParser()); + xtendResourceParser); + registeredParsers.put(CheckUtils.FILE_EXTENSION, + xtendResourceParser); } public Resource loadResource(final String fullyQualifiedName, diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceParser.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceParser.java index b57b59b3..5a163c89 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceParser.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/ResourceParser.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java index cc8eaece..da95731b 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeNameUtil.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; @@ -41,10 +39,13 @@ import org.eclipse.internal.xtend.expression.parser.SyntaxConstants; * @since 4.0 */ public class TypeNameUtil { + private static final String QUALIFIEDNAME_STRING = "(?:[^\\s.:()\\[\\]{}+\\-*/&|%$!\\\"\'=?]+::)*[^\\s.:()\\[\\]{}+\\-*/&|%$!\"'=?]+"; /** * This pattern is used to find the type name within possible query strings */ - private final static Pattern TYPE_PATTERN = Pattern.compile("\\A(?:(\\w+)\\[)?(?:(\\w+)!)?([\\w:]*\\w+)(?:\\])?\\z"); + final static Pattern TYPE_PATTERN = + Pattern.compile("\\A(?:(\\w+)\\[)?(?:(\\w+)!)?("+QUALIFIEDNAME_STRING+")(?:\\])?\\z"); + final static Pattern GENERICLIST_PATTERN = Pattern.compile("\\A\\[L("+QUALIFIEDNAME_STRING+");"); /** * Retrieves the collection type. @@ -55,7 +56,13 @@ public class TypeNameUtil { * otherwise <code>null</code> */ public static String getCollectionTypeName(final String name) { - return getGroup(name, 1); + String group = getGroup(name, TYPE_PATTERN, 1); + if (group == null) { + if (GENERICLIST_PATTERN.matcher(name).matches()) { + group = "List"; + } + } + return group; } /** @@ -66,15 +73,18 @@ public class TypeNameUtil { * @return The type's name */ public static String getTypeName(final String name) { - String group = getGroup(name, 3); + String group = getGroup(name, TYPE_PATTERN, 3); + if (group == null) { + group = getGroup(name, GENERICLIST_PATTERN, 1); + } if (group == null) { group = ""; } return group; } - private static String getGroup(final String input, final int group) { - final Matcher m = TYPE_PATTERN.matcher(input); + private static String getGroup(final String input, final Pattern pattern, final int group) { + final Matcher m = pattern.matcher(input); if (m.matches() && m.groupCount() >= group) { return m.group(group); @@ -168,4 +178,18 @@ public class TypeNameUtil { } return null; } + + /** + * Converts a Java qualified name (dot seperated) to oAW qualified name ('::' seperated) + * @param javaTypeName A java qualifier + * @return All dots are replaced by '::'. Returns <code>null</code> if <tt>javaTypeName</tt> is null. + * @since 4.3.1 + */ + public static String convertJavaTypeName (String javaTypeName) { + if (javaTypeName == null) { + return null; + } else { + return javaTypeName.replaceAll("\\.", SyntaxConstants.NS_DELIM); + } + } } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystem.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystem.java index 8c468dee..8bcd9147 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystem.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystem.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java index f366eeb7..9bb9f704 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/TypeSystemImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Variable.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Variable.java index 0b3de128..5abf2f86 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Variable.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/Variable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.expression; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/package.html new file mode 100644 index 00000000..bb03cc33 --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/expression/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of the expression framework +</body> +</html> diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java index 709bc3c3..27a43e34 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/AbstractTypeImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; @@ -82,6 +80,7 @@ public abstract class AbstractTypeImpl implements Type { } }; + @SuppressWarnings("unchecked") public Property getProperty(final String name) { return propertyCache.get(name); } diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Callable.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Callable.java index 83300c14..14b3005a 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Callable.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Callable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Feature.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Feature.java index 74297f16..836079de 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Feature.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Feature.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/MetaModel.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/MetaModel.java index 93a12aaa..414d358a 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/MetaModel.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/MetaModel.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; @@ -23,8 +21,19 @@ import org.eclipse.xtend.expression.TypeSystem; */ public interface MetaModel { + /** + * Returns the underlying typesystem. + * + * @return the typesystem + */ TypeSystem getTypeSystem(); + /** + * Sets the underlying typesystem. + * + * @param typeSystem + * the typesystem + */ void setTypeSystem(TypeSystem typeSystem); /** @@ -32,7 +41,8 @@ public interface MetaModel { * returns the corresponding type. Otherwise returns <code>null</code> * * @param typeName - * @return + * name of type + * @return the corresponding type */ Type getTypeForName(String typeName); @@ -42,14 +52,15 @@ public interface MetaModel { * <code>null</code> * * @param obj - * @return + * object for which a corresponding object is requested + * @return the corresponding type */ Type getType(Object obj); /** * returns all types this metamodel is responsible for * - * @return + * @return set of known types */ Set<? extends Type> getKnownTypes(); diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Operation.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Operation.java index d8237706..ca88ecb7 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Operation.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Operation.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedCallable.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedCallable.java index ceb60088..e87c9d19 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedCallable.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedCallable.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedType.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedType.java index 5d8d7335..0ff064a3 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedType.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/ParameterizedType.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Property.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Property.java index 755d1a63..2c82ffeb 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Property.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Property.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/StaticProperty.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/StaticProperty.java index 95427e17..e6ea4fe1 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/StaticProperty.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/StaticProperty.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Type.java b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Type.java index 3f179113..18d70ccc 100644 --- a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Type.java +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/Type.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xtend.typesystem; diff --git a/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/package.html b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/package.html new file mode 100644 index 00000000..9391c37c --- /dev/null +++ b/plugins/org.eclipse.xtend/src/org/eclipse/xtend/typesystem/package.html @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!-- $Id: package.html,v 1.1 2009/01/10 00:59:36 pschonbac Exp $ --> +<html> <head> +<title></title> +</head> + +<body> +Implementation of oAW typas and the oAW typesystem +</body> +</html> diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllPackageTests.java index cc3f7ed0..9f1062b5 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllTests.java index a0afd044..163fb248 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/AllTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests; import org.eclipse.xpand.internal.tests.analyze.AllPackageTests; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorAdviceTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorAdviceTest.java index f1911411..72dced85 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorAdviceTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorAdviceTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorTest.java index c3486bda..2e9bfbfb 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/GeneratorTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/AllPackageTests.java index b5c2b044..48e4a2b9 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.analyze; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/StatementAnalyzationTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/StatementAnalyzationTest.java index e0102cbe..48cac986 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/StatementAnalyzationTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/analyze/StatementAnalyzationTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.analyze; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/AllPackageTests.java index dd18ea88..ac2ebcd8 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.codeassist; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/FastAnalyzerTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/FastAnalyzerTest.java index 10574f81..297d1613 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/FastAnalyzerTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/FastAnalyzerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.codeassist; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/KeywordProposalComputerTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/KeywordProposalComputerTest.java index f2874a78..e59b8ef3 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/KeywordProposalComputerTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/KeywordProposalComputerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.codeassist; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/StatementProposalComputerTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/StatementProposalComputerTest.java index d435a6df..e8c89d35 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/StatementProposalComputerTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/codeassist/StatementProposalComputerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.codeassist; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AllPackageTests.java index 74179b0d..edfe8319 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.evaluate; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AopFeatureTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AopFeatureTest.java index 55d7de1c..9b5a8684 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AopFeatureTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/AopFeatureTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.evaluate; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/OutputStringImpl.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/OutputStringImpl.java index 5845369a..6788961d 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/OutputStringImpl.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/OutputStringImpl.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.evaluate; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/ProtectedRegionsTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/ProtectedRegionsTest.java index 60d25d5d..d839f7ec 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/ProtectedRegionsTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/ProtectedRegionsTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.evaluate; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/StatementEvaluatorTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/StatementEvaluatorTest.java index 6e03889b..2819ee74 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/StatementEvaluatorTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/evaluate/StatementEvaluatorTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.evaluate; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/AllPackageTests.java index 68a1c4dc..4c097249 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.impl; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/NameUtilTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/NameUtilTest.java index 6c0afdfa..04c9da82 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/NameUtilTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/impl/NameUtilTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.impl; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/AllPackageTests.java index ddba46a0..d02ef6f1 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.output; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/NoChangesVetoStrategyTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/NoChangesVetoStrategyTest.java index 69c100d7..014d586d 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/NoChangesVetoStrategyTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/NoChangesVetoStrategyTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.output; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/OutputImplTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/OutputImplTest.java index 1a12e671..2631c369 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/OutputImplTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/output/OutputImplTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.output; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/AllPackageTests.java index b785d15e..144db4d1 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.parser; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/StatementParserTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/StatementParserTest.java index e872feb8..3d4a0ce8 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/StatementParserTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/StatementParserTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.parser; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/XpandLexerTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/XpandLexerTest.java index 6dcedffb..b7c9c99a 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/XpandLexerTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/parser/XpandLexerTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.parser; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/AllPackageTests.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/AllPackageTests.java index 1718d861..aac7fa52 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/AllPackageTests.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/AllPackageTests.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.pr; import junit.framework.Test; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/ProtectedRegionResolverImplTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/ProtectedRegionResolverImplTest.java index 714b5095..2e69ee3d 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/ProtectedRegionResolverImplTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/ProtectedRegionResolverImplTest.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.pr; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/util/GenericFileFilterTest.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/util/GenericFileFilterTest.java index f46a923c..bb1bf5b9 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/util/GenericFileFilterTest.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/pr/util/GenericFileFilterTest.java @@ -1,3 +1,11 @@ +/******************************************************************************* + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + *******************************************************************************/ package org.eclipse.xpand.internal.tests.pr.util; import java.io.File; diff --git a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/util/InputStreamLogger.java b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/util/InputStreamLogger.java index 6c2d39e7..1c9ed03b 100644 --- a/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/util/InputStreamLogger.java +++ b/tests/org.eclipse.xpand.tests/src/org/eclipse/xpand/internal/tests/util/InputStreamLogger.java @@ -1,12 +1,10 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 committers of openArchitectureWare and others. + * Copyright (c) 2005-2009 itemis AG (http://www.itemis.eu) and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * committers of openArchitectureWare - initial API and implementation *******************************************************************************/ package org.eclipse.xpand.internal.tests.util; |