Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 109578 Details for
Bug 243449
AbstractNestedValidator: setup and teardown validation is called for each file validated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
xml.core patch with state
bug243449-xml.core.txt (text/plain), 4.45 KB, created by
Amy Wu
on 2008-08-08 18:34:37 EDT
(
hide
)
Description:
xml.core patch with state
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2008-08-08 18:34:37 EDT
Size:
4.45 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.core >Index: src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java,v >retrieving revision 1.10 >diff -u -r1.10 AbstractNestedValidator.java >--- src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java 14 May 2008 12:29:43 -0000 1.10 >+++ src-validation/org/eclipse/wst/xml/core/internal/validation/core/AbstractNestedValidator.java 8 Aug 2008 22:19:53 -0000 >@@ -18,6 +18,7 @@ > import java.util.Locale; > > import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -52,6 +53,7 @@ > private final String GET_FILE = "getFile"; //$NON-NLS-1$ > private final String GET_PROJECT_FILES = "getAllFiles"; //$NON-NLS-1$ > private final String GET_INPUTSTREAM = "inputStream"; //$NON-NLS-1$ >+ private static final String XML_VALIDATOR_CONTEXT = "org.eclipse.wst.xml.core.validatorContext"; //$NON-NLS-1$ > > // Internal strings. These strings are common addition information types. > protected static final String COLUMN_NUMBER_ATTRIBUTE = "columnNumber"; //$NON-NLS-1$ >@@ -64,12 +66,25 @@ > public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor){ > ValidationResult result = new ValidationResult(); > IReporter reporter = result.getReporter(monitor); >- NestedValidatorContext nestedcontext = new NestedValidatorContext(); >- setupValidation(nestedcontext); > IFile file = null; > if (resource instanceof IFile)file = (IFile)resource; >- if (file != null)validate(file, null, result, reporter, nestedcontext); >- teardownValidation(nestedcontext); >+ if (file != null) >+ { >+ NestedValidatorContext nestedcontext = getNestedContext(state, false); >+ boolean teardownRequired = false; >+ if (nestedcontext == null) >+ { >+ // validationstart was not called, so manually setup and tear down >+ nestedcontext = getNestedContext(state, true); >+ setupValidation(nestedcontext); >+ teardownRequired = true; >+ } >+ >+ validate(file, null, result, reporter, nestedcontext); >+ >+ if (teardownRequired) >+ teardownValidation(nestedcontext); >+ } > return result; > } > >@@ -421,9 +436,60 @@ > */ > protected void addInfoToMessage (ValidationMessage validationmessage, IMessage message) > { >- // This method may be overidden by subclasses >+ // This method may be overridden by subclasses > } >- >+ >+ /** >+ * Get the nested validation context. >+ * >+ * @param state >+ * the validation state. >+ * @param create >+ * when true, a new context will be created if one is not found >+ * @return the nested validation context. >+ */ >+ protected NestedValidatorContext getNestedContext(ValidationState state, boolean create) >+ { >+ NestedValidatorContext context = null; >+ Object o = state.get(XML_VALIDATOR_CONTEXT); >+ if (o instanceof NestedValidatorContext) >+ context = (NestedValidatorContext)o; >+ else if (create) >+ { >+ context = new NestedValidatorContext(); >+ } >+ return context; >+ } >+ >+ public void validationStarting(IProject project, ValidationState state, IProgressMonitor monitor) >+ { >+ if (project != null) >+ { >+ NestedValidatorContext context = getNestedContext(state, false); >+ if (context == null) >+ { >+ context = getNestedContext(state, true); >+ setupValidation(context); >+ state.put(XML_VALIDATOR_CONTEXT, context); >+ } >+ super.validationStarting(project, state, monitor); >+ } >+ } >+ >+ public void validationFinishing(IProject project, ValidationState state, IProgressMonitor monitor) >+ { >+ if (project != null) >+ { >+ super.validationFinishing(project, state, monitor); >+ NestedValidatorContext context = getNestedContext(state, false); >+ if (context != null) >+ { >+ teardownValidation(context); >+ state.put(XML_VALIDATOR_CONTEXT, null); >+ } >+ } >+ } >+ > /** > * A localized message is a specialized type of IMessage that allows setting > * and using a localized message string for a message.
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 243449
: 109578