summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpschonbac2009-01-13 14:28:50 (EST)
committer pschonbac2009-01-13 14:28:50 (EST)
commita37e9df6156a1225e2753f6b5171212d0184b111 (patch)
tree41388ad4a1621d0b596a11d6e997a514216115b7
parent573736454bc917fa248323fc989aef35de773d79 (diff)
downloadorg.eclipse.xpand-a37e9df6156a1225e2753f6b5171212d0184b111.zip
org.eclipse.xpand-a37e9df6156a1225e2753f6b5171212d0184b111.tar.gz
org.eclipse.xpand-a37e9df6156a1225e2753f6b5171212d0184b111.tar.bz2
Compiler errors fixed
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java9
-rw-r--r--plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java74
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandExecutionContextImpl.java317
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandFacade.java1
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java422
-rw-r--r--plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java95
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/PluginExecutionContextImpl.java59
-rw-r--r--plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java39
8 files changed, 358 insertions, 658 deletions
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java
index d25e4f4..13abaff 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandEditorPlugin.java
@@ -88,9 +88,8 @@ public class XpandEditorPlugin extends AbstractUIPlugin {
public static Shell getActiveWorkbenchShell() {
final IWorkbenchWindow window = getActiveWorkbenchWindow();
- if (window != null) {
+ if (window != null)
return window.getShell();
- }
return null;
}
@@ -100,9 +99,8 @@ public class XpandEditorPlugin extends AbstractUIPlugin {
public static XpandExecutionContext getExecutionContext(final IJavaProject project) {
final IXtendXpandProject xp = Activator.getExtXptModelManager().findProject(project.getPath());
- if (xp == null) {
+ if (xp == null)
return null;
- }
final XpandExecutionContextImpl ctx = new XpandPluginExecutionContext(xp);
final List<? extends MetamodelContributor> contr = MetamodelContributorRegistry
@@ -122,7 +120,8 @@ public class XpandEditorPlugin extends AbstractUIPlugin {
"templates");
try {
templateStore.load();
- } catch (IOException e) {
+ }
+ catch (IOException e) {
e.printStackTrace();
}
}
diff --git a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java
index 6a38459..cf673fe 100644
--- a/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java
+++ b/plugins/org.eclipse.xpand.ui/src/org/eclipse/xpand/ui/XpandPluginExecutionContext.java
@@ -25,39 +25,43 @@ import org.eclipse.xtend.expression.Variable;
import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
public class XpandPluginExecutionContext extends org.eclipse.xpand2.XpandExecutionContextImpl {
- private final IXtendXpandProject project;
-
- public XpandPluginExecutionContext(final IXtendXpandProject xp) {
- this (new PluginResourceManager(xp), null, new TypeSystemImpl(), new HashMap<String, Variable>(), new HashMap<String, Variable>(), null, null, null, xp);
- }
-
- protected XpandPluginExecutionContext (ResourceManager resourceManager, Resource currentResource, TypeSystemImpl typeSystem, Map<String, Variable> vars,
- Map<String, Variable> globalVars, Output output, ProtectedRegionResolver prs, ProgressMonitor monitor, IXtendXpandProject xp) {
- super (resourceManager, currentResource, typeSystem, vars, globalVars, output, prs, monitor, null, null,null,null);
- this.project = xp;
- }
-
- @Override
- public XpandPluginExecutionContext cloneContext() {
- return new XpandPluginExecutionContext (resourceManager, currentResource(), typeSystem, getVisibleVariables(), getGlobalVariables(), output, protectedRegionResolver, getMonitor(), project);
- }
-
- public static class PluginResourceManager implements ResourceManager {
- private IXtendXpandProject project;
-
- public PluginResourceManager(final IXtendXpandProject project) {
- assert project!=null;
- this.project = project;
- }
-
- public Resource loadResource(final String fullyQualifiedName, final String extension) {
- return project.findExtXptResource(fullyQualifiedName,extension);
- }
-
- public void setFileEncoding(final String fileEncoding) {
- }
-
- public void registerParser(final String template_extension, final ResourceParser parser) {
- }
- };
+ private final IXtendXpandProject project;
+
+ public XpandPluginExecutionContext(final IXtendXpandProject xp) {
+ this(new PluginResourceManager(xp), null, new TypeSystemImpl(), new HashMap<String, Variable>(),
+ new HashMap<String, Variable>(), null, null, null, xp);
+ }
+
+ protected XpandPluginExecutionContext(ResourceManager resourceManager, Resource currentResource,
+ TypeSystemImpl typeSystem, Map<String, Variable> vars, Map<String, Variable> globalVars, Output output,
+ ProtectedRegionResolver prs, ProgressMonitor monitor, IXtendXpandProject xp) {
+ super(resourceManager, currentResource, typeSystem, vars, globalVars, output, prs, monitor, null, null, null,
+ null, null);
+ this.project = xp;
+ }
+
+ @Override
+ public XpandPluginExecutionContext cloneContext() {
+ return new XpandPluginExecutionContext(resourceManager, currentResource(), typeSystem, getVisibleVariables(),
+ getGlobalVariables(), output, protectedRegionResolver, getMonitor(), project);
+ }
+
+ public static class PluginResourceManager implements ResourceManager {
+ private IXtendXpandProject project;
+
+ public PluginResourceManager(final IXtendXpandProject project) {
+ assert project != null;
+ this.project = project;
+ }
+
+ public Resource loadResource(final String fullyQualifiedName, final String extension) {
+ return project.findExtXptResource(fullyQualifiedName, extension);
+ }
+
+ public void setFileEncoding(final String fileEncoding) {
+ }
+
+ public void registerParser(final String template_extension, final ResourceParser parser) {
+ }
+ };
}
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
deleted file mode 100644
index cc8dd2d..0000000
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandExecutionContextImpl.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 committers of openArchitectureWare and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this 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;
-
-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
index 7aa7020..78d36e2 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandFacade.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/internal/xpand2/XpandFacade.java
@@ -16,6 +16,7 @@ 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.xpand2.XpandExecutionContextImpl;
import org.eclipse.xtend.expression.AnalysationIssue;
import org.eclipse.xtend.expression.EvaluationException;
import org.eclipse.xtend.expression.ExecutionContext;
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 eff6f66..9e18841 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandExecutionContextImpl.java
@@ -8,7 +8,6 @@
* Contributors:
* committers of openArchitectureWare - initial API and implementation
*******************************************************************************/
-
package org.eclipse.xpand2;
import java.io.Reader;
@@ -23,6 +22,8 @@ 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.NoSuchTemplateException;
+import org.eclipse.internal.xpand2.XpandUtil;
import org.eclipse.internal.xpand2.model.AdvicedDefinition;
import org.eclipse.internal.xpand2.model.XpandAdvice;
import org.eclipse.internal.xpand2.model.XpandDefinition;
@@ -55,83 +56,71 @@ 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));
- registerParser(resourceManager);
- this.output = output;
- this.protectedRegionResolver = prs;
- this.exceptionHandler = exceptionHandler;
- this.nullEvaluationHandler = nullEvaluationHandler;
- }
+ 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++) {
+
+ 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);
@@ -141,170 +130,165 @@ 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() + " 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 {
+
+ 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 Type owner;
- private List<Type> paramTypes;
+ private List<Type> paramTypes;
- public XpandDefinition def;
+ 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 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 String getName() {
+ return name;
+ }
- public Type getReturnType() {
- throw new UnsupportedOperationException();
- }
+ public Type getReturnType() {
+ throw new UnsupportedOperationException();
+ }
- public Type getOwner() {
- return owner;
- }
+ public Type getOwner() {
+ return owner;
+ }
- public List<Type> getParameterTypes() {
- return paramTypes;
- }
+ public List<Type> getParameterTypes() {
+ return paramTypes;
+ }
- public Object evaluate(final Object target, final Object[] params) {
- throw new UnsupportedOperationException();
- }
+ public Object evaluate(final Object target, final Object[] params) {
+ throw new UnsupportedOperationException();
+ }
- public String getDocumentation() {
- return "Xpand definition " + getName() + " adapted in an Operation";
- }
+ public String getDocumentation() {
+ return "Xpand definition " + getName() + " adapted in an Operation";
+ }
- public Type getReturnType(final Type targetType, final Type[] paramTpes) {
- return getReturnType();
- }
+ 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!
- }
+ @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);
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 548edaf..a20607b 100644
--- a/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
+++ b/plugins/org.eclipse.xpand/src/org/eclipse/xpand2/XpandFacade.java
@@ -28,59 +28,60 @@ import org.eclipse.xtend.typesystem.Type;
* @author Sven Efftinge (http://www.efftinge.de) *
*/
public class XpandFacade {
- private XpandExecutionContext ctx = null;
+ private XpandExecutionContext ctx = null;
- /**
- * @deprecated use XpandFacade.create instead
- */
- public XpandFacade(final XpandExecutionContext ctx) {
- this.ctx = ctx;
- }
+ /**
+ * @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]);
- }
+ 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);
+ 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);
- }
+ 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();
- }
+ 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 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.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/PluginExecutionContextImpl.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/PluginExecutionContextImpl.java
index 1c59e06..283ed37 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/PluginExecutionContextImpl.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/PluginExecutionContextImpl.java
@@ -23,42 +23,43 @@ import org.eclipse.xtend.shared.ui.core.IXtendXpandProject;
import org.eclipse.xtend.shared.ui.core.PluginExecutionContext;
public class PluginExecutionContextImpl extends ExecutionContextImpl implements PluginExecutionContext {
- private final IXtendXpandProject project;
+ private final IXtendXpandProject project;
- public PluginExecutionContextImpl(final IXtendXpandProject xp, final TypeSystemImpl ts) {
- super(new PluginResourceManager (xp), ts, null);
- project = xp;
- }
+ public PluginExecutionContextImpl(final IXtendXpandProject xp, final TypeSystemImpl ts) {
+ super(new PluginResourceManager(xp), ts, null);
+ project = xp;
+ }
- protected PluginExecutionContextImpl (ResourceManager resourceManager, Resource currentResource, TypeSystemImpl typeSystem, Map<String, Variable> vars,
- Map<String, Variable> globalVars, IXtendXpandProject xp) {
- super (resourceManager, currentResource, typeSystem, vars, globalVars, null, null, null, null,null);
- project = xp;
- }
-
- @Override
- public PluginExecutionContextImpl cloneContext() {
- final PluginExecutionContextImpl result = new PluginExecutionContextImpl (resourceManager, currentResource(), typeSystem, getVisibleVariables(), getGlobalVariables(), project);
- return result;
- }
+ protected PluginExecutionContextImpl(ResourceManager resourceManager, Resource currentResource,
+ TypeSystemImpl typeSystem, Map<String, Variable> vars, Map<String, Variable> globalVars,
+ IXtendXpandProject xp) {
+ super(resourceManager, currentResource, typeSystem, vars, globalVars, null, null, null, null, null, null);
+ project = xp;
+ }
+ @Override
+ public PluginExecutionContextImpl cloneContext() {
+ final PluginExecutionContextImpl result = new PluginExecutionContextImpl(resourceManager, currentResource(),
+ typeSystem, getVisibleVariables(), getGlobalVariables(), project);
+ return result;
+ }
- public static class PluginResourceManager implements ResourceManager {
- private IXtendXpandProject project;
+ public static class PluginResourceManager implements ResourceManager {
+ private IXtendXpandProject project;
- public PluginResourceManager(final IXtendXpandProject project) {
- this.project = project;
- }
+ public PluginResourceManager(final IXtendXpandProject project) {
+ this.project = project;
+ }
- public Resource loadResource(final String fullyQualifiedName, final String extension) {
- return project.findExtXptResource(fullyQualifiedName,extension);
- }
+ public Resource loadResource(final String fullyQualifiedName, final String extension) {
+ return project.findExtXptResource(fullyQualifiedName, extension);
+ }
- public void setFileEncoding(final String fileEncoding) {
- }
+ public void setFileEncoding(final String fileEncoding) {
+ }
- public void registerParser(final String template_extension, final ResourceParser parser) {
- }
- }
+ public void registerParser(final String template_extension, final ResourceParser parser) {
+ }
+ }
}
diff --git a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java
index a83379f..60e4aba 100644
--- a/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java
+++ b/plugins/org.eclipse.xtend.shared.ui/src/org/eclipse/xtend/shared/ui/expression/editor/codeassist/ProposalFactoryEclipseImpl.java
@@ -11,8 +11,8 @@
package org.eclipse.xtend.shared.ui.expression.editor.codeassist;
import java.util.List;
+import java.util.Set;
-import org.eclipse.internal.xtend.expression.ast.DeclaredParameter;
import org.eclipse.internal.xtend.expression.codeassist.ProposalFactory;
import org.eclipse.internal.xtend.xtend.ast.Extension;
import org.eclipse.jface.text.contentassist.CompletionProposal;
@@ -54,7 +54,8 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
}
/**
- * @see ProposalFactory#createStaticPropertyProposal(StaticProperty, String, boolean)
+ * @see ProposalFactory#createStaticPropertyProposal(StaticProperty, String,
+ * boolean)
*/
public Object createStaticPropertyProposal(final StaticProperty p, final String prefix, final boolean onOperation) {
final String returnType = computeReturnType(p.getReturnType(), onOperation);
@@ -67,9 +68,8 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
}
private String computeReturnType(Type returnType, final boolean onOperation) {
- if (returnType == null) {
+ if (returnType == null)
return "unknown";
- }
if (onOperation) {
if (returnType instanceof ParameterizedType) {
returnType = ((ParameterizedType) returnType).getInnerType();
@@ -109,7 +109,7 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
public Object createExtensionOnMemberPositionProposal(final Extension p, final String prefix,
final boolean onOperation) {
final String displayStr = p.getName() + toParamString(p, true) + " - "
- + ((DeclaredParameter) p.getFormalParameters().get(0)).getType();
+ + (p.getFormalParameters().get(0)).getType();
final String insertStr = p.getName() + "()";
int x = insertStr.length();
if (p.getFormalParameters().size() > 1) {
@@ -136,7 +136,7 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
final StringBuffer b = new StringBuffer("(");
int i = member ? 1 : 0;
for (final int x = p.getFormalParameters().size(); i < x; i++) {
- b.append(((DeclaredParameter) p.getFormalParameters().get(i)).toString());
+ b.append((p.getFormalParameters().get(i)).toString());
if (i + 1 < x) {
b.append(",");
}
@@ -200,4 +200,31 @@ public class ProposalFactoryEclipseImpl implements ProposalFactory {
throw new UnsupportedOperationException();
}
+ public boolean isDuplicate(Set<String> nameCache, Object proposal) {
+ if (nameCache == null || proposal == null)
+ throw new IllegalArgumentException();
+
+ CompletionProposal 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) {
+ CompletionProposal p = castToProposal(proposal);
+ if (p != null) {
+ nameCache.add(p.getDisplayString());
+ }
+ }
+
+ private CompletionProposal castToProposal(Object obj) {
+ if (obj instanceof CompletionProposal)
+ return (CompletionProposal) obj;
+
+ return null;
+ }
}