JBoss Tools SVN: r30990 - trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 20:44:10 -0400 (Fri, 29 Apr 2011)
New Revision: 30990
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.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/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-30 00:40:32 UTC (rev 30989)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java 2011-04-30 00:44:10 UTC (rev 30990)
@@ -25,6 +25,7 @@
import org.jboss.tools.cdi.internal.core.impl.definition.DefinitionContext;
import org.jboss.tools.cdi.internal.core.impl.definition.FieldDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
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;
@@ -125,6 +126,15 @@
SeamMethodDefinition m = def.getMethod(method);
if(m != null) {
mergeAnnotations(m, methodDef, context);
+ List<ParameterDefinition> psDefs = methodDef.getParameters();
+ List<SeamParameterDefinition> ps = m.getParameters();
+ if(ps.size() != psDefs.size()) {
+ System.out.println("different number of parameters in MethodDefinition and SeamMethodDefinition for method " + method.getDeclaringType().getElementName() + "." + method.getElementName());
+ } else {
+ for (int i = 0; i < ps.size(); i++) {
+ mergeAnnotations(ps.get(i), psDefs.get(i), context);
+ }
+ }
}
}
13 years, 7 months
JBoss Tools SVN: r30989 - in trunk/cdi/tests/org.jboss.tools.cdi.core.test: src/org/jboss/tools/cdi/core/test/tck and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 20:40:32 -0400 (Fri, 29 Apr 2011)
New Revision: 30989
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/injection/NamedParameters.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
Log:
JBIDE-8825
https://issues.jboss.org/browse/JBIDE-8825
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/injection/NamedParameters.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/injection/NamedParameters.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/injection/NamedParameters.java 2011-04-30 00:40:32 UTC (rev 30989)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.lookup.injection;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public class NamedParameters {
+ @Produces
+ @Named("uniqueName16728")
+ String abc;
+
+ @Inject
+ void setA(@Named("anotherName63916") String s) {
+ }
+
+ @Inject
+ void setABC(@Named("uniqueName16728") String s) {
+ }
+}
Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/lookup/injection/NamedParameters.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2011-04-30 00:39:38 UTC (rev 30988)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/InjectionPointTest.java 2011-04-30 00:40:32 UTC (rev 30989)
@@ -15,6 +15,7 @@
import org.eclipse.jdt.core.ITypeParameter;
import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
@@ -75,4 +76,17 @@
assertTrue(!ps.isEmpty());
}
+ public void testParameterInjectionsWithQualifierWithMemberValues() {
+ IInjectionPointParameter injectionPoint = getInjectionPointParameter("JavaSource/org/jboss/jsr299/tck/tests/lookup/injection/NamedParameters.java", "setA");
+ assertNotNull(injectionPoint);
+ Set<IBean> resolved = cdiProject.getBeans(false, injectionPoint);
+ assertTrue(resolved.isEmpty());
+
+ injectionPoint = getInjectionPointParameter("JavaSource/org/jboss/jsr299/tck/tests/lookup/injection/NamedParameters.java", "setABC");
+ assertNotNull(injectionPoint);
+ resolved = cdiProject.getBeans(false, injectionPoint);
+ assertFalse(resolved.isEmpty());
+
+ }
+
}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2011-04-30 00:39:38 UTC (rev 30988)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2011-04-30 00:40:32 UTC (rev 30989)
@@ -17,19 +17,17 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.core.ICDIAnnotation;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IDecorator;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IInjectionPointField;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IProducer;
import org.jboss.tools.cdi.core.IQualifier;
@@ -316,6 +314,28 @@
return null;
}
+ protected IInjectionPointParameter getInjectionPointParameter(String beanClassFilePath, String methodName) {
+ IFile file = tckProject.getFile(beanClassFilePath);
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ Iterator<IBean> it = beans.iterator();
+ while(it.hasNext()) {
+ IBean b = it.next();
+ if(b instanceof IProducer) it.remove();
+ }
+ assertEquals("Wrong number of the beans", 1, beans.size());
+ Set<IInjectionPoint> injections = beans.iterator().next().getInjectionPoints();
+ for (IInjectionPoint injectionPoint : injections) {
+ if(injectionPoint instanceof IInjectionPointParameter) {
+ IInjectionPointParameter param = (IInjectionPointParameter)injectionPoint;
+ if(methodName.equals(param.getBeanMethod().getMethod().getElementName())) {
+ return param;
+ }
+ }
+ }
+ fail("Can't find injection point parameter in method \"" + methodName + "\" in " + beanClassFilePath);
+ return null;
+ }
+
public static void assertContainsBeanClasses(Set<IBean> beans, String... beanClassNames) throws CoreException {
assertContainsBeanClasses(true, beans, beanClassNames);
}
13 years, 7 months
JBoss Tools SVN: r30988 - in trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi: internal/core/impl and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 20:39:38 -0400 (Fri, 29 Apr 2011)
New Revision: 30988
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
JBIDE-8825
https://issues.jboss.org/browse/JBIDE-8825
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParameter.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IParameter.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -10,8 +10,6 @@
******************************************************************************/
package org.jboss.tools.cdi.core;
-import java.util.Set;
-
import org.jboss.tools.common.text.ITextSourceReference;
/**
@@ -22,13 +20,6 @@
public interface IParameter extends IBeanMember {
/**
- * Returns all the annotations of this parameter.
- *
- * @return all the annotations of this parameter.
- */
- Set<IAnnotationDeclaration> getAnnotationDeclarations();
-
- /**
* Returns the declared type of this parameter.
*
* @return the declared type of this parameter.
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -314,7 +314,7 @@
}
}
- boolean isParameter = injectionPoint instanceof InjectionPointParameter;
+ boolean isParameter = false;// injectionPoint instanceof InjectionPointParameter;
boolean isNew = false;
Set<IQualifierDeclaration> qs = injectionPoint.getQualifierDeclarations();
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointParameter.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -43,9 +43,7 @@
* @see org.jboss.tools.cdi.core.IInjectionPoint#getQualifierDeclarations()
*/
public Set<IQualifierDeclaration> getQualifierDeclarations() {
- Set<IQualifierDeclaration> result = new HashSet<IQualifierDeclaration>();
- //cannot implement
- return result;
+ return super.getQualifierDeclarations();
}
/*
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/Parameter.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -1,11 +1,9 @@
package org.jboss.tools.cdi.internal.core.impl;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import org.eclipse.jdt.core.IMember;
-import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBeanMethod;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.IParametedType;
@@ -14,7 +12,7 @@
import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
import org.jboss.tools.common.text.ITextSourceReference;
-public class Parameter extends CDIElement implements IParameter {
+public class Parameter extends AbstractBeanElement implements IParameter {
ParameterDefinition definition;
BeanMethod beanMethod;
@@ -26,13 +24,10 @@
}
public void setDefinition(ParameterDefinition definition) {
+ super.setDefinition(definition);
this.definition = definition;
}
- public Set<IAnnotationDeclaration> getAnnotationDeclarations() {
- throw new RuntimeException("Not implemented because limitations of JDT model.");
- }
-
public String getName() {
return definition.getName();
}
@@ -66,22 +61,6 @@
return p == null ? 0 : p.getStartPosition();
}
- public IAnnotationDeclaration getAnnotation(String annotationTypeName) {
- throw new RuntimeException("Not implemented because limitations of JDT model.");
- }
-
- public List<IAnnotationDeclaration> getAnnotations() {
- throw new RuntimeException("Not implemented because limitations of JDT model.");
- }
-
- public boolean isAnnotationPresent(String annotationTypeName) {
- return definition.isAnnotationPresent(annotationTypeName);
- }
-
- public ITextSourceReference getAnnotationPosition(String annotationTypeName) {
- return definition.getAnnotationPosition(annotationTypeName);
- }
-
public Set<String> getAnnotationTypes() {
return definition.getAnnotationTypes();
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -17,6 +17,7 @@
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
@@ -28,6 +29,7 @@
import org.jboss.tools.cdi.core.IRootDefinitionContext;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationLiteral;
import org.jboss.tools.cdi.internal.core.impl.ClassBean;
import org.jboss.tools.cdi.internal.core.impl.ParametedType;
import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
@@ -64,15 +66,16 @@
super.init(contextType, context, flags);
isConstructor = method.isConstructor();
//TODO process parameters for disposers and observers
- loadParamDefinitions(contextType, context);
+ loadParamDefinitions(contextType, context, flags);
}
public boolean parametersAreInjectionPoints() {
return getProducesAnnotation() != null || getInjectAnnotation() != null;
}
- void loadParamDefinitions(IType contextType, IRootDefinitionContext context) throws CoreException {
+ void loadParamDefinitions(IType contextType, IRootDefinitionContext context, int flags) throws CoreException {
if(method == null) return;
+ boolean loadAll = (flags & FLAG_ALL_MEMBERS) > 0;
boolean parametersAreInjectionPoints = parametersAreInjectionPoints();
String[] parameterNames = method.getParameterNames();
if(parameterNames == null || parameterNames.length == 0) return;
@@ -92,7 +95,7 @@
if(!parametersAreInjectionPoints && paramsString.indexOf("@Observes") >= 0) {
parametersAreInjectionPoints = true;
}
- if(!parametersAreInjectionPoints && paramsString.indexOf('@') < 0) return;
+ if(!loadAll && !parametersAreInjectionPoints && paramsString.indexOf('@') < 0) return;
String[] params = getParams(paramsString);
String[] ps = method.getParameterTypes();
int start = paramStart + 1;
@@ -103,7 +106,7 @@
// The source code may be broken. Just ignore such errors.
break;
}
- if(!parametersAreInjectionPoints && params[i].indexOf('@') < 0) {
+ if(!loadAll && !parametersAreInjectionPoints && params[i].indexOf('@') < 0) {
start += params[i].length() + 1;
continue; //do not need parameters without annotation
}
@@ -129,14 +132,21 @@
String[] tokens = getParamTokens(p);
for (String q: tokens) {
if(!q.startsWith("@")) continue;
- v = new CheckingValueInfo(method);
- v.setValue(q);
- v.valueStartPosition = start + params[i].indexOf(q);
- v.valueLength = q.length();
+ int valueStartPosition = start + params[i].indexOf(q);
+ int valueLength = q.length();
int s = q.indexOf('(');
if(s >= 0) q = q.substring(0, s).trim();
String annotationType = EclipseJavaUtil.resolveType(contextType, q.substring(1).trim());
- if(annotationType != null) pd.annotationsByTypeName.put(annotationType, v);
+ IType t = context.getProject().getType(annotationType);
+ if(t != null) {
+ String source = content.substring(valueStartPosition, valueStartPosition + valueLength);
+ IMemberValuePair[] pairs = ParameterDefinition.getMemberValues(source);
+ AnnotationLiteral ja = new AnnotationLiteral(method.getResource(), valueStartPosition, valueLength, null, IMemberValuePair.K_UNKNOWN, t);
+ if(pairs != null && pairs.length > 0) for (IMemberValuePair pair: pairs) {
+ ja.addMemberValuePair(pair.getMemberName(), pair.getValue(), pair.getValueKind());
+ }
+ pd.addAnnotation(ja, context);
+ }
}
parameters.add(pd);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/ParameterDefinition.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -10,29 +10,15 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl.definition;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.jdt.core.IMemberValuePair;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.SourceRange;
import org.eclipse.jdt.internal.core.MemberValuePair;
-import org.jboss.tools.cdi.core.CDICoreNature;
-import org.jboss.tools.cdi.core.CDICorePlugin;
-import org.jboss.tools.cdi.core.IAnnotated;
-import org.jboss.tools.cdi.core.IAnnotationDeclaration;
-import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
-import org.jboss.tools.cdi.internal.core.impl.AnnotationLiteral;
import org.jboss.tools.cdi.internal.core.impl.ParametedType;
import org.jboss.tools.cdi.internal.core.impl.TypeDeclaration;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.text.ITextSourceReference;
-public class ParameterDefinition implements IAnnotated {
+public class ParameterDefinition extends AbstractMemberDefinition {
protected MethodDefinition methodDefinition;
protected String name;
@@ -41,7 +27,6 @@
protected int index;
protected ITextSourceReference position = null;
- Map<String, ITextSourceReference> annotationsByTypeName = new HashMap<String, ITextSourceReference>();
public ParameterDefinition() {}
@@ -65,44 +50,9 @@
return methodDefinition;
}
- /**
- * JDT doesn't have API for annotations for method params. So this method will return a wrapper for ITextSourceReference.
- * Use getAnnotationPosition() instead.
- *
- * @see org.jboss.tools.cdi.core.IAnnotated#getAnnotation(java.lang.String)
- */
- public IAnnotationDeclaration getAnnotation(String annotationTypeName) {
- ITextSourceReference reference = getAnnotationPosition(annotationTypeName);
- if(reference==null) {
- return null;
- }
- // JDT doesn't have API for annotations for method params. So let's wrap ITextSourceReference into IAnnotationDeclaration.
- AnnotationDeclaration ad = new AnnotationDeclaration();
- IType t = null;
- try {
- t = EclipseJavaUtil.findType(methodDefinition.getMethod().getJavaProject(), annotationTypeName);
- } catch (JavaModelException e) {
-
- }
- if(t == null) return null;
- int b = reference.getStartPosition();
- int e = reference.getLength() + b;
- if(b < 0 || e < b) return null;
- String source = methodDefinition.getTypeDefinition().getContent().substring(b, e);
-
- //compute member value parameters
- IMemberValuePair[] memberValues = getMemberValues(source);
-
- AnnotationLiteral a = new AnnotationLiteral(methodDefinition.getResource(), source, new SourceRange(b, e - b), memberValues, t);
- ad.setDeclaration(a);
- CDICoreNature nature = CDICorePlugin.getCDI(methodDefinition.getResource().getProject(), false);
- ad.setProject(nature);
- return ad;
- }
-
private static IMemberValuePair[] EMPTY_PAIRS = new IMemberValuePair[0];
- private IMemberValuePair[] getMemberValues(String source) {
+ static IMemberValuePair[] getMemberValues(String source) {
int p1 = source.indexOf('(');
int p2 = source.indexOf(')');
if(p1 >= 0 && p2 > p1) {
@@ -127,33 +77,8 @@
return EMPTY_PAIRS;
}
- /**
- * Returns an empty list because JDT doesn't have API for annotations for method params. Use getAnnotationTypes() instead.
- *
- * @see org.jboss.tools.cdi.core.IAnnotated#getAnnotations()
- */
- public List<IAnnotationDeclaration> getAnnotations() {
- return Collections.emptyList();
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.cdi.core.IAnnotated#isAnnotationPresent(java.lang.String)
- */
- public boolean isAnnotationPresent(String annotationTypeName) {
- return annotationsByTypeName.containsKey(annotationTypeName);
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.cdi.core.IAnnotated#getAnnotationPosition(java.lang.String)
- */
- public ITextSourceReference getAnnotationPosition(String annotationTypeName) {
- return annotationsByTypeName.get(annotationTypeName);
- }
-
public Set<String> getAnnotationTypes() {
- return annotationsByTypeName.keySet();
+ return annotationsByType.keySet();
}
public void setPosition(ITextSourceReference position) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-04-29 21:51:29 UTC (rev 30987)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-04-30 00:39:38 UTC (rev 30988)
@@ -21,6 +21,8 @@
import java.util.Set;
import java.util.StringTokenizer;
+import javax.management.ValueExp;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
@@ -1310,27 +1312,22 @@
* - injection point other than injected field declares a @Named annotation that does not specify the value member
*/
if(injection instanceof IInjectionPointParameter) {
- IInjectionPointParameter pinjection = (IInjectionPointParameter)injection;
- if(pinjection.isAnnotationPresent(CDIConstants.NAMED_QUALIFIER_TYPE_NAME)) {
- String value = ((Parameter)pinjection).getValue(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
- if(value == null || value.length() == 0) {
+// IInjectionPointParameter pinjection = (IInjectionPointParameter)injection;
+ IAnnotationDeclaration named = injection.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ if (named != null) {
+ Object value = named.getMemberValue(null);
+ boolean valueExists = value != null && value.toString().trim().length() > 0;
+ if (!valueExists) {
addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME,
CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME,
- pinjection.getAnnotationPosition(CDIConstants.NAMED_QUALIFIER_TYPE_NAME),
+ named,
injection.getResource());
}
}
} else if (injection instanceof IInjectionPointMethod) {
IAnnotationDeclaration named = injection.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if (named != null) {
- IMemberValuePair[] values = named.getMemberValuePairs();
- boolean valueExists = false;
- for (IMemberValuePair pair : values) {
- if ("value".equals(pair.getMemberName())) {
- valueExists = true;
- break;
- }
- }
+ boolean valueExists = named.getMemberValue(null) != null;
if (!valueExists) {
addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME, CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named, injection.getResource());
}
13 years, 7 months
JBoss Tools SVN: r30987 - in trunk/forge/plugins/org.jboss.tools.seam.forge: src/org/jboss/tools/seam/forge/console and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: koen.aers(a)jboss.com
Date: 2011-04-29 17:51:29 -0400 (Fri, 29 Apr 2011)
New Revision: 30987
Modified:
trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF
trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java
Log:
added support for 'field' command
Modified: trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF
===================================================================
--- trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF 2011-04-29 21:37:27 UTC (rev 30986)
+++ trunk/forge/plugins/org.jboss.tools.seam.forge/META-INF/MANIFEST.MF 2011-04-29 21:51:29 UTC (rev 30987)
@@ -13,7 +13,8 @@
org.eclipse.ui.ide,
org.eclipse.m2e.core;bundle-version="0.13.0",
org.eclipse.m2e.maven.runtime;bundle-version="0.13.0",
- org.eclipse.jdt.core
+ org.eclipse.jdt.core,
+ org.eclipse.ui.views
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.jboss.tools.seam.forge.ForgePlugin
Modified: trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java 2011-04-29 21:37:27 UTC (rev 30986)
+++ trunk/forge/plugins/org.jboss.tools.seam.forge/src/org/jboss/tools/seam/forge/console/CommandRecorder.java 2011-04-29 21:51:29 UTC (rev 30987)
@@ -6,7 +6,9 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.text.DocumentEvent;
@@ -19,6 +21,7 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.part.ISetSelectionTarget;
+import org.eclipse.ui.views.contentoutline.ContentOutline;
import org.jboss.tools.seam.forge.ForgePlugin;
import org.jboss.tools.seam.forge.importer.ProjectImporter;
@@ -80,6 +83,8 @@
return "persistence";
} else if ("entity".equals(candidateCommand)) {
return "entity";
+ } else if ("field".equals(candidateCommand)) {
+ return "field";
} else {
return null;
}
@@ -116,13 +121,6 @@
} else if ("persistence".equals(currentCommand)) {
int index = beforePrompt.lastIndexOf("***SUCCESS*** Installed [forge.spec.jpa] successfully.\nWrote ");
if (index == -1) return;
-// String projectName = currentPrompt.substring(1, currentPrompt.indexOf(']'));
-// IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-// try {
-// project.refreshLocal(IResource.DEPTH_INFINITE, null);
-// } catch (CoreException e) {
-// ForgePlugin.log(e);
-// }
try {
IFile file = project.getFile("/src/main/resources/META-INF/persistence.xml");
if (file == null) return;
@@ -142,15 +140,8 @@
} else if ("entity".equals(currentCommand)) {
int index = beforePrompt.lastIndexOf("Picked up type <JavaResource>: ");
if (index == -1) return;
-// String projectName = currentPrompt.substring(1, currentPrompt.indexOf(']'));
-// IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (index + 31 > beforePrompt.length() -1) return;
String entityName = beforePrompt.substring(index + 31, beforePrompt.length() - 1).replace('.', '/');
-// try {
-// project.refreshLocal(IResource.DEPTH_INFINITE, null);
-// } catch (CoreException e) {
-// ForgePlugin.log(e);
-// }
try {
IFile file = project.getFile("/src/main/java/" + entityName + ".java");
if (file == null) return;
@@ -175,6 +166,48 @@
} catch (PartInitException e) {
ForgePlugin.log(e);
}
+ } else if ("field".equals(currentCommand)) {
+ try {
+ int index = beforePrompt.lastIndexOf("Added field to ");
+ if (index == -1) return;
+ if (index + 15 > beforePrompt.length()) return;
+ String str = beforePrompt.substring(index + 15);
+ index = str.indexOf(':');
+ if (index == -1) return;
+ String entityName = str.substring(0, index);
+ str = str.substring(index);
+ index = str.lastIndexOf(';');
+ if (index == -1) return;
+ str = str.substring(0, index);
+ index = str.lastIndexOf(' ');
+ if (index == -1) return;
+ String fieldName = str.substring(index + 1);
+ IFile file = project.getFile("/src/main/java/" + entityName.replace('.', '/') + ".java");
+ if (file == null) return;
+ Object objectToSelect = file;
+ IJavaElement javaElement = JavaCore.create(file);
+ if (javaElement != null && javaElement.getElementType() == IJavaElement.COMPILATION_UNIT) {
+ try {
+ IType type = ((ICompilationUnit)javaElement).getTypes()[0];
+ IField field = type.getField(fieldName);
+ if (field != null) {
+ objectToSelect = field;
+ }
+ } catch (JavaModelException e) {
+ ForgePlugin.log(e);
+ }
+ }
+ IViewPart packageExplorer = workbenchPage.showView("org.eclipse.jdt.ui.PackageExplorer");
+ if (packageExplorer instanceof ISetSelectionTarget) {
+ ((ISetSelectionTarget)packageExplorer).selectReveal(new StructuredSelection(objectToSelect));
+ }
+// IViewPart outlineViewer = workbenchPage.showView("org.eclipse.ui.views.ContentOutline");
+// if (outlineViewer instanceof ContentOutline) {
+// ((ContentOutline)outlineViewer).getCurrentPage().get
+// }
+ } catch (PartInitException e) {
+ ForgePlugin.log(e);
+ }
} else {
}
13 years, 7 months
JBoss Tools SVN: r30986 - trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 17:37:27 -0400 (Fri, 29 Apr 2011)
New Revision: 30986
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.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/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 21:29:02 UTC (rev 30985)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java 2011-04-29 21:37:27 UTC (rev 30986)
@@ -126,8 +126,10 @@
if(m != null) {
mergeAnnotations(m, methodDef, context);
}
- }
+ }
+ typeDef.checkConstructor();
+
}
private void mergeAnnotations(SeamMemberDefinition def, AbstractMemberDefinition memberDef, ConfigDefinitionContext context) {
13 years, 7 months
JBoss Tools SVN: r30985 - trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 17:29:02 -0400 (Fri, 29 Apr 2011)
New Revision: 30985
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
Log:
JBIDE-3120
https://issues.jboss.org/browse/JBIDE-3120
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2011-04-29 21:03:17 UTC (rev 30984)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2011-04-29 21:29:02 UTC (rev 30985)
@@ -89,6 +89,14 @@
// }
}
+ public void checkConstructor() {
+ for (MethodDefinition m: methods) {
+ if(m.isConstructor() && m.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME) != null) {
+ hasBeanConstructor = true;
+ }
+ }
+ }
+
public void annotationKindChanged(String typeName, IRootDefinitionContext context) {
super.annotationKindChanged(typeName, context);
for (FieldDefinition f: fields) f.annotationKindChanged(typeName, context);
13 years, 7 months
JBoss Tools SVN: r30984 - trunk/build/aggregate/site.
by jbosstools-commits@lists.jboss.org
Author: nickboldt
Date: 2011-04-29 17:03:17 -0400 (Fri, 29 Apr 2011)
New Revision: 30984
Modified:
trunk/build/aggregate/site/site.xml
Log:
add org.savara.tools.feature; remove org.scribble.protocol.feature (JBIDE-8817)
Modified: trunk/build/aggregate/site/site.xml
===================================================================
--- trunk/build/aggregate/site/site.xml 2011-04-29 20:40:20 UTC (rev 30983)
+++ trunk/build/aggregate/site/site.xml 2011-04-29 21:03:17 UTC (rev 30984)
@@ -240,11 +240,15 @@
<feature url="features/org.pi4soa.core.feature_0.0.0.jar" id="org.pi4soa.core.feature" version="0.0.0">
<category name="SOATools" />
</feature>
+ <feature url="features/org.savara.tools.feature_0.0.0.jar" id="org.savara.tools.feature" version="0.0.0">
+ <category name="SOATools" />
+ </feature>
<feature url="features/org.jboss.savara.tools.feature_0.0.0.jar" id="org.jboss.savara.tools.feature" version="0.0.0">
<category name="SOATools" />
</feature>
- <feature url="features/org.scribble.protocol.feature_0.0.0.jar" id="org.scribble.protocol.feature" version="0.0.0">
- </feature>
+ <!-- scribble.protocol.feature no longer exists in Savara/Scribble 2.0 -->
+ <!-- <feature url="features/org.scribble.protocol.feature_0.0.0.jar" id="org.scribble.protocol.feature" version="0.0.0">
+ </feature> -->
<!-- aggregated from other sources -->
<feature url="features/org.drools.eclipse.feature_0.0.0.jar" id="org.drools.eclipse.feature" version="0.0.0">
13 years, 7 months
JBoss Tools SVN: r30983 - in trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot: test/assertion and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-04-29 16:40:20 -0400 (Fri, 29 Apr 2011)
New Revision: 30983
Modified:
trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/ext/widgets/BPELEditPartListener.java
trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/test/assertion/BPELValidator.java
Log:
fix for BPEL SWTBot Tests compilation errors
Modified: trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/ext/widgets/BPELEditPartListener.java
===================================================================
--- trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/ext/widgets/BPELEditPartListener.java 2011-04-29 20:38:15 UTC (rev 30982)
+++ trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/ext/widgets/BPELEditPartListener.java 2011-04-29 20:40:20 UTC (rev 30983)
@@ -5,7 +5,7 @@
import java.util.Properties;
import org.apache.log4j.Logger;
-import org.eclipse.bpel.model.impl.ExtensibleElementImpl;
+import org.eclipse.wst.wsdl.internal.impl.ExtensibleElementImpl;
import org.jboss.tools.bpel.ui.bot.test.assertion.BPELValidator;
import org.junit.Assert;
Modified: trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/test/assertion/BPELValidator.java
===================================================================
--- trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/test/assertion/BPELValidator.java 2011-04-29 20:38:15 UTC (rev 30982)
+++ trunk/bpel/tests/org.jboss.tools.bpel.ui.bot.test/src/org/jboss/tools/bpel/ui/bot/test/assertion/BPELValidator.java 2011-04-29 20:40:20 UTC (rev 30983)
@@ -12,7 +12,6 @@
import org.eclipse.bpel.model.impl.ElseImpl;
import org.eclipse.bpel.model.impl.EmptyImpl;
import org.eclipse.bpel.model.impl.ExitImpl;
-import org.eclipse.bpel.model.impl.ExtensibleElementImpl;
import org.eclipse.bpel.model.impl.FaultHandlerImpl;
import org.eclipse.bpel.model.impl.FlowImpl;
import org.eclipse.bpel.model.impl.ForEachImpl;
@@ -31,6 +30,7 @@
import org.eclipse.bpel.model.impl.ValidateImpl;
import org.eclipse.bpel.model.impl.WaitImpl;
import org.eclipse.bpel.model.impl.WhileImpl;
+import org.eclipse.wst.wsdl.internal.impl.ExtensibleElementImpl;
import org.junit.Assert;
13 years, 7 months
JBoss Tools SVN: r30982 - trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 16:38:15 -0400 (Fri, 29 Apr 2011)
New Revision: 30982
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java
Log:
JBIDE-3120
https://issues.jboss.org/browse/JBIDE-3120
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java 2011-04-29 20:37:57 UTC (rev 30981)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java 2011-04-29 20:38:15 UTC (rev 30982)
@@ -72,11 +72,11 @@
InterfaceDefinition i = new InterfaceDefinition(t);
if(i.isAnnotationPresent(CDISeamSolderConstants.MESSAGE_LOGGER_ANNOTATION_TYPE_NAME)) {
TypeDefinition d = new TypeDefinition();
- d.setType(t, workingCopy.getRootContext());
+ d.setType(t, workingCopy.getRootContext(), 0);
workingCopy.addMessageLogger(path, d);
} else if(i.isAnnotationPresent(CDISeamSolderConstants.MESSAGE_BUNDLE_ANNOTATION_TYPE_NAME)) {
TypeDefinition d = new TypeDefinition();
- d.setType(t, workingCopy.getRootContext());
+ d.setType(t, workingCopy.getRootContext(), 0);
workingCopy.addMessageBundle(path, d);
AnnotationDeclaration ad = d.getAnnotation(CDISeamSolderConstants.MESSAGE_BUNDLE_ANNOTATION_TYPE_NAME);
if(ad.getMemberValue("projectCode") != null && ad.getMemberValue("projectCode").toString().length() > 0) {
@@ -172,7 +172,7 @@
class InterfaceDefinition extends AbstractMemberDefinition {
InterfaceDefinition(IType type) {
- setAnnotatable(type, type, context.getRootContext());
+ setAnnotatable(type, type, context.getRootContext(), 0);
}
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java 2011-04-29 20:37:57 UTC (rev 30981)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java 2011-04-29 20:38:15 UTC (rev 30982)
@@ -82,7 +82,7 @@
for (IAnnotationDeclaration a: as) {
if(workingCopy.isServiceAnnotation(a.getType())) {
TypeDefinition d = new TypeDefinition();
- d.setType(t, workingCopy.getRootContext());
+ d.setType(t, workingCopy.getRootContext(), 0);
workingCopy.addService(path, d);
}
}
@@ -159,7 +159,7 @@
class InterfaceDefinition extends AbstractMemberDefinition {
InterfaceDefinition(IType type) {
- setAnnotatable(type, type, context.getRootContext());
+ setAnnotatable(type, type, context.getRootContext(), 0);
}
}
13 years, 7 months
JBoss Tools SVN: r30981 - in trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core: definition and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-04-29 16:37:57 -0400 (Fri, 29 Apr 2011)
New Revision: 30981
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/definition/SeamBeanDefinition.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/definition/SeamMemberDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/scanner/SeamDefinitionBuilder.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/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 20:37:39 UTC (rev 30980)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/ConfigDefinitionContext.java 2011-04-29 20:37:57 UTC (rev 30981)
@@ -10,8 +10,10 @@
******************************************************************************/
package org.jboss.tools.cdi.seam.config.core;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -20,6 +22,7 @@
import org.jboss.tools.cdi.core.extension.AbstractDefinitionContextExtension;
import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.DefinitionContext;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.cdi.seam.config.core.definition.SeamBeansDefinition;
/**
@@ -134,4 +137,15 @@
((DefinitionContext)root).addType(path, typeName, def);
}
+ public List<TypeDefinition> getTypeDefinitions() {
+ List<TypeDefinition> result = new ArrayList<TypeDefinition>();
+ for (SeamBeansDefinition def: beanXMLs.values()) {
+ result.addAll(def.getTypeDefinitions());
+ }
+ for (SeamBeansDefinition def: seambeanXMLs.values()) {
+ result.addAll(def.getTypeDefinitions());
+ }
+ return result;
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeanDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeanDefinition.java 2011-04-29 20:37:39 UTC (rev 30980)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeanDefinition.java 2011-04-29 20:37:57 UTC (rev 30981)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.seam.config.core.scanner.SAXElement;
@@ -68,4 +69,15 @@
return methods;
}
+ public SeamMethodDefinition getMethod(IMethod method) {
+ for (SeamMethodDefinition m: methods) {
+ IMethod c = m.getMethod();
+ if(c != null && c.getElementName().equals(method.getElementName())
+ && c.equals(method)) {
+ return m;
+ }
+ }
+ return null;
+ }
+
}
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 20:37:39 UTC (rev 30980)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamBeansDefinition.java 2011-04-29 20:37:57 UTC (rev 30981)
@@ -17,7 +17,14 @@
import java.util.Map;
import java.util.Set;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.cdi.core.IJavaAnnotation;
+import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.DefinitionContext;
+import org.jboss.tools.cdi.internal.core.impl.definition.FieldDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
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;
@@ -67,17 +74,26 @@
}
public void buildTypeDefinitions(ConfigDefinitionContext context) {
+ typeDefinitions.clear();
+
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
+ replacedAndModified.add(type);
+ ((DefinitionContext)context.getRootContext()).veto(type);
}
- //TODO Initialize typeDef taking into account replaces and modifies
- typeDef.setType(type, context.getRootContext());
- //TODO merge seam definitions into typeDef and add to typeDefinitions
+ //Initialize typeDef taking into account replaces and modifies
+ int flags = AbstractMemberDefinition.FLAG_ALL_MEMBERS;
+ if(replaces) flags |= AbstractMemberDefinition.FLAG_NO_ANNOTATIONS;
+ typeDef.setType(type, context.getRootContext(), flags);
+
+ System.out.println("--merge type def-->" + def.getType().getFullyQualifiedName());
+ mergeTypeDefinition(def, typeDef, context);
+
+ typeDefinitions.add(typeDef);
}
}
@@ -85,8 +101,43 @@
List<IType> ds = replacedAndModified;
replacedAndModified = new ArrayList<IType>();
for (IType type: ds) {
- //TODO unveto type in root context
+ ((DefinitionContext)context.getRootContext()).unveto(type);
}
}
+ private void mergeTypeDefinition(SeamBeanDefinition def, TypeDefinition typeDef, ConfigDefinitionContext context) {
+ mergeAnnotations(def, typeDef, context);
+
+ List<FieldDefinition> fieldDefs = typeDef.getFields();
+ for (FieldDefinition fieldDef:fieldDefs) {
+ if(fieldDef.getField() == null) continue;
+ String n = fieldDef.getField().getElementName();
+ SeamFieldDefinition f = def.getField(n);
+ if(f != null) {
+ mergeAnnotations(f, fieldDef, context);
+ }
+ }
+
+ List<MethodDefinition> methodDefs = typeDef.getMethods();
+ for (MethodDefinition methodDef: methodDefs) {
+ IMethod method = methodDef.getMethod();
+ if(method == null) continue;
+ SeamMethodDefinition m = def.getMethod(method);
+ if(m != null) {
+ mergeAnnotations(m, methodDef, context);
+ }
+ }
+
+ }
+
+ private void mergeAnnotations(SeamMemberDefinition def, AbstractMemberDefinition memberDef, ConfigDefinitionContext context) {
+ Map<String, IJavaAnnotation> annotations = def.getAnnotations();
+ for (String typeName: annotations.keySet()) {
+ IJavaAnnotation ja = annotations.get(typeName);
+ IAnnotationDeclaration current = memberDef.getAnnotation(typeName);
+ if(current != null) memberDef.removeAnnotation(current);
+ memberDef.addAnnotation(ja, context.getRootContext());
+ }
+ }
+
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamMemberDefinition.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamMemberDefinition.java 2011-04-29 20:37:39 UTC (rev 30980)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/definition/SeamMemberDefinition.java 2011-04-29 20:37:57 UTC (rev 30981)
@@ -51,6 +51,10 @@
annotations.put(a.getTypeName(), a);
}
+ public Map<String, IJavaAnnotation> getAnnotations() {
+ return annotations;
+ }
+
public IJavaAnnotation getAnnotation(String typeName) {
return annotations.get(typeName);
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/scanner/SeamDefinitionBuilder.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/scanner/SeamDefinitionBuilder.java 2011-04-29 20:37:39 UTC (rev 30980)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.config.core/src/org/jboss/tools/cdi/seam/config/core/scanner/SeamDefinitionBuilder.java 2011-04-29 20:37:57 UTC (rev 30981)
@@ -104,7 +104,7 @@
private void scanAnnotation(SAXElement element, IType type) {
context.getRootContext().getAnnotationKind(type); // kick it
AnnotationDefinition def = new AnnotationDefinition();
- def.setType(type, context.getRootContext());
+ def.setType(type, context.getRootContext(), 0);
List<SAXElement> es = element.getChildElements();
//children should be annotation declarations.
@@ -253,7 +253,7 @@
if(q != null) {
inline.addAnnotation(q);
def.addAnnotation(q);
- IJavaAnnotation inject = createInject();
+ IJavaAnnotation inject = createInject(element);
if(inject != null) def.addAnnotation(inject);
}
}
@@ -337,7 +337,7 @@
SeamParameterDefinition pd = scanParameter(element);
if(pd != null) def.addParameter(pd);
}
- IJavaAnnotation inject = createInject();
+ IJavaAnnotation inject = createInject(element);
def.addAnnotation(inject);
IMethod method = null;
try {
@@ -463,12 +463,12 @@
return new AnnotationLiteral(resource, 0, 0, "" + id, IMemberValuePair.K_STRING, type);
}
- IJavaAnnotation createInject() {
+ IJavaAnnotation createInject(SAXElement forElement) {
IType type = project.getType(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
if(type == null) {
return null;
}
- return new AnnotationLiteral(resource, 0, 0, null, 0, type);
+ return new AnnotationLiteral(resource, forElement.getLocation().getStartPosition(), forElement.getLocation().getLength(), null, 0, type);
}
}
13 years, 7 months