JBoss Tools SVN: r27799 - in trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model: helpers/bean and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-29 09:09:18 -0500 (Wed, 29 Dec 2010)
New Revision: 27799
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/AddManagedBeanPropertiesContext.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/BeanHelper.java
Log:
JBIDE-8011
https://issues.jboss.org/browse/JBIDE-8011
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/AddManagedBeanPropertiesContext.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/AddManagedBeanPropertiesContext.java 2010-12-29 13:22:48 UTC (rev 27798)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/bean/AddManagedBeanPropertiesContext.java 2010-12-29 14:09:18 UTC (rev 27799)
@@ -137,12 +137,12 @@
private String getMessage(boolean getter, boolean setter, String name){
if(!getter && !setter) {
- return NLS.bind(JSFUIMessages.ADD_GETTER_SETTER_FOR_PROPERTY, names);
+ return NLS.bind(JSFUIMessages.ADD_GETTER_SETTER_FOR_PROPERTY, name);
}
if (!getter && setter){
- return NLS.bind(JSFUIMessages.ADD_GETTER_FOR_PROPERTY, names);
+ return NLS.bind(JSFUIMessages.ADD_GETTER_FOR_PROPERTY, name);
}
- return NLS.bind(JSFUIMessages.ADD_SETTER_FOR_PROPERTY, names);
+ return NLS.bind(JSFUIMessages.ADD_SETTER_FOR_PROPERTY, name);
}
class PropertyData {
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/BeanHelper.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/BeanHelper.java 2010-12-29 13:22:48 UTC (rev 27798)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/BeanHelper.java 2010-12-29 14:09:18 UTC (rev 27799)
@@ -17,8 +17,8 @@
import org.eclipse.jdt.core.*;
import org.jboss.tools.common.model.XModelObject;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.BeanUtil;
public class BeanHelper {
@@ -31,20 +31,15 @@
}
IMethod[] ms = type.getMethods();
for (int i = 0; i < ms.length; i++) {
- String n = ms[i].getElementName();
- if(!n.startsWith("get") || n.length() < 4) continue; //$NON-NLS-1$
- n = toPropertyName(n.substring(3));
- if(!map.containsKey(n)) map.put(n, ms[i]);
+ if(!BeanUtil.isGetter(ms[i])) continue;
+ String n = BeanUtil.getPropertyName(ms[i].getElementName());
+ if(n != null && !map.containsKey(n)) map.put(n, ms[i]);
}
Map<String,IJavaElement> smap = getSuperTypeJavaProperties(type);
if(smap != null) map.putAll(smap);
return map;
}
- private static String toPropertyName(String rootName) {
- return (rootName.toUpperCase().equals(rootName)) ? rootName : rootName.substring(0, 1).toLowerCase() + rootName.substring(1);
- }
-
static Map<String,IJavaElement> getSuperTypeJavaProperties(IType type) throws JavaModelException {
String scn = type.getSuperclassName();
if(scn == null || scn.length() == 0 || scn.equals("java.lang.Object")) return null; //$NON-NLS-1$
@@ -72,16 +67,9 @@
public static IMethod findGetter(IType type, String property) throws JavaModelException {
IMethod[] ms = type.getMethods();
for (int i = 0; i < ms.length; i++) {
- String n = ms[i].getElementName();
- if(n.startsWith("get") && n.length() > 3) { //$NON-NLS-1$
- String gn = toPropertyName(n.substring(3));
- if(gn.equals(property)) return ms[i];
- }
- String t = EclipseJavaUtil.resolveTypeAsString(type, ms[i].getReturnType());
- if(n.startsWith("is") && n.length() > 2 && t != null && (t.equals("boolean") || t.equals("java.lang.Boolean"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- String gn = toPropertyName(n.substring(2));
- if(gn.equals(property)) return ms[i];
- }
+ if(!BeanUtil.isGetter(ms[i])) continue;
+ String n = BeanUtil.getPropertyName(ms[i].getElementName());
+ if(n != null && n.equals(property)) return ms[i];
}
return null;
}
@@ -89,10 +77,9 @@
public static IMethod findSetter(IType type, String property) throws JavaModelException {
IMethod[] ms = type.getMethods();
for (int i = 0; i < ms.length; i++) {
- String n = ms[i].getElementName();
- if(!n.startsWith("set") || n.length() < 4) continue; //$NON-NLS-1$
- n = toPropertyName(n.substring(3));
- if(n.equals(property)) return ms[i];
+ if(!BeanUtil.isSetter(ms[i])) continue;
+ String n = BeanUtil.getPropertyName(ms[i].getElementName());
+ if(n != null && n.equals(property)) return ms[i];
}
return null;
}
14 years
JBoss Tools SVN: r27798 - in trunk: tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/resource and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-12-29 08:22:48 -0500 (Wed, 29 Dec 2010)
New Revision: 27798
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java
trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/resource/ResourceFactory.java
Log:
https://issues.jboss.org/browse/JBIDE-8015
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java 2010-12-29 12:59:07 UTC (rev 27797)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java 2010-12-29 13:22:48 UTC (rev 27798)
@@ -32,8 +32,6 @@
private static final ELResolverFactoryManager INSTANCE = new ELResolverFactoryManager();
-// private Map<String, ELResolver[]> resolvers = new HashMap<String, ELResolver[]>();
-
private ELResolverFactoryManager() {
}
@@ -51,17 +49,13 @@
* @return
*/
public ELResolver[] getResolvers(IResource resource) {
- if(resource==null || !resource.isAccessible()) {
+ if(!resource.isAccessible()) {
return new ELResolver[0];
}
IProject project = resource.getProject();
if (project == null || !project.isAccessible())
return new ELResolver[0];
-// ELResolver[] result = resolvers.get(project.getName());
-// if(result!=null) {
-// return result;
-// }
Set<ELResolver> resolverSet = new HashSet<ELResolver>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint extensionPoint = registry.getExtensionPoint("org.jboss.tools.common.el.core.elResolver"); //$NON-NLS-1$
@@ -104,9 +98,6 @@
}
}
}
-// result = resolverSet.toArray(new ELResolver[resolverSet.size()]);
-// resolvers.put(project.getName(), result);
-// return result;
return resolverSet.toArray(new ELResolver[resolverSet.size()]);
}
}
\ No newline at end of file
Modified: trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/resource/ResourceFactory.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/resource/ResourceFactory.java 2010-12-29 12:59:07 UTC (rev 27797)
+++ trunk/tests/plugins/org.jboss.tools.tests/src/org/jboss/tools/test/resource/ResourceFactory.java 2010-12-29 13:22:48 UTC (rev 27798)
@@ -55,10 +55,10 @@
result = Boolean.TRUE;
} else if(method.equals(IFile.class.getMethod("getFullPath"))){
result = fullPath;
- }
+ } else if(method.equals(IFile.class.getMethod("isAccessible"))){
+ return true;
+ }
return result;
}
-
-
}
-}
+}
\ No newline at end of file
14 years
JBoss Tools SVN: r27797 - trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-12-29 07:59:07 -0500 (Wed, 29 Dec 2010)
New Revision: 27797
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java
Log:
https://issues.jboss.org/browse/JBIDE-8015
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java 2010-12-29 12:38:46 UTC (rev 27796)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELResolverFactoryManager.java 2010-12-29 12:59:07 UTC (rev 27797)
@@ -51,7 +51,7 @@
* @return
*/
public ELResolver[] getResolvers(IResource resource) {
- if(!resource.isAccessible()) {
+ if(resource==null || !resource.isAccessible()) {
return new ELResolver[0];
}
IProject project = resource.getProject();
14 years
JBoss Tools SVN: r27796 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-29 07:38:46 -0500 (Wed, 29 Dec 2010)
New Revision: 27796
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
Log:
removed JAXB when unmarshalling instances
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2010-12-29 12:38:27 UTC (rev 27795)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2010-12-29 12:38:46 UTC (rev 27796)
@@ -280,8 +280,7 @@
public Instance createInstance(String imageId)
throws DeltaCloudClientException {
try {
- return buildInstance(requestStringResponse(new CreateInstanceRequest(
- baseUrl, imageId)));
+ return buildInstance(requestStringResponse(new CreateInstanceRequest(baseUrl, imageId)));
} catch (DeltaCloudClientException e) {
throw e;
} catch (Exception e) {
@@ -415,13 +414,13 @@
return key;
}
- private Instance updateInstance(String xml, Instance instance)
- throws Exception {
+ private Instance updateInstance(String xml, Instance instance) throws Exception {
Document document = getDocument(xml);
+ instance.setName(getElementTextValues(document, "name").get(0));
+ instance.setOwnerId(getElementTextValues(document, "owner_id").get(0));
instance.setImageId(getIdFromHref(getAttributeValues(document, "image", "href").get(0))); //$NON-NLS-1$ //$NON-NLS-2$
instance.setProfileId(getIdFromHref(getAttributeValues(document, "hardware_profile", "href").get(0))); //$NON-NLS-1$ //$NON-NLS-2$
- getProfileProperties(instance,
- getPropertyNodes(document, "hardware_profile")); //$NON-NLS-1$
+ updateProfileProperties(instance, getPropertyNodes(document, "hardware_profile")); //$NON-NLS-1$
instance.setRealmId(getIdFromHref(getAttributeValues(document, "realm", "href").get(0))); //$NON-NLS-1$ //$NON-NLS-2$
instance.setState(getElementTextValues(document, "state").get(0)); //$NON-NLS-1$
updateKeyname(document, instance);
@@ -433,9 +432,37 @@
return instance;
}
+ private void updateProfileProperties(Instance instance,
+ List<Node> propertyNodes) {
+ if (propertyNodes != null) {
+ for (Iterator<Node> i = propertyNodes.iterator(); i.hasNext();) {
+ Node n = i.next();
+ NamedNodeMap attrs = n.getAttributes();
+ String name = attrs.getNamedItem("name").getNodeValue(); //$NON-NLS-1$
+ if (name.equals("memory")) { //$NON-NLS-1$
+ String memory = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
+ if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
+ memory += " " + attrs.getNamedItem("unit").getNodeValue(); //$NON-NLS-1$
+ }
+ instance.setMemory(memory);
+ } else if (name.equals("storage")) { //$NON-NLS-1$
+ String storage = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
+ if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
+ storage += " " + attrs.getNamedItem("unit").getNodeValue(); //$NON-NLS-1$
+ }
+ instance.setStorage(storage);
+ } else if (name.equals("cpu")) { //$NON-NLS-1$
+ String cpu = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
+ instance.setCPU(cpu);
+ }
+ }
+ }
+ }
+
private Instance buildInstance(String xml) throws Exception {
- Instance instance = JAXB.unmarshal(new StringReader(xml),
- Instance.class);
+ // Instance instance = JAXB.unmarshal(new
+ // StringReader(xml),Instance.class);
+ Instance instance = new Instance();
return updateInstance(xml, instance);
}
@@ -610,40 +637,12 @@
}
}
- private void getProfileProperties(Instance instance,
- List<Node> propertyNodes) {
- if (propertyNodes != null) {
- for (Iterator<Node> i = propertyNodes.iterator(); i.hasNext();) {
- Node n = i.next();
- NamedNodeMap attrs = n.getAttributes();
- String name = attrs.getNamedItem("name").getNodeValue(); //$NON-NLS-1$
- if (name.equals("memory")) { //$NON-NLS-1$
- String memory = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
- if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
- memory += " " + attrs.getNamedItem("unit").getNodeValue(); //$NON-NLS-1$
- }
- instance.setMemory(memory);
- } else if (name.equals("storage")) { //$NON-NLS-1$
- String storage = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
- if (attrs.getNamedItem("unit") != null) { //$NON-NLS-1$
- storage += " " + attrs.getNamedItem("unit").getNodeValue(); //$NON-NLS-1$
- }
- instance.setStorage(storage);
- } else if (name.equals("cpu")) { //$NON-NLS-1$
- String cpu = attrs.getNamedItem("value").getNodeValue(); //$NON-NLS-1$
- instance.setCPU(cpu);
- }
- }
- }
- }
-
private String getIdFromHref(String href) {
return href.substring(href.lastIndexOf("/") + 1, href.length());
}
- private <T extends AbstractDeltaCloudObject> List<T> listDeltaCloudObjects(
- Class<T> clazz, AbstractListObjectsRequest request,
- String elementName) throws DeltaCloudClientException {
+ private <T extends AbstractDeltaCloudObject> List<T> listDeltaCloudObjects(Class<T> clazz,
+ AbstractListObjectsRequest request, String elementName) throws DeltaCloudClientException {
try {
Document document = getDocument(requestStringResponse(request));
List<T> dco = new ArrayList<T>();
@@ -668,8 +667,7 @@
}
@SuppressWarnings("unchecked")
- private <T extends Object> T buildDeltaCloudObject(Class<T> clazz,
- String node) throws Exception {
+ private <T extends Object> T buildDeltaCloudObject(Class<T> clazz, String node) throws Exception {
if (clazz.equals(Instance.class)) {
return (T) buildInstance(node);
} else if (clazz.equals(HardwareProfile.class)) {
14 years
JBoss Tools SVN: r27795 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-12-29 07:38:27 -0500 (Wed, 29 Dec 2010)
New Revision: 27795
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java
Log:
removed JAXB when unmarshalling instances
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java 2010-12-29 12:20:28 UTC (rev 27794)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java 2010-12-29 12:38:27 UTC (rev 27795)
@@ -31,7 +31,7 @@
@XmlElement
private String architecture;
- private Image()
+ protected Image()
{
}
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java 2010-12-29 12:20:28 UTC (rev 27794)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java 2010-12-29 12:38:27 UTC (rev 27795)
@@ -61,13 +61,11 @@
public Instance() {
}
- @SuppressWarnings("unused")
- private void setOwnerId(String ownerId) {
+ protected void setOwnerId(String ownerId) {
this.ownerId = ownerId;
}
- @SuppressWarnings("unused")
- private void setName(String name) {
+ protected void setName(String name) {
this.name = name;
}
14 years
JBoss Tools SVN: r27794 - trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-29 07:20:28 -0500 (Wed, 29 Dec 2010)
New Revision: 27794
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
Log:
JBIDE-8011
https://issues.jboss.org/browse/JBIDE-8011
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2010-12-29 12:19:27 UTC (rev 27793)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2010-12-29 12:20:28 UTC (rev 27794)
@@ -132,7 +132,7 @@
boolean isProperty = false;
if(BeanUtil.isGetter(ms[i]) || BeanUtil.isSetter(ms[i])) {
String propertyName = BeanUtil.getPropertyName(n);
- if(propertyName != null && checkPropertyReturnType(ms[i])) {
+ if(propertyName != null) {
n = propertyName;
isProperty = true;
}
@@ -256,36 +256,4 @@
return c;
}
- private boolean isGetter(IMethod method, String pref) {
- if(method == null) return false;
- String name = method.getElementName();
- if(!name.startsWith(pref) || name.length() <= pref.length()) return false;
- try {
- String[] ps = method.getParameterNames();
- if(ps == null || ps.length != 0) return false;
- String t = EclipseJavaUtil.getMemberTypeAsString(method);
- if(t == null || t.equals("void")) return false;
- } catch (JavaModelException e) {
- return false;
- }
-
- return true;
- }
-
- //TODO move this to BeanUtil.isGetter and isSetter
- private boolean checkPropertyReturnType(IMethod method) {
- if(method == null) {
- return false;
- }
- String typeName = EclipseJavaUtil.getMemberTypeAsString(method);
- if(typeName == null || typeName.equals("void")) {
- return false;
- }
- if(method.getElementName().startsWith(BeanUtil.IS)) {
- if(!"boolean".equals(typeName) && !"java.lang.Boolean".equals(typeName)) {
- return false;
- }
- }
- return true;
- }
}
14 years
JBoss Tools SVN: r27793 - in trunk/common/tests/org.jboss.tools.common.model.test: projects/Test1/src and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-29 07:19:27 -0500 (Wed, 29 Dec 2010)
New Revision: 27793
Added:
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/demo/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/demo/User.java
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/util/test/EclipseJavaUtilTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java
Log:
JBIDE-8011
https://issues.jboss.org/browse/JBIDE-8011
Modified: trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF 2010-12-29 12:17:58 UTC (rev 27792)
+++ trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF 2010-12-29 12:19:27 UTC (rev 27793)
@@ -9,6 +9,7 @@
Require-Bundle:
org.junit,
org.eclipse.core.runtime,
+ org.eclipse.jdt.core,
org.eclipse.core.resources,
org.jboss.tools.common.model,
org.jboss.tools.common.test,
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/demo/User.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/demo/User.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/demo/User.java 2010-12-29 12:19:27 UTC (rev 27793)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package demo;
+
+/**
+ * Created by JBoss Developer Studio
+ */
+public class User {
+
+ private String name;
+
+ /**
+ * @return User Name
+ */
+ public String getST() {
+ return name;
+ }
+
+ /**
+ * @param User Name
+ */
+ public void setST(String name) {
+ this.name = name;
+ }
+
+ public boolean isBooleanValue1() {
+ return true;
+ }
+
+ public Boolean isBooleanValue2() {
+ return Boolean.TRUE;
+ }
+
+ public int isBooleanValue3() {
+ return 0;
+ }
+
+ public void getVoid() {
+
+ }
+
+ public int getIntValue() {
+ return 0;
+ }
+}
\ No newline at end of file
Property changes on: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/demo/User.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java 2010-12-29 12:17:58 UTC (rev 27792)
+++ trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java 2010-12-29 12:19:27 UTC (rev 27793)
@@ -12,6 +12,7 @@
import org.jboss.tools.common.ant.parser.test.AntParserTest;
import org.jboss.tools.common.model.exception.test.DeveloperExceptionTest;
+import org.jboss.tools.common.model.util.test.EclipseJavaUtilTest;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -32,6 +33,7 @@
suite.addTestSuite(XModelTransferBufferTest.class);
suite.addTestSuite(PropertiesLoaderTest.class);
suite.addTestSuite(JarAccessTest.class);
+ suite.addTestSuite(EclipseJavaUtilTest.class);
return suite;
}
}
Added: trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/util/test/EclipseJavaUtilTest.java
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/util/test/EclipseJavaUtilTest.java (rev 0)
+++ trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/util/test/EclipseJavaUtilTest.java 2010-12-29 12:19:27 UTC (rev 27793)
@@ -0,0 +1,73 @@
+package org.jboss.tools.common.model.util.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.util.BeanUtil;
+import org.jboss.tools.common.util.EclipseJavaUtil;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.TestProjectProvider;
+
+public class EclipseJavaUtilTest extends TestCase {
+
+ static String BUNDLE_NAME = "org.jboss.tools.common.model.test";
+ TestProjectProvider provider1 = null;
+ IProject project1 = null;
+
+ public void setUp() throws Exception {
+ provider1 = new TestProjectProvider(BUNDLE_NAME, null, "Test1", true);
+ project1 = provider1.getProject();
+
+ project1.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+
+ JobUtils.waitForIdle();
+ }
+
+ public void testGetters() throws Exception {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(project1);
+ assertNotNull(jp);
+
+ IType user = EclipseJavaUtil.findType(jp, "demo.User");
+ assertNotNull(user);
+
+ IMethod[] ms = user.getMethods();
+ Map<String, IMethod> methods = new HashMap<String, IMethod>();
+ for (IMethod m: ms) methods.put(m.getElementName(), m);
+
+ IMethod m = methods.get("isBooleanValue1");
+ assertNotNull(m);
+ assertEquals("boolean", EclipseJavaUtil.getMemberTypeAsString(m));
+ assertTrue("Method isBooleanValue1() is not recognized as getter", BeanUtil.isGetter(m));
+
+ m = methods.get("isBooleanValue2");
+ assertNotNull(m);
+ assertEquals("java.lang.Boolean", EclipseJavaUtil.getMemberTypeAsString(m));
+ assertTrue("Method isBooleanValue2() is not recognized as getter", BeanUtil.isGetter(m));
+
+ m = methods.get("isBooleanValue3");
+ assertNotNull(m);
+ assertEquals("int", EclipseJavaUtil.getMemberTypeAsString(m));
+ assertFalse("Method isBooleanValue3() is misrecognized as getter", BeanUtil.isGetter(m));
+
+ m = methods.get("getVoid");
+ assertNotNull(m);
+ assertEquals("void", EclipseJavaUtil.getMemberTypeAsString(m));
+ assertFalse("Method getVoid() is misrecognized as getter", BeanUtil.isGetter(m));
+
+ m = methods.get("getIntValue");
+ assertNotNull(m);
+ assertEquals("int", EclipseJavaUtil.getMemberTypeAsString(m));
+ assertTrue("Method getIntValue() is not recognized as getter", BeanUtil.isGetter(m));
+
+ }
+
+}
Property changes on: trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/util/test/EclipseJavaUtilTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years
JBoss Tools SVN: r27792 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-29 07:17:58 -0500 (Wed, 29 Dec 2010)
New Revision: 27792
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseJavaUtil.java
Log:
JBIDE-8011
https://issues.jboss.org/browse/JBIDE-8011
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseJavaUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseJavaUtil.java 2010-12-29 12:16:36 UTC (rev 27791)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseJavaUtil.java 2010-12-29 12:17:58 UTC (rev 27792)
@@ -12,169 +12,18 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IAnnotatable;
-import org.eclipse.jdt.core.IAnnotation;
-import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jdt.core.Signature;
-import org.jboss.tools.common.model.plugin.ModelPlugin;
-public class EclipseJavaUtil {
+public class EclipseJavaUtil extends org.jboss.tools.common.util.EclipseJavaUtil {
- public static String getMemberTypeAsString(IMember member) {
- if(member instanceof IField) return getMemberTypeAsString((IField)member);
- if(member instanceof IMethod) return getMemberTypeAsString((IMethod)member);
- return null;
- }
-
- public static String getMemberTypeAsString(IField f) {
- if(f == null) return null;
- try {
- String typeName = new String(Signature.toCharArray(f.getTypeSignature().toCharArray()));
- return resolveType(f.getDeclaringType(), typeName);
- } catch (JavaModelException e) {
- ModelPlugin.getPluginLog().logError(e);
- }
- return null;
- }
-
- public static String getMemberTypeAsString(IMethod m) {
- if(m == null) return null;
- try {
- return resolveTypeAsString(m.getDeclaringType(), m.getReturnType());
- } catch (JavaModelException e) {
- ModelPlugin.getPluginLog().logError(e);
- }
- return null;
- }
-
- public static String resolveTypeAsString(IType type, String typeName) {
- if(type == null || typeName == null) return null;
- typeName = new String(Signature.toCharArray(typeName.toCharArray()));
- return resolveType(type, typeName);
- }
-
- static String NULL = ";;;"; //$NON-NLS-1$
-
- static class Resolved {
- IType type;
- Map<String, String> types = new HashMap<String, String>();
- Resolved(IType type) {
- this.type = type;
- }
-
- void setType(IType type) {
- this.type = type;
- types.clear();
- }
- }
-
- static Map<String,Resolved> resolved = new HashMap<String, Resolved>();
-
- static String getKey(IType type) {
- String n = type.getFullyQualifiedName();
- IJavaProject jp = type.getJavaProject();
- if(jp == null) return n;
- IProject p = jp.getProject();
- if(p == null || !p.isAccessible()) return n;
- return p.getName() + ":" + n; //$NON-NLS-1$
- }
- public static String resolveType(IType type, String typeName) {
- if(type == null) return null;
- if(type.isBinary() || typeName == null) return typeName;
- int i = typeName.indexOf("<");
- if(i >= 0) {
- int j = typeName.lastIndexOf(">");
- if(j >= i) {
-// typeName = typeName.substring(0, i);
- }
- }
-
- String n = getKey(type);
- Resolved r = resolved.get(n);
- if(r == null) {
- r = new Resolved(type);
- resolved.put(n, r);
-// if(resolved.size() % 100 == 0) {
-// System.out.println("-->" + resolved.size() + " " + n); //$NON-NLS-1$ //$NON-NLS-2$
-// }
- }
- if(r.type != type) {
- r.setType(type);
- }
-
- String result = r.types.get(typeName);
-
- if(result != null) {
- return (result == NULL) ? null : result;
- }
-
- result = __resolveType(type, typeName);
-
- String nresult = result == null ? NULL : result;
-
- r.types.put(typeName, nresult);
-
-// System.out.println(n + " " + typeName);
-
- return result;
-
- }
-
- private static String __resolveType(IType type, String typeName) {
- if(type == null || typeName == null) return null;
- try {
- String resolvedArray[][] = type.resolveType(typeName);
-// resolvedArray == null for primitive types
- if(resolvedArray == null) return typeName;
- typeName = ""; //$NON-NLS-1$
- for (int i = 0; i < resolvedArray[0].length; i++)
- typeName += (!"".equals(typeName) ? "." : "") + resolvedArray[0][i]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return typeName;
- } catch (JavaModelException e) {
- ModelPlugin.getPluginLog().logError(e);
- } catch (IllegalArgumentException ee) {
- System.out.println("Illegal " + typeName);
- }
- return null;
- }
-
- public static IType findType(IJavaProject javaProject, String qualifiedName) throws JavaModelException {
- if(qualifiedName == null || qualifiedName.length() == 0) return null;
- IType type = javaProject.findType(qualifiedName);
- if(type != null) return type;
- int dot = qualifiedName.lastIndexOf('.');
- String packageName = (dot < 0) ? "" : qualifiedName.substring(0, dot); //$NON-NLS-1$
- String shortName = qualifiedName.substring(dot + 1);
- IPackageFragmentRoot[] rs = javaProject.getPackageFragmentRoots();
- for (int i = 0; i < rs.length; i++) {
- IPackageFragment f = rs[i].getPackageFragment(packageName);
- if(f == null || !f.exists()) continue;
- ICompilationUnit[] us = f.getCompilationUnits();
- for (int j = 0; j < us.length; j++) {
- IType t = us[j].getType(shortName);
- if(t != null && t.exists()) return t;
- }
- }
- return null;
- }
-
public static boolean isDerivedClass(String type, String superType, IProject project) {
if(type == null) return false;
if(superType == null || superType.equals("java.lang.Object")) return true; //$NON-NLS-1$
@@ -224,28 +73,4 @@
return suppers;
}
- public static IAnnotation findAnnotation(IType sourceType, IAnnotatable member, String qulifiedAnnotationName) throws JavaModelException{
- IAnnotation[] annotations = member.getAnnotations();
- String simpleAnnotationTypeName = qulifiedAnnotationName;
- int lastDot = qulifiedAnnotationName.lastIndexOf('.');
- if(lastDot>-1) {
- simpleAnnotationTypeName = simpleAnnotationTypeName.substring(lastDot + 1);
- }
- for (IAnnotation annotation : annotations) {
- if(qulifiedAnnotationName.equals(annotation.getElementName())) {
- return annotation;
- }
- if(simpleAnnotationTypeName.equals(annotation.getElementName())) {
- String fullAnnotationclassName = EclipseJavaUtil.resolveType(sourceType, simpleAnnotationTypeName);
- if(fullAnnotationclassName!=null) {
- IType annotationType = sourceType.getJavaProject().findType(fullAnnotationclassName);
- if(annotationType!=null && annotationType.getFullyQualifiedName().equals(qulifiedAnnotationName)) {
- return annotation;
- }
- }
- }
- }
- return null;
- }
-
}
\ No newline at end of file
14 years
JBoss Tools SVN: r27791 - trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-12-29 07:16:36 -0500 (Wed, 29 Dec 2010)
New Revision: 27791
Added:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
Modified:
trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java
Log:
JBIDE-8011
https://issues.jboss.org/browse/JBIDE-8011
Modified: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java 2010-12-29 06:58:56 UTC (rev 27790)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/BeanUtil.java 2010-12-29 12:16:36 UTC (rev 27791)
@@ -34,9 +34,26 @@
}
public static boolean isGetter(IMethod method) {
- return method != null && isGetter(method.getElementName(), method.getNumberOfParameters());
+ return method != null && isGetter(method.getElementName(), method.getNumberOfParameters())
+ && checkPropertyReturnType(method);
}
+ private static boolean checkPropertyReturnType(IMethod method) {
+ if(method == null) {
+ return false;
+ }
+ String typeName = EclipseJavaUtil.getMemberTypeAsString(method);
+ if(typeName == null || typeName.equals("void")) { //$NON-NLS-1$
+ return false;
+ }
+ if(method.getElementName().startsWith(BeanUtil.IS)) {
+ if(!"boolean".equals(typeName) && !"java.lang.Boolean".equals(typeName)) { //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+ }
+ return true;
+ }
+
public static boolean isSetter(IMethod method) {
return method != null && isSetter(method.getElementName(), method.getNumberOfParameters());
}
Added: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java (rev 0)
+++ trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java 2010-12-29 12:16:36 UTC (rev 27791)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and 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:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.util;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IAnnotatable;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.jboss.tools.common.CommonPlugin;
+
+public class EclipseJavaUtil {
+
+ public static String getMemberTypeAsString(IMember member) {
+ if(member instanceof IField) return getMemberTypeAsString((IField)member);
+ if(member instanceof IMethod) return getMemberTypeAsString((IMethod)member);
+ return null;
+ }
+
+ public static String getMemberTypeAsString(IField f) {
+ if(f == null) return null;
+ try {
+ String typeName = new String(Signature.toCharArray(f.getTypeSignature().toCharArray()));
+ return resolveType(f.getDeclaringType(), typeName);
+ } catch (JavaModelException e) {
+ CommonPlugin.getPluginLog().logError(e);
+ }
+ return null;
+ }
+
+ public static String getMemberTypeAsString(IMethod m) {
+ if(m == null) return null;
+ try {
+ return resolveTypeAsString(m.getDeclaringType(), m.getReturnType());
+ } catch (JavaModelException e) {
+ CommonPlugin.getPluginLog().logError(e);
+ }
+ return null;
+ }
+
+ public static String resolveTypeAsString(IType type, String typeName) {
+ if(type == null || typeName == null) return null;
+ typeName = new String(Signature.toCharArray(typeName.toCharArray()));
+ return resolveType(type, typeName);
+ }
+
+ static String NULL = ";;;"; //$NON-NLS-1$
+
+ static class Resolved {
+ IType type;
+ Map<String, String> types = new HashMap<String, String>();
+ Resolved(IType type) {
+ this.type = type;
+ }
+
+ void setType(IType type) {
+ this.type = type;
+ types.clear();
+ }
+ }
+
+ static Map<String,Resolved> resolved = new HashMap<String, Resolved>();
+
+ static String getKey(IType type) {
+ String n = type.getFullyQualifiedName();
+ IJavaProject jp = type.getJavaProject();
+ if(jp == null) return n;
+ IProject p = jp.getProject();
+ if(p == null || !p.isAccessible()) return n;
+ return p.getName() + ":" + n; //$NON-NLS-1$
+ }
+ public static String resolveType(IType type, String typeName) {
+ if(type == null) return null;
+ if(type.isBinary() || typeName == null) return typeName;
+ int i = typeName.indexOf("<");
+ if(i >= 0) {
+ int j = typeName.lastIndexOf(">");
+ if(j >= i) {
+// typeName = typeName.substring(0, i);
+ }
+ }
+
+ String n = getKey(type);
+ Resolved r = resolved.get(n);
+ if(r == null) {
+ r = new Resolved(type);
+ resolved.put(n, r);
+// if(resolved.size() % 100 == 0) {
+// System.out.println("-->" + resolved.size() + " " + n); //$NON-NLS-1$ //$NON-NLS-2$
+// }
+ }
+ if(r.type != type) {
+ r.setType(type);
+ }
+
+ String result = r.types.get(typeName);
+
+ if(result != null) {
+ return (result == NULL) ? null : result;
+ }
+
+ result = __resolveType(type, typeName);
+
+ String nresult = result == null ? NULL : result;
+
+ r.types.put(typeName, nresult);
+
+// System.out.println(n + " " + typeName);
+
+ return result;
+
+ }
+
+ private static String __resolveType(IType type, String typeName) {
+ if(type == null || typeName == null) return null;
+ try {
+ String resolvedArray[][] = type.resolveType(typeName);
+// resolvedArray == null for primitive types
+ if(resolvedArray == null) return typeName;
+ typeName = ""; //$NON-NLS-1$
+ for (int i = 0; i < resolvedArray[0].length; i++)
+ typeName += (!"".equals(typeName) ? "." : "") + resolvedArray[0][i]; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return typeName;
+ } catch (JavaModelException e) {
+ CommonPlugin.getPluginLog().logError(e);
+ } catch (IllegalArgumentException ee) {
+ System.out.println("Illegal " + typeName);
+ }
+ return null;
+ }
+
+ public static IType findType(IJavaProject javaProject, String qualifiedName) throws JavaModelException {
+ if(qualifiedName == null || qualifiedName.length() == 0) return null;
+ IType type = javaProject.findType(qualifiedName);
+ if(type != null) return type;
+ int dot = qualifiedName.lastIndexOf('.');
+ String packageName = (dot < 0) ? "" : qualifiedName.substring(0, dot); //$NON-NLS-1$
+ String shortName = qualifiedName.substring(dot + 1);
+ IPackageFragmentRoot[] rs = javaProject.getPackageFragmentRoots();
+ for (int i = 0; i < rs.length; i++) {
+ IPackageFragment f = rs[i].getPackageFragment(packageName);
+ if(f == null || !f.exists()) continue;
+ ICompilationUnit[] us = f.getCompilationUnits();
+ for (int j = 0; j < us.length; j++) {
+ IType t = us[j].getType(shortName);
+ if(t != null && t.exists()) return t;
+ }
+ }
+ return null;
+ }
+
+ public static List<IType> getSupperTypes(IType type) throws JavaModelException {
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
+ IType[] superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type);
+ if(superTypes == null) {
+ return Collections.emptyList();
+ }
+ List<IType> suppers = new ArrayList<IType>();
+ for (int i = 0; i < superTypes.length; i++) {
+ suppers.add(superTypes[i]);
+ }
+ return suppers;
+ }
+
+ public static IAnnotation findAnnotation(IType sourceType, IAnnotatable member, String qulifiedAnnotationName) throws JavaModelException{
+ IAnnotation[] annotations = member.getAnnotations();
+ String simpleAnnotationTypeName = qulifiedAnnotationName;
+ int lastDot = qulifiedAnnotationName.lastIndexOf('.');
+ if(lastDot>-1) {
+ simpleAnnotationTypeName = simpleAnnotationTypeName.substring(lastDot + 1);
+ }
+ for (IAnnotation annotation : annotations) {
+ if(qulifiedAnnotationName.equals(annotation.getElementName())) {
+ return annotation;
+ }
+ if(simpleAnnotationTypeName.equals(annotation.getElementName())) {
+ String fullAnnotationclassName = EclipseJavaUtil.resolveType(sourceType, simpleAnnotationTypeName);
+ if(fullAnnotationclassName!=null) {
+ IType annotationType = sourceType.getJavaProject().findType(fullAnnotationclassName);
+ if(annotationType!=null && annotationType.getFullyQualifiedName().equals(qulifiedAnnotationName)) {
+ return annotation;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/common/plugins/org.jboss.tools.common/src/org/jboss/tools/common/util/EclipseJavaUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years
JBoss Tools SVN: r27790 - in trunk/ws: plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands and 3 other directories.
by jbosstools-commits@lists.jboss.org
Author: Grid.Qian
Date: 2010-12-29 01:58:56 -0500 (Wed, 29 Dec 2010)
New Revision: 27790
Modified:
trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ImplementationClassCreationCommand.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java
Log:
JBIDE-7913: partly fixed this issue by change the method of finding classes that contain webservice annotation
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/META-INF/MANIFEST.MF 2010-12-29 06:58:56 UTC (rev 27790)
@@ -37,7 +37,8 @@
org.eclipse.jdt.launching,
org.eclipse.debug.core,
org.eclipse.jst.jee.web,
- javax.wsdl;visibility:=reexport
+ javax.wsdl;visibility:=reexport,
+ org.eclipse.jst.ws.annotations.core
Bundle-ActivationPolicy: lazy
Export-Package: org.jboss.tools.ws.creation.core,
org.jboss.tools.ws.creation.core.commands,
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ClientSampleCreationCommand.java 2010-12-29 06:58:56 UTC (rev 27790)
@@ -89,7 +89,7 @@
List<ICompilationUnit> serviceUnits = JBossWSCreationUtils
.findJavaUnitsByAnnotation(
project,
- JBossWSCreationCoreMessages.Webservice_Annotation_Check,
+ JBossWSCreationCoreMessages.Webservice_Annotation,
model.getCustomPackage());
if (clientUnits.size() == 0) {
@@ -160,7 +160,6 @@
return StatusUtils
.errorStatus(JBossWSCreationCoreMessages.Error_Create_Client_Sample);
}
- System.out.println(sb.toString());
return Status.OK_STATUS;
}
@@ -390,13 +389,11 @@
sb.append(argsNum).append("])"); //$NON-NLS-1$
countArgs(j, sb, list);
argsNum += 1;
- System.out.println(argsNum);
return true;
} else if ("String".equals(para.getType().toString())) { //$NON-NLS-1$
sb.append("args[").append(argsNum).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
countArgs(j, sb, list);
argsNum += 1;
- System.out.println(argsNum);
return true;
}
if (list.get(j) instanceof Object) {
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ImplementationClassCreationCommand.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ImplementationClassCreationCommand.java 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/commands/ImplementationClassCreationCommand.java 2010-12-29 06:58:56 UTC (rev 27790)
@@ -102,7 +102,7 @@
List<ICompilationUnit> serviceUnits = JBossWSCreationUtils
.findJavaUnitsByAnnotation(
javaPrj,
- JBossWSCreationCoreMessages.Webservice_Annotation_Check,
+ JBossWSCreationCoreMessages.Webservice_Annotation,
model.getCustomPackage());
packageName = model.getCustomPackage();
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCore.properties 2010-12-29 06:58:56 UTC (rev 27790)
@@ -3,10 +3,9 @@
Value_Target_0=2.0
Value_Target_1=2.1
Separator_Java=/
-WebserviceClient_Annotation=@WebServiceClient
+WebserviceClient_Annotation=WebServiceClient
Webservice_Annotation=WebService
Webservice_Annotation_Prefix=javax.jws.WebService
-Webservice_Annotation_Check=@WebService(
Client_Sample_Package_Name=.clientsample
Client_Sample_Class_Name=ClientSample
WebEndpoint=WebEndpoint
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/messages/JBossWSCreationCoreMessages.java 2010-12-29 06:58:56 UTC (rev 27790)
@@ -11,7 +11,6 @@
public static String Value_Target_1;
public static String Separator_Java;
public static String WebserviceClient_Annotation;
- public static String Webservice_Annotation_Check;
public static String Webservice_Annotation;
public static String Webservice_Annotation_Prefix;
public static String WebEndpoint;
Modified: trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java
===================================================================
--- trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/plugins/org.jboss.tools.ws.creation.core/src/org/jboss/tools/ws/creation/core/utils/JBossWSCreationUtils.java 2010-12-29 06:58:56 UTC (rev 27790)
@@ -43,6 +43,7 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IParent;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.wst.common.componentcore.ComponentCore;
@@ -446,23 +447,27 @@
return path;
}
- public static String composeSrcPackageClassPath ( IProject project, String packageName, String className) {
+ public static String composeSrcPackageClassPath(IProject project,
+ String packageName, String className) {
String classFilePath = null;
try {
- String srcPath = JBossWSCreationUtils.getJavaProjectSrcLocation(project);
+ String srcPath = JBossWSCreationUtils
+ .getJavaProjectSrcLocation(project);
if (srcPath != null && srcPath.trim().length() > 0) {
String pathSeparator = "" + File.separatorChar; //$NON-NLS-1$
- String packageToFolderPath = packageName.replace(".", pathSeparator); //$NON-NLS-1$
- classFilePath = srcPath + pathSeparator + packageToFolderPath + pathSeparator + className + JAVA;
+ String packageToFolderPath = packageName.replace(
+ ".", pathSeparator); //$NON-NLS-1$
+ classFilePath = srcPath + pathSeparator + packageToFolderPath
+ + pathSeparator + className + JAVA;
return classFilePath;
}
} catch (JavaModelException e) {
return null;
}
return null;
-
+
}
-
+
public static File findFileByPath(String path) {
File file = new File(path);
if (file.exists())
@@ -534,9 +539,11 @@
}
if (javaFiles != null) {
for (ICompilationUnit unit : javaFiles) {
- if (unit.getSource().contains(annotation)) {
- units.add(unit);
-
+ if (unit.getTypes().length > 0) {
+ IType type = unit.getTypes()[0];
+ if (type.getAnnotation(annotation).exists()) {
+ units.add(unit);
+ }
}
}
}
Modified: trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java 2010-12-29 01:30:07 UTC (rev 27789)
+++ trunk/ws/tests/org.jboss.tools.ws.creation.core.test/src/org/jboss/tools/ws/creation/core/test/command/JBossWSClientSampleCreationCommandTest.java 2010-12-29 06:58:56 UTC (rev 27790)
@@ -33,7 +33,7 @@
ServiceModel model = new ServiceModel();
model.setCustomPackage("");
model.setWebProjectName("WebTest");
- List<ICompilationUnit> list = JBossWSCreationUtils.findJavaUnitsByAnnotation(JavaCore.create(prj), "@WebService", "");
+ List<ICompilationUnit> list = JBossWSCreationUtils.findJavaUnitsByAnnotation(JavaCore.create(prj), "WebService", "");
assertTrue("No java files in src!",list.isEmpty());
}
14 years