diff options
author | nhauge | 2011-07-27 21:45:07 +0000 |
---|---|---|
committer | nhauge | 2011-07-27 21:45:07 +0000 |
commit | b8c19f68cd05dcc6deb49cd81906f097fc0ffe6b (patch) | |
tree | b00c1fde6ff1c5c5ca9d0fe0e6a25a30dae2b2f8 | |
parent | 5232f02853ffee24f38a5976943efc708c3fadae (diff) | |
download | webtools.dali-b8c19f68cd05dcc6deb49cd81906f097fc0ffe6b.tar.gz webtools.dali-b8c19f68cd05dcc6deb49cd81906f097fc0ffe6b.tar.xz webtools.dali-b8c19f68cd05dcc6deb49cd81906f097fc0ffe6b.zip |
[351975] Fix NPE's for special characters and unresolved classes. Patch from Nan with minor adjustments.
3 files changed, 20 insertions, 15 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java index 59928f6756..c91dec73c6 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/JDTTools.java @@ -281,21 +281,23 @@ public final class JDTTools { if (javaProject != null && className != null) { boolean hasDefinedConstructor = false; IType type = findType(javaProject, className); - try { - for (IMethod method : type.getMethods()) { - if (method.isConstructor()) { - if ((method.getNumberOfParameters() == 0) && (Flags.isPublic(method.getFlags()))) { - return true; + if (type != null) { + try { + for (IMethod method : type.getMethods()) { + if (method.isConstructor()) { + if ((method.getNumberOfParameters() == 0) && (Flags.isPublic(method.getFlags()))) { + return true; + } + hasDefinedConstructor = true; } - hasDefinedConstructor = true; } + //When there's no defined constructor, the default constructor is in place. + if (!hasDefinedConstructor) { + return true; + } + } catch (JavaModelException ex) { + JptCommonCorePlugin.log(ex); } - //When there's no defined constructor, the default constructor is in place. - if (!hasDefinedConstructor) { - return true; - } - } catch (JavaModelException ex) { - JptCommonCorePlugin.log(ex); } } return false; diff --git a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java index c8be45a290..ccf435662e 100644 --- a/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java +++ b/common/plugins/org.eclipse.jpt.common.core/src/org/eclipse/jpt/common/core/internal/utility/jdt/ASTTools.java @@ -123,7 +123,7 @@ public class ASTTools { * type binding. */ public static ITypeBinding resolveTypeBinding(Expression expression) { - if (expression.getNodeType() == ASTNode.TYPE_LITERAL) { + if (expression != null && expression.getNodeType() == ASTNode.TYPE_LITERAL) { return ((TypeLiteral) expression).getType().resolveBinding(); } return null; @@ -135,7 +135,7 @@ public class ASTTools { * The result may include <code>null</code> elements. */ public static Iterable<ITypeBinding> resolveTypeBindings(Expression expression) { - return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ? + return (expression != null && expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ? resolveTypeBindings((ArrayInitializer) expression) : EmptyIterable.<ITypeBinding>instance(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java index 47e0b3d25a..e1715808bb 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomizer.java @@ -167,7 +167,10 @@ public class JavaEclipseLinkCustomizer protected void validateCustomizerClass(List<IMessage> messages,CompilationUnit astRoot) { IJavaProject javaProject = getPersistenceUnit().getJpaProject().getJavaProject(); EclipseLinkCustomizerAnnotation annotation = this.getCustomizerAnnotation(); - if (annotation != null && annotation.getValue() != null) { + if (annotation != null && annotation.getValue() != null && + //if the type cannot be resolved there is no need to perform the following validation, + //JDT will note the error in the source + JDTTools.findType(javaProject, annotation.getValue()) != null) { if (!JDTTools.classHasPublicZeroArgConstructor(javaProject, this.getFullyQualifiedCustomizerClass())) { messages.add( DefaultEclipseLinkJpaValidationMessages.buildMessage( |