Author: scabanovich
Date: 2011-06-29 19:29:00 -0400 (Wed, 29 Jun 2011)
New Revision: 32484
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java
Modified:
trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
Log:
JBIDE-5046
https://issues.jboss.org/browse/JBIDE-5046
Modified: trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2011-06-29 23:26:30
UTC (rev 32483)
+++ trunk/common/plugins/org.jboss.tools.common/META-INF/MANIFEST.MF 2011-06-29 23:29:00
UTC (rev 32484)
@@ -7,6 +7,7 @@
Bundle-Localization: plugin
Export-Package: org.jboss.tools.common,
org.jboss.tools.common.java,
+ org.jboss.tools.common.java.impl,
org.jboss.tools.common.log,
org.jboss.tools.common.preferences,
org.jboss.tools.common.reporting,
Copied:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java
(from rev 32417,
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IJavaAnnotation.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java 2011-06-29
23:29:00 UTC (rev 32484)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.common.java;
+
+import org.eclipse.core.resources.IResource;
+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;
+
+/**
+ * Hides IAnnotation and allows to subtitute another implementation than wrapper for
IAnnotation.
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public interface IJavaAnnotation extends ITextSourceReference {
+
+ /**
+ * Returns resource that declares this annotation.
+ *
+ * @return resource that declares this annotation
+ */
+ public IResource getResource();
+
+ /**
+ * Returns fully qualified type name if resolved or element name otherwise.
+ *
+ * @return fully qualified type name if resolved or element name otherwise
+ */
+ public String getTypeName();
+
+ /**
+ * Returns annotation type or null if it cannot be resolved.
+ *
+ * @return annotation type or null if it cannot be resolved
+ */
+ public IType getType();
+ /**
+ * Returns Java element on which or for which this annotation was created.
+ *
+ * @return Java element on which or for which this annotation was created
+ */
+ public IMember getParentMember();
+
+ /**
+ * Returns member value pairs as IAnnotation does.
+ *
+ * @return member value pairs as IAnnotation does
+ */
+ public IMemberValuePair[] getMemberValuePairs();
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/IJavaAnnotation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java
(from rev 32417,
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AnnotationLiteral.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java 2011-06-29
23:29:00 UTC (rev 32484)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * 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.common.java.impl;
+
+import org.eclipse.core.resources.IResource;
+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.SourceRange;
+import org.eclipse.jdt.internal.core.MemberValuePair;
+import org.jboss.tools.common.java.IJavaAnnotation;
+
+public class AnnotationLiteral implements IJavaAnnotation {
+ IResource declaringResource;
+ IType annotationType;
+
+ String source;
+ ISourceRange range;
+ IMemberValuePair[] memberValues = new IMemberValuePair[0];
+
+ public AnnotationLiteral(IResource declaringResource, String source, ISourceRange range,
IMemberValuePair[] memberValues, IType annotationType) {
+ this.declaringResource = declaringResource;
+ this.source = source;
+ this.range = range;
+ this.memberValues = memberValues;
+ this.annotationType = annotationType;
+ }
+
+ public AnnotationLiteral(IResource declaringResource, int offset, int length, Object
value, int valueType, IType annotationType) {
+ this.declaringResource = declaringResource;
+ this.range = new SourceRange(offset, length);
+ if(value != null) {
+ this.memberValues = new IMemberValuePair[]{
+ createPair("value", value, valueType)
+ };
+ }
+ this.annotationType = annotationType;
+ }
+
+ public void addMemberValuePair(String name, Object value, int valueType) {
+ IMemberValuePair[] pairs = new IMemberValuePair[memberValues.length + 1];
+ System.arraycopy(memberValues, 0, pairs, 0, memberValues.length);
+ pairs[memberValues.length] = createPair(name, value, valueType);
+ memberValues = pairs;
+ }
+
+ private IMemberValuePair createPair(String name, Object value, int valueType) {
+ return new MemberValuePair(name, value, valueType);
+ }
+
+ public int getStartPosition() {
+ return range == null ? -1 : range.getOffset();
+ }
+
+ public int getLength() {
+ return range == null ? -1 : range.getLength();
+ }
+
+ public IResource getResource() {
+ return declaringResource;
+ }
+
+ public String getTypeName() {
+ if(annotationType != null) return annotationType.getFullyQualifiedName();
+ return null;
+ }
+
+ public IType getType() {
+ return annotationType;
+ }
+
+ public IMember getParentMember() {
+ //Do we need it?
+ return null;
+ }
+
+ public IMemberValuePair[] getMemberValuePairs() {
+ return memberValues;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/AnnotationLiteral.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Copied:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java
(from rev 32464,
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/JavaAnnotation.java)
===================================================================
---
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java 2011-06-29
23:29:00 UTC (rev 32484)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.common.java.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;
+import org.jboss.tools.common.CommonPlugin;
+import org.jboss.tools.common.java.IJavaAnnotation;
+import org.jboss.tools.common.util.EclipseJavaUtil;
+
+public class JavaAnnotation implements IJavaAnnotation {
+ IAnnotation annotation;
+
+ String annotationTypeName;
+ IType type;
+
+ public JavaAnnotation(IAnnotation annotation, IType declaringType) {
+ this.annotation = annotation;
+ try {
+ String name = annotation.getElementName();
+ annotationTypeName = EclipseJavaUtil.resolveType(declaringType, name);
+ type = EclipseJavaUtil.findType(annotation.getJavaProject(), annotationTypeName);
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ }
+
+ public IResource getResource() {
+ return annotation.getResource();
+ }
+
+ public String getTypeName() {
+ return annotationTypeName;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public int getLength() {
+ try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ return range.getLength();
+ }
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ return 0;
+ }
+
+ public int getStartPosition() {
+ try {
+ ISourceRange range = annotation.getSourceRange();
+ if(range != null) {
+ return range.getOffset();
+ }
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ return 0;
+ }
+
+ public IMember getParentMember() {
+ return (IMember)annotation.getParent();
+ }
+
+ public IMemberValuePair[] getMemberValuePairs() {
+ try {
+ return annotation.getMemberValuePairs();
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ return new IMemberValuePair[0];
+ }
+
+ public IAnnotation getAnnotation() {
+ return annotation;
+ }
+
+}
Property changes on:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/java/impl/JavaAnnotation.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain