List of usage examples for org.springframework.ide.eclipse.core.java JdtUtils getJavaTypeForMethodReturnType
public static final IType getJavaTypeForMethodReturnType(IMethod method, IType contextType)
From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java
public static void addPropertyNameAttributeValueProposals(ContentAssistRequest request, String prefix, String oldPrefix, IType type) { // resolve type of indexed and nested property path if (prefix.lastIndexOf(".") >= 0) { int firstIndex = prefix.indexOf("."); String firstPrefix = prefix.substring(0, firstIndex); String lastPrefix = prefix.substring(firstIndex); if (".".equals(lastPrefix)) { lastPrefix = ""; } else if (lastPrefix.startsWith(".")) { lastPrefix = lastPrefix.substring(1); }/*w ww . j av a 2s . c om*/ try { Collection<?> methods = Introspector.findReadableProperties(type, firstPrefix, true); if (methods != null && methods.size() == 1) { Iterator<?> iterator = methods.iterator(); while (iterator.hasNext()) { IMethod method = (IMethod) iterator.next(); IType returnType = JdtUtils.getJavaTypeForMethodReturnType(method, type); if (returnType != null) { String newPrefix = oldPrefix + firstPrefix + "."; addPropertyNameAttributeValueProposals(request, lastPrefix, newPrefix, returnType); } return; } } } catch (CoreException e) { // do nothing } } else { try { Collection<?> methods = Introspector.findWritableProperties(type, prefix, true); if (methods != null && methods.size() > 0) { Iterator<?> iterator = methods.iterator(); while (iterator.hasNext()) { createMethodProposal(request, (IMethod) iterator.next(), oldPrefix); } } } catch (JavaModelException e1) { // do nothing } } }
From source file:org.dozer.eclipse.plugin.sourcepage.util.DozerPluginUtils.java
public static IType hasReadProperty(String property, String className, IProject project, boolean noGetter) throws JavaModelException { IType javaType = JdtUtils.getJavaType(project, className); String checkProperty = property; String[] propertySplitted = checkProperty.split("\\."); //we only check the first level, if there is some x.y.z property if (propertySplitted.length > 1) { checkProperty = propertySplitted[0]; }/*from ww w . ja v a 2s .com*/ //if we are doing indexed property mapping, we remove the [] checkProperty = checkProperty.replaceAll("\\[\\]", ""); if (noGetter) { IField[] fields = javaType.getFields(); for (IField field : fields) { if (field.getElementName().equals(property)) { return field.getDeclaringType(); } } return null; } Collection<IMethod> methods = Introspector.findReadableProperties(javaType, checkProperty, true); boolean retVal = methods.size() > 0; if (!retVal) return null; else { try { //className = JdtUtils.resolveClassName(className, javaType); if (!Class.forName(className).isPrimitive()) className = null; } catch (Throwable t) { //className = null; } Iterator<?> iterator = methods.iterator(); while (iterator.hasNext()) { IMethod method = (IMethod) iterator.next(); IType returnType = JdtUtils.getJavaTypeForMethodReturnType(method, javaType); if (className == null) { if (returnType != null) className = returnType.getFullyQualifiedName(); } if (className != null) { if (propertySplitted.length > 1) { List<String> l = new ArrayList<String>(Arrays.asList(propertySplitted)); l.remove(0); property = StringUtils.collectionToDelimitedString(l, "."); return hasReadProperty(property, returnType.getFullyQualifiedName(), project, false); } else { return returnType; } } } } return null; }