[146784] - 'Duplicate prefix' after switching editor input and Save As
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPDirectiveValidator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPDirectiveValidator.java
index ae2204f..1bc51ae 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPDirectiveValidator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPDirectiveValidator.java
@@ -84,11 +84,13 @@
}
public void connect(IDocument document) {
+ fDuplicatePrefixes.clear();
fDocument = document;
}
public void disconnect(IDocument document) {
fDuplicatePrefixes.clear();
+ fDocument = null;
}
/**
@@ -182,6 +184,7 @@
public void cleanup(IReporter reporter) {
super.cleanup(reporter);
fDuplicatePrefixes.clear();
+ fDocument = null;
}
private boolean isReservedPrefix(String name) {
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
index cbafcdc..eabd405 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
@@ -77,8 +77,10 @@
* @param sm
*/
private void setupAdapterFactory(IStructuredModel sm) {
- JSPTranslationAdapterFactory factory = new JSPTranslationAdapterFactory();
- sm.getFactoryRegistry().addFactory(factory);
+ if (sm.getFactoryRegistry().getFactoryFor(IJSPTranslation.class) == null) {
+ JSPTranslationAdapterFactory factory = new JSPTranslationAdapterFactory();
+ sm.getFactoryRegistry().addFactory(factory);
+ }
}
/**
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPValidator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPValidator.java
index 944f3af..bddeea5 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPValidator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPValidator.java
@@ -246,7 +246,7 @@
*
* @param sdr
* @param attrName
- * @return the ITextRegion for the attribute value of the given attribute name
+ * @return the ITextRegion for the attribute value of the given attribute name, case sensitive, null if no matching attribute is found
*/
protected ITextRegion getAttributeValueRegion(IStructuredDocumentRegion sdr, String attrName) {
ITextRegion valueRegion = null;
@@ -254,7 +254,6 @@
for (int i = 0; i < subRegions.size(); i++) {
ITextRegion subRegion = subRegions.get(i);
if(subRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME && sdr.getText(subRegion).equals(attrName)) {
-
for(int j=i; j<subRegions.size(); j++) {
subRegion = subRegions.get(j);
if(subRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java
index 27486ff..306d329 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
+ * Copyright (c) 2001, 2006 IBM Corporation and others.
* 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
@@ -279,7 +279,8 @@
// results = createAnnotations(reporter.getMessages());
results = createAnnotations(reporter.getAnnotationInfo());
reporter.removeAllMessages(fValidator);
-
+
+ fValidator.cleanup(reporter);
}
catch (Exception e) {
Logger.logException(e);
@@ -307,6 +308,7 @@
// notify that document disconnecting
((ISourceValidator)fValidator).disconnect(document);
}
+ fValidator.cleanup(getReporter());
}
super.release();
}
@@ -329,11 +331,11 @@
if (fValidator instanceof ISourceValidator) {
IncrementalReporter reporter = getReporter();
((ISourceValidator) fValidator).validate(dirtyRegion, helper, reporter);
+ // call IValidator.cleanup() during release()
// results = createAnnotations(reporter.getMessages());
results = createAnnotations(reporter.getAnnotationInfo());
reporter.removeAllMessages(fValidator);
}
-
}
catch (Exception e) {
Logger.logException(e);