[jbosstools-commits] JBoss Tools SVN: r42165 - in trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation: java and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Jun 21 20:48:47 EDT 2012
Author: akazakov
Date: 2012-06-21 20:48:46 -0400 (Thu, 21 Jun 2012)
New Revision: 42165
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java
Log:
https://issues.jboss.org/browse/JBIDE-10611 As-you-type CDI validation
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java 2012-06-22 00:33:59 UTC (rev 42164)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java 2012-06-22 00:48:46 UTC (rev 42165)
@@ -161,7 +161,7 @@
CommonPlugin.getDefault().logError(e);
}
}
- IMessage message = addMesssage(validationManager, alwaysCleanAnnotations(), this.reporter, offset, length, target, lineNumber, severity, textMessage, messageArguments, getMessageBundleName());
+ IMessage message = addMesssage(validationManager, shouldCleanAllAnnotations(), this.reporter, offset, length, target, lineNumber, severity, textMessage, messageArguments, getMessageBundleName());
String preferencePageId = getPreferencePageId();
if(preferencePageId != null && preferenceKey != null){
@@ -172,22 +172,28 @@
return message;
}
- protected boolean alwaysCleanAnnotations() {
+ /**
+ * Returns true if all the annotations belonged to this validator of entire document should be removed before start this validator again.
+ * If "false" then only annotations of the changed region should be removed.
+ * Returns "false" by default but subclasses are free to override this method.
+ * @return
+ */
+ protected boolean shouldCleanAllAnnotations() {
return false;
}
public static final String AS_YOU_TYPE_VALIDATION_ANNOTATION_ATTRIBUTE = "org.jboss.tools.common.validation.asyoutype";
- public static final String CLEAN_ALWAYS_ATTRIBUTE = "org.jboss.tools.common.validation.cleanAlways";
+ public static final String CLEAN_ALL_ANNOTATIONS_ATTRIBUTE = "org.jboss.tools.common.validation.cleanAllAnnotaions";
- private static IMessage addMesssage(IValidator validator, boolean cleanAlways, IReporter reporter, int offset, int length, IResource target, int lineNumber, int severity, String textMessage, Object[] messageArguments, String bundleName) {
+ private static IMessage addMesssage(IValidator validator, boolean cleanAllAnnotaions, IReporter reporter, int offset, int length, IResource target, int lineNumber, int severity, String textMessage, Object[] messageArguments, String bundleName) {
Message message = new ValidationMessage(severity, messageArguments!=null?MessageFormat.format(textMessage, messageArguments):textMessage, target);
message.setOffset(offset);
message.setLength(length);
message.setLineNo(lineNumber);
message.setBundleName(bundleName);
message.setAttribute(AS_YOU_TYPE_VALIDATION_ANNOTATION_ATTRIBUTE, Boolean.TRUE);
- if(cleanAlways) {
- message.setAttribute(CLEAN_ALWAYS_ATTRIBUTE, Boolean.TRUE);
+ if(cleanAllAnnotaions) {
+ message.setAttribute(CLEAN_ALL_ANNOTATIONS_ATTRIBUTE, Boolean.TRUE);
}
reporter.addMessage(validator, message);
return message;
Modified: trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java 2012-06-22 00:33:59 UTC (rev 42164)
+++ trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/java/JavaDirtyRegionProcessor.java 2012-06-22 00:48:46 UTC (rev 42165)
@@ -59,8 +59,10 @@
@SuppressWarnings("restriction")
final class JavaDirtyRegionProcessor extends
DirtyRegionProcessor {
- static Position ALWAYS_CLEARED = new Position(100000);
+ // TODO Slava what is that?
+ static final Position ALWAYS_CLEARED = new Position(100000);
+
private ITextEditor fEditor;
private IDocument fDocument;
private IValidationContext fHelper;
@@ -168,11 +170,11 @@
}
}
- public void addAnnotation(Annotation annotation, Position position, boolean cleanAlways) {
+ public void addAnnotation(Annotation annotation, Position position, boolean cleanAllAnnotations) {
if (isCancelled()) {
return;
}
- fAnnotations.put(annotation, cleanAlways ? ALWAYS_CLEARED : position);
+ fAnnotations.put(annotation, cleanAllAnnotations ? ALWAYS_CLEARED : position);
fAnnotationModel.addAnnotation(annotation, position);
}
@@ -186,13 +188,13 @@
IEditorInput editorInput= fEditor.getEditorInput();
if (editorInput != null) {
- boolean cleanAlways = Boolean.TRUE.equals(message.getAttribute(TempMarkerManager.CLEAN_ALWAYS_ATTRIBUTE));
+ boolean cleanAllAnnotations = Boolean.TRUE.equals(message.getAttribute(TempMarkerManager.CLEAN_ALL_ANNOTATIONS_ATTRIBUTE));
Position position = new Position(valMessage.getOffset(), valMessage.getLength());
CoreELProblem problem= new CoreELProblem(valMessage,
editorInput.getName());
if (fCompilationUnit != null) {
ProblemAnnotation problemAnnotation = new ProblemAnnotation(problem, fCompilationUnit);
- addAnnotation(problemAnnotation, position, cleanAlways);
+ addAnnotation(problemAnnotation, position, cleanAllAnnotations);
}
}
}
More information about the jbosstools-commits
mailing list