Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkmoore2010-07-13 18:49:42 +0000
committerkmoore2010-07-13 18:49:42 +0000
commit2394ff95ef8c489a322297a17a01920e87b746b9 (patch)
tree13fd98526d3a87be601513e2993ca64e27468e96
parent41f61ffb310e91a4069d223130f142ff7facca9f (diff)
downloadwebtools.dali-2394ff95ef8c489a322297a17a01920e87b746b9.tar.gz
webtools.dali-2394ff95ef8c489a322297a17a01920e87b746b9.tar.xz
webtools.dali-2394ff95ef8c489a322297a17a01920e87b746b9.zip
Create a JPA problem marker in preparation for supporting quick fixes
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/plugin.xml22
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/DefaultJpaValidationMessages.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java3
5 files changed, 53 insertions, 28 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/plugin.xml b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
index 26ccdd0e83..f9ddc7021e 100644
--- a/jpa/plugins/org.eclipse.jpt.core/plugin.xml
+++ b/jpa/plugins/org.eclipse.jpt.core/plugin.xml
@@ -488,7 +488,8 @@
name="%JPA_VALIDATOR">
<validator
- class="org.eclipse.jpt.core.internal.validation.JpaValidator">
+ class="org.eclipse.jpt.core.internal.validation.JpaValidator"
+ markerId="org.eclipse.jpt.core.jpaProblemMarker">
<include>
<rules>
<facet id="jpt.jpa"/>
@@ -505,4 +506,23 @@
</extension>
+ <!-- =================================================================================== -->
+ <!-- Extension: JPA Problem Marker -->
+ <!-- **** Do NOT qualify the marker id with org.eclipse.jpt.core, see bug 252891 -->
+ <!-- =================================================================================== -->
+ <extension
+ point="org.eclipse.core.resources.markers"
+ id="jpaProblemMarker"
+ name="JPA Problem">
+
+ <persistent value="true"/>
+
+ <!-- Can't use text marker until we have specific models for each input type (XML, java)
+ <super type="org.eclipse.core.resources.textmarker"/>
+ -->
+
+ <super type="org.eclipse.wst.validation.problemmarker2"/>
+ <super type="org.eclipse.jdt.core.problem"/>
+ </extension>
+
</plugin>
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
index 8047e52def..085b3f6cad 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/JptCorePlugin.java
@@ -150,6 +150,13 @@ public class JptCorePlugin extends Plugin {
public static final QualifiedName USER_OVERRIDE_DEFAULT_SCHEMA =
new QualifiedName(PLUGIN_ID, "userOverrideDefaultSchemaName"); //$NON-NLS-1$
+
+ /**
+ * The identifier for the JPA validation marker
+ * (value <code>"org.eclipse.jpt.core.jpaProblemMarker"</code>).
+ */
+ public static final String VALIDATION_MARKER_ID = PLUGIN_ID + ".jpaProblemMarker"; //$NON-NLS-1$
+
/**
* The identifier for the JPA validator
* (value <code>"org.eclipse.jpt.core.jpaValidator"</code>).
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/DefaultJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/DefaultJpaValidationMessages.java
index 2136e52e5e..126fd3368d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/DefaultJpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/DefaultJpaValidationMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -44,6 +44,7 @@ public class DefaultJpaValidationMessages {
severity = severityPreference;
}
IMessage message = new Message(JpaValidationMessages.BUNDLE_NAME, severity, messageId, parms, targetObject);
+ message.setMarkerId(JptCorePlugin.VALIDATION_MARKER_ID);
if (textRange == null) {
//log an exception and then continue without setting location information
//At least the user will still get the validation message and will
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
index 72248499b2..87ef49ec58 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.core.internal.validation;
-import java.util.Iterator;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -19,12 +18,11 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jpt.core.IResourcePart;
import org.eclipse.jpt.core.JpaProject;
import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
+import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
import org.eclipse.wst.validation.AbstractValidator;
import org.eclipse.wst.validation.ValidationResult;
import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.ValidatorMessage;
-import org.eclipse.wst.validation.internal.ValConstants;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IProjectValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -62,34 +60,32 @@ public class JpaValidator extends AbstractValidator implements IValidator {
ValidationResult result = new ValidationResult();
IReporter reporter = result.getReporter(monitor);
IProject project = resource.getProject();
- try {
- clearMarkers(project);
- }
- catch (CoreException ce) {
- JptCorePlugin.log(ce);
- }
+ this.clearMarkers(project);
result.setSuspendValidation(project);
- validate(reporter, project);
+ this.validate(reporter, project);
return result;
}
// **************** internal conv. *****************************************
-
- private void clearMarkers(IProject project) throws CoreException {
- IMarker[] markers = project.findMarkers(ValConstants.ProblemMarker, true, IResource.DEPTH_INFINITE);
- String valId = JptCorePlugin.VALIDATOR_ID;
+ private void clearMarkers(IProject project) {
+ try {
+ clearMarkers_(project);
+ }
+ catch (CoreException ce) {
+ JptCorePlugin.log(ce);
+ }
+ }
+
+ private void clearMarkers_(IProject project) throws CoreException {
+ IMarker[] markers = project.findMarkers(JptCorePlugin.VALIDATION_MARKER_ID, true, IResource.DEPTH_INFINITE);
for (IMarker marker : markers) {
- String id = marker.getAttribute(ValidatorMessage.ValidationId, null);
- if (valId.equals(id)) marker.delete();
+ marker.delete();
}
}
private void validate(IReporter reporter, IProject project) {
- reporter.removeAllMessages(this);
-
- for (Iterator<IMessage> stream = this.validationMessages(reporter, project); stream.hasNext(); ) {
- IMessage message = stream.next();
+ for (IMessage message : this.getValidationMessages(reporter, project)) {
// check to see if the message should be ignored based on preferences
if (!JpaValidationPreferences.isProblemIgnored(project, message.getId())){
reporter.addMessage(this, adjustMessage(message));
@@ -101,12 +97,12 @@ public class JpaValidator extends AbstractValidator implements IValidator {
return ((IProjectValidationContext) context).getProject();
}
- private Iterator<IMessage> validationMessages(IReporter reporter, IProject project) {
+ private Iterable<IMessage> getValidationMessages(IReporter reporter, IProject project) {
JpaProject jpaProject = JptCorePlugin.getJpaProject(project);
if (jpaProject != null) {
- return jpaProject.validationMessages(reporter);
+ return CollectionTools.iterable(jpaProject.validationMessages(reporter));
}
- return new SingleElementIterator<IMessage>(
+ return new SingleElementIterable<IMessage>(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
JpaValidationMessages.NO_JPA_PROJECT,
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java
index a8198e009f..e8baee5ce0 100644
--- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/DefaultEclipseLinkJpaValidationMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 Oracle. All rights reserved.
+ * Copyright (c) 2005, 2010 Oracle. All rights reserved.
* This program and the accompanying materials are 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.
@@ -40,6 +40,7 @@ public class DefaultEclipseLinkJpaValidationMessages {
public static IMessage buildMessage(
int severity, String messageId, String[] parms, Object targetObject, TextRange textRange) {
IMessage message = new EclipseLinkMessage(EclipseLinkJpaValidationMessages.BUNDLE_NAME, severity, messageId, parms, targetObject);
+ message.setMarkerId(JptCorePlugin.VALIDATION_MARKER_ID); //TODO do we need an 'EclipseLink JPA' problem marker?
if (textRange == null) {
//log an exception and then continue without setting location information
//At least the user will still get the validation message and will

Back to the top