Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2012-03-21 16:21:03 -0400
committerpfullbright2012-03-21 16:21:03 -0400
commit8317bcdb79dd15fd8d82568c5b1d8366f9949797 (patch)
tree134d73fb2555b238a2648ab4ed7450457a2187cc
parent846547228bfbf075832135d0f17055b4429a3614 (diff)
downloadwebtools.dali-8317bcdb79dd15fd8d82568c5b1d8366f9949797.tar.gz
webtools.dali-8317bcdb79dd15fd8d82568c5b1d8366f9949797.tar.xz
webtools.dali-8317bcdb79dd15fd8d82568c5b1d8366f9949797.zip
bugs 374370, 374379 - JPQL validation fixes
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidator.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/JpaJpqlQueryHelper.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/prefs/JpaValidationPreferencesManager.java14
3 files changed, 33 insertions, 20 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidator.java
index c08176790c..8906e7d6af 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/JpaValidator.java
@@ -31,9 +31,9 @@ import org.eclipse.wst.validation.internal.provisional.core.IValidator;
* WTP validator extension point.
*/
public class JpaValidator
- extends AbstractValidator
- implements IValidator
-{
+ extends AbstractValidator
+ implements IValidator {
+
public JpaValidator() {
super();
}
@@ -85,13 +85,16 @@ public class JpaValidator
private void validate(IReporter reporter, IProject project) {
Iterable<IMessage> messages = this.buildValidationMessages(reporter, project);
+
// since the validation messages are usually built asynchronously
// and a workspace shutdown could occur in the meantime,
// wait until we actually get the new messages before we clear out the old messages
this.clearMarkers(project);
+
+ JpaValidationPreferencesManager prefsManager = new JpaValidationPreferencesManager(project);
for (IMessage message : messages) {
// check preferences for IGNORE
- if ((new JpaValidationPreferencesManager(project)).problemIsNotIgnored(message.getId())) {
+ if (prefsManager.problemIsNotIgnored(message.getId())) {
reporter.addMessage(this, message);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/JpaJpqlQueryHelper.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/JpaJpqlQueryHelper.java
index 3b4972ec50..cd13055395 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/JpaJpqlQueryHelper.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpql/JpaJpqlQueryHelper.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.NamedQuery;
@@ -199,11 +200,10 @@ public abstract class JpaJpqlQueryHelper extends AbstractJPQLQueryHelper {
);
}
- protected int getValidationPreference(NamedQuery namedQuery) {
- return JpaValidationPreferencesManager.getProblemSeverityPreference(
- namedQuery.getResource(),
- JpaValidationMessages.JPQL_QUERY_VALIDATION
- );
+ protected String getValidationPreference(NamedQuery namedQuery) {
+ return JpaValidationPreferencesManager.getProblemPreference(
+ namedQuery.getResource(),
+ JpaValidationMessages.JPQL_QUERY_VALIDATION);
}
/**
@@ -229,17 +229,21 @@ public abstract class JpaJpqlQueryHelper extends AbstractJPQLQueryHelper {
* @param targetObject The object for which a new {@link IMessage} is creating describing the
* problem
- * @return The global severity for validating JPQL queries
+ * @return The global severity for validating JPQL queries. The default is {@link IMessage#HIGH_SEVERITY}.
*/
protected int severity(IResource targetObject) {
- return JpaValidationPreferencesManager.getProblemSeverityPreference(
- targetObject,
- JpaValidationMessages.JPQL_QUERY_VALIDATION
- );
+ int severity = JpaValidationPreferencesManager.getProblemSeverityPreference(
+ targetObject, JpaValidationMessages.JPQL_QUERY_VALIDATION);
+ if (severity == JpaValidationPreferencesManager.NO_SEVERITY_PREFERENCE) {
+ return IMessage.HIGH_SEVERITY;
+ }
+ return severity;
}
-
+
protected boolean shouldValidate(NamedQuery namedQuery) {
- return getValidationPreference(namedQuery) == -1;
+ return ! StringTools.stringsAreEqual(
+ getValidationPreference(namedQuery),
+ JpaValidationPreferencesManager.IGNORE);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/prefs/JpaValidationPreferencesManager.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/prefs/JpaValidationPreferencesManager.java
index 71881a3bd8..d65e4e18e8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/prefs/JpaValidationPreferencesManager.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/prefs/JpaValidationPreferencesManager.java
@@ -37,16 +37,21 @@ public class JpaValidationPreferencesManager extends JpaPreferencesManager
public static final String WORKSPACE_PREFERENCES_OVERRIDEN = "workspace_preferences_overriden"; //$NON-NLS-1$
// ********** public static methods **********
+
+ public static String getProblemPreference(IResource targetObject, String messageId) {
+ return new JpaValidationPreferencesManager(targetObject.getProject()).
+ getLegacyPreference(appendProblemPrefix(messageId));
+ }
+
/**
* Returns only the severity level of a given problem preference. This does not
* include information on whether the problem is ignored. See isProblemIgnored.
* @return an IMessage severity level
*/
public static int getProblemSeverityPreference(IResource targetObject, String messageId) {
- String problemPreference = (new JpaValidationPreferencesManager(targetObject.getProject())).
- getLegacyPreference(appendProblemPrefix(messageId));
-
+ String problemPreference = getProblemPreference(targetObject, messageId);
+
if(problemPreference == null) {
return NO_SEVERITY_PREFERENCE;
}
@@ -61,7 +66,8 @@ public class JpaValidationPreferencesManager extends JpaPreferencesManager
}
return NO_SEVERITY_PREFERENCE;
}
-
+
+
// ********** workspace preference **********
/**

Back to the top