Author: scabanovich
Date: 2011-03-31 16:10:12 -0400 (Thu, 31 Mar 2011)
New Revision: 30193
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IVetoFeature.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IBeanNameFeature.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.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/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
Log:
JBIDE-3120
https://issues.jboss.org/browse/JBIDE-3120
Removed org.eclipse.jdt.core.IAnnotation from CDI interfaces.
IAnnotationDeclaration implementation should handle it or work without it when annotation
info is provided by non-java sources.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -1047,7 +1047,7 @@
*/
public static Set<String> getTargetAnnotationValues(IAnnotationDeclaration target)
throws JavaModelException {
Set<String> result = new HashSet<String>();
- IMemberValuePair[] ps = target.getDeclaration().getMemberValuePairs();
+ IMemberValuePair[] ps = target.getMemberValuePairs();
for (IMemberValuePair p: ps) {
if(!"value".equals(p.getMemberName())) continue;
Object o = p.getValue();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IAnnotationDeclaration.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,8 +10,8 @@
******************************************************************************/
package org.jboss.tools.cdi.core;
-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.jboss.tools.common.text.ITextSourceReference;
@@ -28,8 +28,10 @@
*
* @return the annotation declaration.
*/
- IAnnotation getDeclaration();
+// IAnnotation getDeclaration();
+ IMemberValuePair[] getMemberValuePairs();
+
/**
* Returns the member which is annotated by this declaration.
*
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IBeanNameFeature.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IBeanNameFeature.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IBeanNameFeature.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -13,6 +13,9 @@
import org.jboss.tools.cdi.core.IBean;
/**
+ * This feature corresponds to runtime feature
+ * javax.enterprise.inject.spi.ProcessAnnotatedType.setAnnotatedType()
+ *
* This feature is invoked by bean when it computes its name.
* The first non-null value is accepted.
*
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IVetoFeature.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IVetoFeature.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IVetoFeature.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core.extension.feature;
+
+/**
+ * This feature corresponds to runtime feature
+ * javax.enterprise.inject.spi.ProcessAnnotatedType.veto()
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public interface IVetoFeature {
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IVetoFeature.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -19,10 +20,8 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMemberValuePair;
-import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.Signature;
import org.jboss.tools.cdi.core.CDIConstants;
@@ -265,21 +264,21 @@
Set<ITypeDeclaration> result = new HashSet<ITypeDeclaration>();
AnnotationDeclaration typed = getDefinition().getTypedAnnotation();
if(typed != null) {
- IAnnotation a = typed.getDeclaration();
+ int s = typed.getStartPosition();
+ int l = typed.getLength();
try {
- ISourceRange r = a.getSourceRange();
String txt = null;
- if(r != null && a.getResource() instanceof IFile) {
+ if(s >= 0 && typed.getResource() instanceof IFile) {
AbstractTypeDefinition td = getDefinition().getTypeDefinition();
if(td != null) {
String content = td.getContent();
- if(content != null && content.length() > r.getOffset() + r.getLength())
{
- txt = content.substring(r.getOffset(), r.getOffset() + r.getLength());
+ if(content != null && content.length() > s + l) {
+ txt = content.substring(s, s + l);
}
}
}
- IMemberValuePair[] ps = a.getMemberValuePairs();
+ IMemberValuePair[] ps = typed.getMemberValuePairs();
if(ps == null || ps.length == 0) return result;
IMember member = (IMember)definition.getMember();
IType declaringType = member instanceof IType ? (IType)member :
member.getDeclaringType();
@@ -297,7 +296,7 @@
if(txt != null) {
int q = txt.indexOf(rawTypeName);
if(q >= 0) {
- offset = r.getOffset() + q;
+ offset = s + q;
length = rawTypeName.length();
}
}
@@ -323,7 +322,7 @@
if(txt != null) {
int q = txt.indexOf(rawTypeName);
if(q >= 0) {
- offset = r.getOffset() + q;
+ offset = s + q;
length = rawTypeName.length();
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationDeclaration.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,8 +10,10 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -65,10 +67,31 @@
}
}
- public IAnnotation getDeclaration() {
- return annotation;
+// public IAnnotation getDeclaration() {
+// return annotation;
+// }
+
+ public IResource getResource() {
+ if(annotation != null) {
+ return annotation.getResource();
+ }
+ //TODO
+ return null;
}
+ public IMemberValuePair[] getMemberValuePairs() {
+ if(annotation != null) {
+ try {
+ return annotation.getMemberValuePairs();
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+ //
+ return new IMemberValuePair[0];
+ }
+
+
public IMember getParentMember() {
return (IMember)annotation.getParent();
}
@@ -82,10 +105,28 @@
}
public int getLength() {
+ //while annotation is available, it can be updated, we should take actual value.
+ if(annotation != null) try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ return length = range.getLength();
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
return length;
}
public int getStartPosition() {
+ //while annotation is available, it can be updated, we should take actual value.
+ if(annotation != null) try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ return startPosition = range.getOffset();
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
return startPosition;
}
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-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -27,7 +28,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
@@ -516,7 +516,7 @@
result.append(type.getFullyQualifiedName());
if(ms != null && ms.length > 0) {
TreeMap<String, String> values = new TreeMap<String, String>();
- IMemberValuePair[] ps = d.getDeclaration().getMemberValuePairs();
+ IMemberValuePair[] ps = d.getMemberValuePairs();
if (ps != null) for (IMemberValuePair p: ps) {
String n = p.getMemberName();
Object o = p.getValue();
@@ -732,17 +732,12 @@
if(a instanceof AnnotationDeclaration) {
AnnotationDeclaration aa = (AnnotationDeclaration)a;
if(CDIConstants.NORMAL_SCOPE_ANNOTATION_TYPE_NAME.equals(aa.getTypeName())) {
- IAnnotation ann = a.getDeclaration();
- try {
- IMemberValuePair[] ps = ann.getMemberValuePairs();
- if(ps != null) for (IMemberValuePair p: ps) {
- if("passivating".equals(p.getMemberName())) {
- Object o = p.getValue();
- return o != null && "true".equalsIgnoreCase(o.toString());
- }
+ IMemberValuePair[] ps = a.getMemberValuePairs();
+ if(ps != null) for (IMemberValuePair p: ps) {
+ if("passivating".equals(p.getMemberName())) {
+ Object o = p.getValue();
+ return o != null && "true".equalsIgnoreCase(o.toString());
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
return false;
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -11,6 +11,7 @@
package org.jboss.tools.cdi.internal.core.impl;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -19,7 +20,6 @@
import java.util.Map;
import java.util.Set;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
@@ -331,27 +331,18 @@
name = name.substring(0, 1).toLowerCase() + name.substring(1);
}
- IAnnotation a = named.getDeclaration();
- try {
- IMemberValuePair[] vs = a.getMemberValuePairs();
- if(vs != null && vs.length > 0) {
- Object value = vs[0].getValue();
- if(value != null && value.toString().trim().length() > 0) {
- return value.toString().trim();
- }
+ IMemberValuePair[] vs = named.getMemberValuePairs();
+ if(vs != null && vs.length > 0) {
+ Object value = vs[0].getValue();
+ if(value != null && value.toString().trim().length() > 0) {
+ return value.toString().trim();
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
return name;
}
public ITextSourceReference getNameLocation() {
- AnnotationDeclaration named = getDefinition().getNamedAnnotation();
- if(named != null) {
- return ValueInfo.getValueInfo(named.getDeclaration(), null);
- }
- return null;
+ return getDefinition().getNamedAnnotation();
}
public ClassBean getSpecializedBean() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,15 +10,13 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDIConstants;
-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.IInjectionPoint;
@@ -30,7 +28,6 @@
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.core.extension.feature.IBeanNameFeature;
-import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
import org.jboss.tools.common.text.ITextSourceReference;
/**
@@ -106,29 +103,20 @@
if(named == null) return null;
String name = getField().getElementName();
- IAnnotation a = named.getDeclaration();
- try {
- IMemberValuePair[] vs = a.getMemberValuePairs();
- if(vs == null || vs.length == 0) {
- return name;
- } else {
- Object value = vs[0].getValue();
- if(value != null && value.toString().trim().length() > 0) {
- return value.toString().trim();
- }
+ IMemberValuePair[] vs = named.getMemberValuePairs();
+ if(vs == null || vs.length == 0) {
+ return name;
+ } else {
+ Object value = vs[0].getValue();
+ if(value != null && value.toString().trim().length() > 0) {
+ return value.toString().trim();
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
return name;
}
public ITextSourceReference getNameLocation() {
- AnnotationDeclaration named = findNamedAnnotation();
- if(named != null) {
- return ValueInfo.getValueInfo(named.getDeclaration(), null);
- }
- return null;
+ return findNamedAnnotation();
}
public IBean getSpecializedBean() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,15 +10,13 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDIConstants;
-import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IInjectionPoint;
import org.jboss.tools.cdi.core.IParametedType;
@@ -32,7 +30,6 @@
import org.jboss.tools.cdi.core.extension.feature.IBeanNameFeature;
import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.ParameterDefinition;
-import org.jboss.tools.common.model.project.ext.impl.ValueInfo;
import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.common.util.BeanUtil;
@@ -136,31 +133,22 @@
String name = getMethod().getElementName();
- IAnnotation a = named.getDeclaration();
- try {
- IMemberValuePair[] vs = a.getMemberValuePairs();
- if(vs == null || vs.length == 0) {
- if(BeanUtil.isGetter(getMethod())) {
- return BeanUtil.getPropertyName(name);
- }
- } else {
- Object value = vs[0].getValue();
- if(value != null && value.toString().trim().length() > 0) {
- return value.toString().trim();
- }
+ IMemberValuePair[] vs = named.getMemberValuePairs();
+ if(vs == null || vs.length == 0) {
+ if(BeanUtil.isGetter(getMethod())) {
+ return BeanUtil.getPropertyName(name);
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
+ } else {
+ Object value = vs[0].getValue();
+ if(value != null && value.toString().trim().length() > 0) {
+ return value.toString().trim();
+ }
}
return name;
}
public ITextSourceReference getNameLocation() {
- AnnotationDeclaration named = findNamedAnnotation();
- if(named != null) {
- return ValueInfo.getValueInfo(named.getDeclaration(), null);
- }
- return null;
+ return findNamedAnnotation();
}
public void setSpecializedBean(ProducerMethod other) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2011-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -190,7 +190,7 @@
if(retention == null) {
validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(type.getSourceType().getNameRange()), resource);
} else {
- IMemberValuePair[] ps = retention.getDeclaration().getMemberValuePairs();
+ IMemberValuePair[] ps = retention.getMemberValuePairs();
boolean ok = false;
for (IMemberValuePair p: ps) {
if(!"value".equals(p.getMemberName())) continue;
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-03-31
19:48:45 UTC (rev 30192)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-03-31
20:10:12 UTC (rev 30193)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.validation;
+
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
@@ -1322,21 +1323,17 @@
} else if (injection instanceof IInjectionPointMethod) {
IAnnotationDeclaration named =
injection.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if (named != null) {
- try {
- IMemberValuePair[] values = named.getDeclaration().getMemberValuePairs();
- boolean valueExists = false;
- for (IMemberValuePair pair : values) {
- if ("value".equals(pair.getMemberName())) {
- valueExists = true;
- break;
- }
+ IMemberValuePair[] values = named.getMemberValuePairs();
+ boolean valueExists = false;
+ for (IMemberValuePair pair : values) {
+ if ("value".equals(pair.getMemberName())) {
+ valueExists = true;
+ break;
}
- if (!valueExists) {
- addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME,
CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named, injection.getResource());
- }
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
+ if (!valueExists) {
+ addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME,
CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named, injection.getResource());
+ }
}
IInjectionPointMethod injectionMethod = (IInjectionPointMethod)injection;
@@ -1737,30 +1734,27 @@
IScope scope = bean.getScope();
if(scope!=null && scope.isNorlmalScope()) {
IAnnotationDeclaration normalScopeDeclaration =
scope.getAnnotationDeclaration(CDIConstants.NORMAL_SCOPE_ANNOTATION_TYPE_NAME);
- if(normalScopeDeclaration!=null) {
- IAnnotation annt = normalScopeDeclaration.getDeclaration();
- if(annt!=null) {
- boolean passivatingScope = false;
- IMemberValuePair[] pairs = annt.getMemberValuePairs();
- for (IMemberValuePair pair : pairs) {
- if("passivating".equals(pair.getMemberName()) &&
"true".equalsIgnoreCase("" + pair.getValue())) {
- passivatingScope = true;
+ if(normalScopeDeclaration != null) {
+ boolean passivatingScope = false;
+ IMemberValuePair[] pairs = normalScopeDeclaration.getMemberValuePairs();
+ for (IMemberValuePair pair : pairs) {
+ if("passivating".equals(pair.getMemberName()) &&
"true".equalsIgnoreCase("" + pair.getValue())) {
+ passivatingScope = true;
+ break;
+ }
+ }
+ if(passivatingScope) {
+ boolean passivatingCapable = false;
+ Set<IParametedType> supers = bean.getAllTypes();
+ for (IParametedType type : supers) {
+ if("java.io.Serializable".equals(type.getType().getFullyQualifiedName()))
{
+ passivatingCapable = true;
break;
}
}
- if(passivatingScope) {
- boolean passivatingCapable = false;
- Set<IParametedType> supers = bean.getAllTypes();
- for (IParametedType type : supers) {
- if("java.io.Serializable".equals(type.getType().getFullyQualifiedName()))
{
- passivatingCapable = true;
- break;
- }
- }
- if(!passivatingCapable) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
- addError(MessageFormat.format(CDIValidationMessages.NOT_PASSIVATION_CAPABLE_BEAN,
bean.getSimpleJavaName(), scope.getSourceType().getElementName()),
CDIPreferences.NOT_PASSIVATION_CAPABLE_BEAN, reference, bean.getResource(),
NOT_PASSIVATION_CAPABLE_BEAN_ID);
- }
+ if(!passivatingCapable) {
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
+ addError(MessageFormat.format(CDIValidationMessages.NOT_PASSIVATION_CAPABLE_BEAN,
bean.getSimpleJavaName(), scope.getSourceType().getElementName()),
CDIPreferences.NOT_PASSIVATION_CAPABLE_BEAN, reference, bean.getResource(),
NOT_PASSIVATION_CAPABLE_BEAN_ID);
}
}
}
@@ -1832,31 +1826,27 @@
boolean markedAsWrong = false;
IAnnotationDeclaration target =
binding.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
if(target!=null) {
- try {
- IMemberValuePair[] ps = target.getDeclaration().getMemberValuePairs();
- if (ps != null && ps.length==1) {
- IMemberValuePair pair = ps[0];
- Object value = pair.getValue();
- if(value != null && value instanceof Object[]) {
- Object[] values = (Object[]) value;
- if(values.length>1) {
- Set<IBeanMethod> methods = interceptor.getAllMethods();
- for (IBeanMethod method : methods) {
- if(method.isLifeCycleCallbackMethod()) {
- ITextSourceReference declaration =
CDIUtil.getAnnotationDeclaration(interceptor, binding);
- if(declaration==null) {
- declaration = interceptor.getInterceptorAnnotation();
- }
- addError(CDIValidationMessages.ILLEGAL_LIFECYCLE_CALLBACK_INTERCEPTOR_BINDING,
CDIPreferences.ILLEGAL_LIFECYCLE_CALLBACK_INTERCEPTOR_BINDING, declaration,
interceptor.getResource());
- markedAsWrong = true;
- break;
+ IMemberValuePair[] ps = target.getMemberValuePairs();
+ if (ps != null && ps.length==1) {
+ IMemberValuePair pair = ps[0];
+ Object value = pair.getValue();
+ if(value != null && value instanceof Object[]) {
+ Object[] values = (Object[]) value;
+ if(values.length>1) {
+ Set<IBeanMethod> methods = interceptor.getAllMethods();
+ for (IBeanMethod method : methods) {
+ if(method.isLifeCycleCallbackMethod()) {
+ ITextSourceReference declaration =
CDIUtil.getAnnotationDeclaration(interceptor, binding);
+ if(declaration==null) {
+ declaration = interceptor.getInterceptorAnnotation();
}
+ addError(CDIValidationMessages.ILLEGAL_LIFECYCLE_CALLBACK_INTERCEPTOR_BINDING,
CDIPreferences.ILLEGAL_LIFECYCLE_CALLBACK_INTERCEPTOR_BINDING, declaration,
interceptor.getResource());
+ markedAsWrong = true;
+ break;
}
}
}
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
}
if(markedAsWrong) {
@@ -2166,12 +2156,7 @@
// 1. non-empty name
IAnnotationDeclaration nameDeclaration = stereotype.getNameDeclaration();
if (nameDeclaration != null) {
- IMemberValuePair[] ps = null;
- try {
- ps = nameDeclaration.getDeclaration().getMemberValuePairs();
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
+ IMemberValuePair[] ps = nameDeclaration.getMemberValuePairs();
if (ps != null && ps.length > 0) {
Object name = ps[0].getValue();
if (name != null && name.toString().length() > 0) {