Author: scabanovich
Date: 2011-04-28 21:31:29 -0400 (Thu, 28 Apr 2011)
New Revision: 30959
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/ConfigDefinitionContext.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/util/Util.java
Log:
JBIDE-3120
https://issues.jboss.org/browse/JBIDE-3120
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java 2011-04-29
01:30:52 UTC (rev 30958)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/CDISeamConfigExtension.java 2011-04-29
01:31:29 UTC (rev 30959)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.seam.config.core;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -75,6 +77,7 @@
}
public void buildDefinitions() {
+ List<SeamBeansDefinition> newDefinitions = new
ArrayList<SeamBeansDefinition>();
Set<IPath> paths = fileSet.getAllPaths();
for (IPath p: paths) {
boolean isSeamBeans = false;
@@ -90,6 +93,7 @@
SeamDefinitionBuilder builder = new SeamDefinitionBuilder();
document.set(text);
SeamBeansDefinition def = builder.createDefinition(resource, document, project,
context.getWorkingCopy());
+ newDefinitions.add(def);
if(isSeamBeans) {
context.getWorkingCopy().addSeamBeanXML(p, def);
} else {
@@ -97,6 +101,11 @@
}
}
}
+
+ for (SeamBeansDefinition def: newDefinitions) {
+ //Or, should we just build through all context?
+ def.buildTypeDefinitions(context.getWorkingCopy());
+ }
//TODO
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/ConfigDefinitionContext.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/ConfigDefinitionContext.java 2011-04-29
01:30:52 UTC (rev 30958)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/ConfigDefinitionContext.java 2011-04-29
01:31:29 UTC (rev 30959)
@@ -81,10 +81,12 @@
public void clean(IPath path) {
synchronized (beanXMLs) {
- beanXMLs.remove(path);
+ SeamBeansDefinition def = beanXMLs.remove(path);
+ if(def != null) def.clean(this);
}
synchronized (seambeanXMLs) {
- seambeanXMLs.remove(path);
+ SeamBeansDefinition def = seambeanXMLs.remove(path);
+ if(def != null) def.clean(this);
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java 2011-04-29
01:30:52 UTC (rev 30958)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java 2011-04-29
01:31:29 UTC (rev 30959)
@@ -10,11 +10,16 @@
******************************************************************************/
package org.jboss.tools.cdi.seam.config.core.definition;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
+import org.jboss.tools.cdi.seam.config.core.ConfigDefinitionContext;
import org.jboss.tools.cdi.seam.config.core.scanner.SAXNode;
/**
@@ -27,6 +32,9 @@
Set<SeamBeanDefinition> beanDefinitions = new
HashSet<SeamBeanDefinition>();
Set<SeamVirtualFieldDefinition> virtualFieldDefinitions = new
HashSet<SeamVirtualFieldDefinition>();
+
+ List<TypeDefinition> typeDefinitions = new ArrayList<TypeDefinition>();
+ List<IType> replacedAndModified = new ArrayList<IType>();
public SeamBeansDefinition() {}
@@ -54,4 +62,31 @@
return virtualFieldDefinitions;
}
+ public List<TypeDefinition> getTypeDefinitions() {
+ return typeDefinitions;
+ }
+
+ public void buildTypeDefinitions(ConfigDefinitionContext context) {
+ for (SeamBeanDefinition def: beanDefinitions) {
+ IType type = def.getType();
+ TypeDefinition typeDef = new TypeDefinition();
+ boolean replaces = def.getReplacesLocation() != null;
+ boolean modifies = def.getModifiesLocation() != null;
+ if(replaces || modifies) {
+ //TODO veto type in root context
+ }
+ //TODO Initialize typeDef taking into account replaces and modifies
+ typeDef.setType(type, context.getRootContext());
+ //TODO merge seam definitions into typeDef and add to typeDefinitions
+ }
+ }
+
+ public void clean(ConfigDefinitionContext context) {
+ List<IType> ds = replacedAndModified;
+ replacedAndModified = new ArrayList<IType>();
+ for (IType type: ds) {
+ //TODO unveto type in root context
+ }
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/util/Util.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/util/Util.java 2011-04-29
01:30:52 UTC (rev 30958)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/util/Util.java 2011-04-29
01:31:29 UTC (rev 30959)
@@ -119,13 +119,13 @@
public static IMember resolveMember(IType type, SAXElement element) throws
JavaModelException {
String name = element.getLocalName();
IField f = type.getField(name);
- if(f != null && f.exists()) {
+ if(f != null && f.exists() && !hasParametersOrArrayChild(element)) {
return f;
}
IMethod[] ms = type.getMethods();
for (IMethod m: ms) {
if(name.equals(m.getElementName())) {
- //do more checks
+ //that is only a preliminary resolving. Exact method will be found on loading
parameters.
return m;
}
}
@@ -197,6 +197,14 @@
return false;
}
+ public static boolean hasParametersOrArrayChild(SAXElement element) {
+ List<SAXElement> cs = element.getChildElements();
+ for (SAXElement c: cs) {
+ if(isParameters(c) || isArray(c)) return true;
+ }
+ return false;
+ }
+
/**
*
* @param def