Author: scabanovich
Date: 2009-12-09 12:38:11 -0500 (Wed, 09 Dec 2009)
New Revision: 19159
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/impl/ValueInfo.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4943
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/impl/ValueInfo.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/impl/ValueInfo.java 2009-12-09
16:42:20 UTC (rev 19158)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ext/impl/ValueInfo.java 2009-12-09
17:38:11 UTC (rev 19159)
@@ -14,6 +14,10 @@
import java.util.List;
import java.util.Properties;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.MemberValuePair;
@@ -21,6 +25,7 @@
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.core.dom.StringLiteral;
+import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.project.ext.IValueInfo;
import org.jboss.tools.common.model.project.ext.store.XMLStoreConstants;
import org.jboss.tools.common.xml.XMLUtilities;
@@ -68,6 +73,31 @@
}
return null;
}
+
+ public static ValueInfo getValueInfo(IAnnotation annotation, String name) {
+ if(name == null) name = "value"; //$NON-NLS-1$
+ ValueInfo result = new ValueInfo();
+ ISourceRange r = null;
+ IMemberValuePair[] ps = null;
+ try {
+ r = annotation.getSourceRange();
+ ps = annotation.getMemberValuePairs();
+ } catch (CoreException e) {
+ ModelPlugin.getDefault().logError(e);
+ }
+ if(r != null) {
+ result.valueStartPosition = r.getOffset();
+ result.valueLength = r.getLength();
+ }
+ if(ps != null) for (IMemberValuePair p: ps) {
+ if(name.equals(p.getMemberName())) {
+ Object v = p.getValue();
+ if(v != null) result.value = v.toString();
+ break;
+ }
+ }
+ return result;
+ }
public ValueInfo() {
}