Author: scabanovich
Date: 2011-05-02 15:03:27 -0400 (Mon, 02 May 2011)
New Revision: 31001
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/internal/core/impl/TypeDeclaration.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/XMLNodeReference.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-8832
https://issues.jboss.org/browse/JBIDE-8832
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-05-02
18:49:41 UTC (rev 31000)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2011-05-02
19:03:27 UTC (rev 31001)
@@ -869,7 +869,7 @@
* @param range
* @return
*/
- public static ITextSourceReference convertToSourceReference(final ISourceRange range) {
+ public static ITextSourceReference convertToSourceReference(final ISourceRange range,
final IResource resource) {
return new ITextSourceReference() {
public int getStartPosition() {
@@ -879,6 +879,10 @@
public int getLength() {
return range.getLength();
}
+
+ public IResource getResource() {
+ return resource;
+ }
};
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2011-05-02
18:49:41 UTC (rev 31000)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/TypeDeclaration.java 2011-05-02
19:03:27 UTC (rev 31001)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl;
+import org.eclipse.core.resources.IResource;
import org.jboss.tools.cdi.core.ITypeDeclaration;
/**
@@ -49,4 +50,8 @@
public int getStartPosition() {
return startPosition;
}
+
+ public IResource getResource() {
+ return type.getResource();
+ }
}
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-05-02
18:49:41 UTC (rev 31000)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2011-05-02
19:03:27 UTC (rev 31001)
@@ -16,6 +16,7 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IMethod;
@@ -127,6 +128,7 @@
v.setValue(params[i]);
v.valueStartPosition = start + pi;
v.valueLength = p.length();
+ v.setResource((IFile)resource);
pd.setPosition(v);
String[] tokens = getParamTokens(p);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/XMLNodeReference.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/XMLNodeReference.java 2011-05-02
18:49:41 UTC (rev 31000)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/XMLNodeReference.java 2011-05-02
19:03:27 UTC (rev 31001)
@@ -10,6 +10,8 @@
******************************************************************************/
package org.jboss.tools.cdi.internal.core.impl.definition;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.PositionHolder;
import org.jboss.tools.common.text.INodeReference;
@@ -58,4 +60,8 @@
return object;
}
+ public IFile getResource() {
+ return (IFile)object.getAdapter(IFile.class);
+ }
+
}
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-05-02
18:49:41 UTC (rev 31000)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/AnnotationValidationDelegate.java 2011-05-02
19:03:27 UTC (rev 31001)
@@ -187,7 +187,7 @@
void validateRetentionAnnotation(ICDIAnnotation type, String message, IResource
resource) throws JavaModelException {
IAnnotationDeclaration retention =
type.getAnnotationDeclaration(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
if(retention == null) {
- validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(type.getSourceType().getNameRange()), resource);
+ validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(type.getSourceType().getNameRange(), resource),
resource);
} else {
boolean ok = false;
Object o = retention.getMemberValue(null);
@@ -220,7 +220,7 @@
private void validateTargetAnnotation(ICDIAnnotation annotationType, String[][]
variants, String message, IResource resource) throws JavaModelException {
IAnnotationDeclaration target =
annotationType.getAnnotationDeclaration(CDIConstants.TARGET_ANNOTATION_TYPE_NAME);
if(target==null) {
- validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(annotationType.getSourceType().getNameRange()),
resource);
+ validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIUtil.convertToSourceReference(annotationType.getSourceType().getNameRange(), resource),
resource);
} else if(!CDIUtil.checkTargetAnnotation(target, variants)) {
validator.addError(message,
CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, target,
resource);
}
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-05-02
18:49:41 UTC (rev 31000)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-05-02
19:03:27 UTC (rev 31001)
@@ -626,14 +626,14 @@
try {
if(hasConflictedInterceptorBindings(bean)) {
//TODO consider putting markers to interceptor bindings/stereotype declarations.
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange(), bean.getResource());
addError(CDIValidationMessages.CONFLICTING_INTERCEPTOR_BINDINGS,
CDIPreferences.CONFLICTING_INTERCEPTOR_BINDINGS, reference, bean.getResource());
}
Set<IBeanMethod> methods = bean.getAllMethods();
for (IBeanMethod method : methods) {
if(hasConflictedInterceptorBindings(method)) {
//TODO consider putting markers to interceptor bindings/stereotype declarations.
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(method.getMethod().getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(method.getMethod().getNameRange(), bean.getResource());
addError(CDIValidationMessages.CONFLICTING_INTERCEPTOR_BINDINGS,
CDIPreferences.CONFLICTING_INTERCEPTOR_BINDINGS, reference, bean.getResource());
}
}
@@ -1625,7 +1625,7 @@
IField[] fields = type.getFields();
for (IField field : fields) {
if (Flags.isPublic(field.getFlags()) && !Flags.isStatic(field.getFlags()))
{
- ITextSourceReference fieldReference =
CDIUtil.convertToSourceReference(field.getNameRange());
+ ITextSourceReference fieldReference =
CDIUtil.convertToSourceReference(field.getNameRange(), bean.getResource());
addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD,
CDIPreferences.ILLEGAL_SCOPE_FOR_MANAGED_BEAN,
fieldReference, bean.getResource(),
ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD_ID);
}
@@ -1693,14 +1693,14 @@
Set<IInterceptorBinding> bindings = bean.getInterceptorBindings();
if(!bindings.isEmpty()) {
if(Flags.isFinal(bean.getBeanClass().getFlags())) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange(), bean.getResource());
addError(CDIValidationMessages.ILLEGAL_INTERCEPTOR_BINDING_CLASS,
CDIPreferences.ILLEGAL_INTERCEPTOR_BINDING_METHOD, reference, bean.getResource());
} else {
IMethod[] methods = bean.getBeanClass().getMethods();
for (int i = 0; i < methods.length; i++) {
int flags = methods[i].getFlags();
if(Flags.isFinal(flags) && !Flags.isStatic(flags) &&
!Flags.isPrivate(flags)) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(methods[i].getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(methods[i].getNameRange(), bean.getResource());
addError(CDIValidationMessages.ILLEGAL_INTERCEPTOR_BINDING_METHOD,
CDIPreferences.ILLEGAL_INTERCEPTOR_BINDING_METHOD, reference, bean.getResource());
}
}
@@ -1710,13 +1710,13 @@
for (IBeanMethod method : beanMethods) {
if(!method.getInterceptorBindings().isEmpty()) {
if(Flags.isFinal(bean.getBeanClass().getFlags())) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange(), bean.getResource());
addError(CDIValidationMessages.ILLEGAL_INTERCEPTOR_BINDING_CLASS,
CDIPreferences.ILLEGAL_INTERCEPTOR_BINDING_METHOD, reference, bean.getResource());
} else {
IMethod sourceMethod = method.getMethod();
int flags = sourceMethod.getFlags();
if(Flags.isFinal(flags) && !Flags.isStatic(flags) &&
!Flags.isPrivate(flags)) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(sourceMethod.getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(sourceMethod.getNameRange(), bean.getResource());
addError(CDIValidationMessages.ILLEGAL_INTERCEPTOR_BINDING_METHOD,
CDIPreferences.ILLEGAL_INTERCEPTOR_BINDING_METHOD, reference, bean.getResource());
}
}
@@ -1743,7 +1743,7 @@
}
}
if(!passivatingCapable) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange(), bean.getResource());
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);
}
}
@@ -2242,7 +2242,7 @@
int kind = Signature.getTypeSignatureKind(returnTypeSignature);
if(kind == Signature.ARRAY_TYPE_SIGNATURE) {
if(!annotation.getNonBindingMethods().contains(method)) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(method.getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(method.getNameRange(), annotation.getResource());
addError(arrayMessageErrorKey, preferencesKey, reference,
annotation.getResource());
}
} else if(kind == Signature.CLASS_TYPE_SIGNATURE) {
@@ -2257,7 +2257,7 @@
IType memberType = type.getJavaProject().findType(typeName);
if(memberType!=null && memberType.isAnnotation()) {
if(!annotation.getNonBindingMethods().contains(method)) {
- ITextSourceReference reference =
CDIUtil.convertToSourceReference(method.getNameRange());
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(method.getNameRange(), annotation.getResource());
addError(annotationValueErrorKey, preferencesKey, reference,
annotation.getResource());
}
}