Author: scabanovich
Date: 2007-07-10 11:41:19 -0400 (Tue, 10 Jul 2007)
New Revision: 2369
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
Log:
EXIN-217 annotated methods in java source merged correctly in incremental build
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -10,14 +10,25 @@
******************************************************************************/
package org.jboss.tools.seam.core;
+import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
+
/**
* Represents Type of Bijected Attribute.
* @author Alexey Kazakov
*/
-public enum BijectedAttributeType {
- IN,
- OUT,
- DATA_BINDER,
- DATA_MODEL_SELECTION,
- DATA_MODEL_SELECTION_INDEX
+public enum BijectedAttributeType implements SeamAnnotations {
+ IN(IN_ANNOTATION_TYPE),
+ OUT(OUT_ANNOTATION_TYPE),
+ DATA_BINDER(DATA_MODEL_ANNOTATION_TYPE),
+ DATA_MODEL_SELECTION(DATA_MODEL_SELECTION_ANNOTATION_TYPE),
+ DATA_MODEL_SELECTION_INDEX(DATA_MODEL_SELECTION_INDEX_ANNOTATION_TYPE);
+
+ BijectedAttributeType(String annotationType) {
+ this.annotationType = annotationType;
+ }
+
+ String annotationType;
+ public String getAnnotationType() {
+ return annotationType;
+ }
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamObject.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -21,6 +21,12 @@
public interface ISeamObject {
/**
+ * Returns seam project that contains this object.
+ * @return
+ */
+ public ISeamProject getSeamProject();
+
+ /**
* Returns parent object of seam model.
* @return
*/
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -37,6 +37,12 @@
}
return false;
}
+
+ public boolean isContextVariable() {
+ //TODO which else?
+ return isOfType(BijectedAttributeType.OUT)
+ || isOfType(BijectedAttributeType.DATA_BINDER);
+ }
public void setTypes(BijectedAttributeType[] types) {
this.types = types;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -1,7 +1,9 @@
package org.jboss.tools.seam.internal.core;
+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.IMember;
@@ -11,6 +13,7 @@
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponentMethod;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
@@ -184,19 +187,115 @@
}
Change children = new Change(this, null, null, null);
- //TODO do real merge and add changes to children
- this.bijectedAttributes = jd.bijectedAttributes;
- for (IBijectedAttribute a: bijectedAttributes) adopt(a);
- this.componentMethods = jd.componentMethods;
- for (ISeamComponentMethod m: componentMethods) adopt(m);
- this.roles = jd.roles;
- for (IRole role: roles) adopt(role);
+ mergeComponentMethods(jd, children);
+ mergeBijected(jd, children);
+ mergeRoles(jd, children);
changes = Change.addChange(changes, children);
return changes;
}
+
+ public void mergeBijected(SeamJavaComponentDeclaration jd, Change children) {
+
+ Map<Object, BijectedAttribute> bijectedMap = new HashMap<Object,
BijectedAttribute>();
+ for (IBijectedAttribute r: bijectedAttributes) bijectedMap.put(((SeamObject)r).getId(),
(BijectedAttribute)r);
+
+ for (IBijectedAttribute r: jd.bijectedAttributes) {
+ BijectedAttribute loaded = (BijectedAttribute)r;
+ BijectedAttribute current = (BijectedAttribute)bijectedMap.remove(loaded.getId());
+ if(current == null) {
+ adopt(loaded);
+ bijectedAttributes.add(loaded);
+ ISeamProject p = getSeamProject();
+ if(p != null && loaded.isContextVariable()) {
+ p.getVariables().add(loaded);
+ }
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ boolean wasOut = current.isContextVariable();
+ boolean isOut = loaded.isContextVariable();
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ if(wasOut != isOut) {
+ ISeamProject p = getSeamProject();
+ if(p != null) {
+ if(wasOut) p.getVariables().remove(current);
+ if(isOut) p.getVariables().add(current);
+ }
+ }
+ }
+ }
+
+ for (BijectedAttribute r: bijectedMap.values()) {
+ bijectedAttributes.remove(r);
+ ISeamProject p = getSeamProject();
+ if(p != null) p.getVariables().remove(r);
+ Change change = new Change(this, null, r, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+ }
+
+ public void mergeRoles(SeamJavaComponentDeclaration jd, Change children) {
+
+ Map<Object, Role> roleMap = new HashMap<Object, Role>();
+ for (IRole r: roles) roleMap.put(((SeamObject)r).getId(), (Role)r);
+
+ for (IRole r: jd.roles) {
+ Role loaded = (Role)r;
+ Role current = (Role)roleMap.remove(loaded.getId());
+ if(current == null) {
+ adopt(loaded);
+ roles.add(loaded);
+ ISeamProject p = getSeamProject();
+ if(p != null) p.getVariables().add(loaded);
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ }
+ }
+
+ for (Role r: roleMap.values()) {
+ roles.remove(r);
+ ISeamProject p = getSeamProject();
+ if(p != null) p.getVariables().remove(r);
+ Change change = new Change(this, null, r, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+
+ }
+
+ public void mergeComponentMethods(SeamJavaComponentDeclaration jd, Change children) {
+
+ Map<Object, SeamComponentMethod> methodsMap = new HashMap<Object,
SeamComponentMethod>();
+ for (ISeamComponentMethod r: componentMethods) methodsMap.put(((SeamObject)r).getId(),
(SeamComponentMethod)r);
+
+ for (ISeamComponentMethod r: jd.componentMethods) {
+ SeamComponentMethod loaded = (SeamComponentMethod)r;
+ SeamComponentMethod current = (SeamComponentMethod)methodsMap.remove(loaded.getId());
+ if(current == null) {
+ adopt(loaded);
+ componentMethods.add(loaded);
+ Change change = new Change(this, null, null, loaded);
+ children.addChildren(Change.addChange(null, change));
+ } else {
+ List<Change> rc = current.merge(loaded);
+ if(rc != null) children.addChildren(rc);
+ }
+ }
+
+ for (SeamComponentMethod r: methodsMap.values()) {
+ componentMethods.remove(r);
+ Change change = new Change(this, null, r, null);
+ children.addChildren(Change.addChange(null, change));
+ }
+
+ }
+
/**
* @see org.jboss.tools.seam.core.ISeamJavaComponentDeclaration#getPrecedence()
*/
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamObject.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -16,6 +16,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamObject;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.event.Change;
/**
@@ -44,6 +45,10 @@
public SeamObject() {}
+ public ISeamProject getSeamProject() {
+ return parent == null ? null : parent.getSeamProject();
+ }
+
public Object getId() {
return id;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -74,6 +74,10 @@
public IProject getProject() {
return project;
}
+
+ public ISeamProject getSeamProject() {
+ return this;
+ }
public void setProject(IProject project) {
this.project = project;
@@ -177,6 +181,7 @@
List<Change> addedComponents = null;
for (int i = 0; i < components.length; i++) {
SeamComponentDeclaration loaded = (SeamComponentDeclaration)components[i];
+ loaded.setParent(this);
SeamComponentDeclaration current =
(SeamComponentDeclaration)currentComponents.remove(loaded.getId());
loaded.setSourcePath(source);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -121,6 +121,7 @@
public boolean visit(FieldDeclaration node) {
currentAnnotatedField = new AnnotatedASTNode<FieldDeclaration>(node);
+ currentAnnotatedNode = currentAnnotatedField;
return true;
}
@@ -140,6 +141,7 @@
public boolean visit(MethodDeclaration node) {
currentAnnotatedMethod = new AnnotatedASTNode<MethodDeclaration>(node);
+ currentAnnotatedNode = currentAnnotatedMethod;
return true;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -11,7 +11,9 @@
package org.jboss.tools.seam.internal.core.scanner.java;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.core.IField;
@@ -51,6 +53,7 @@
public ComponentBuilder(LoadedDeclarations ds, ASTVisitorImpl visitor) {
+ this.ds = ds;
annotatedType = visitor.annotatedType;
annotatedFields = visitor.annotatedFields;
annotatedMethods = visitor.annotatedMethods;
@@ -127,21 +130,27 @@
void processBijections() {
for (AnnotatedASTNode<MethodDeclaration> n: annotatedMethods) {
- Annotation in = findAnnotation(n, IN_ANNOTATION_TYPE);
- Annotation out = findAnnotation(n, OUT_ANNOTATION_TYPE);
- if(in == null || out == null) continue;
+ Map<BijectedAttributeType, Annotation> as = new
HashMap<BijectedAttributeType, Annotation>();
+ List<BijectedAttributeType> types = new
ArrayList<BijectedAttributeType>();
+ Annotation main = null;
+ for (int i = 0; i < BijectedAttributeType.values().length; i++) {
+ Annotation a = findAnnotation(n,
BijectedAttributeType.values()[i].getAnnotationType());
+ if(a != null) {
+ as.put(BijectedAttributeType.values()[i], a);
+ if(main == null) main = a;
+ types.add(BijectedAttributeType.values()[i]);
+ }
+ }
+ if(as.size() == 0) continue;
+
MethodDeclaration m = n.getNode();
BijectedAttribute att = new BijectedAttribute();
component.addBijectedAttribute(att);
- BijectedAttributeType[] types = (in == null) ? new
BijectedAttributeType[]{BijectedAttributeType.OUT}
- : (out == null) ? new BijectedAttributeType[]{BijectedAttributeType.IN}
- : new BijectedAttributeType[]{BijectedAttributeType.IN, BijectedAttributeType.OUT};
- att.setTypes(types);
+ att.setTypes(types.toArray(new BijectedAttributeType[0]));
- Annotation a = in != null ? in : out;
- ValueInfo name = ValueInfo.getValueInfo(a, null);
+ ValueInfo name = ValueInfo.getValueInfo(main, null);
if(name == null) {
name = new ValueInfo();
name.value = m.getName().getIdentifier();
@@ -149,7 +158,7 @@
att.setName(name.getValue());
- ValueInfo scope = ValueInfo.getValueInfo(a, "scope");
+ ValueInfo scope = ValueInfo.getValueInfo(main, "scope");
if(scope != null) att.setScopeAsString(scope.getValue());
att.setSourceMember(findMethod(m));
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-10
14:49:00 UTC (rev 2368)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-10
15:41:19 UTC (rev 2369)
@@ -9,7 +9,10 @@
public static String IN_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "In";
public static String OUT_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX +
"Out";
-
+ public static String DATA_MODEL_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX +
"datamodel.DataModel";
+ public static String DATA_MODEL_SELECTION_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX
+ "datamodel.DataModelSelection";
+ public static String DATA_MODEL_SELECTION_INDEX_ANNOTATION_TYPE =
SEAM_ANNOTATION_TYPE_PREFIX + "datamodel.DataModelSelectionIndex";
+
public static String CREATE_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX +
"Create";
public static String DESTROY_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX +
"Destroy";