Author: akazakov
Date: 2012-02-14 20:50:33 -0500 (Tue, 14 Feb 2012)
New Revision: 38733
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/EditorValidationContext.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IAsYouTypeValidator.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationErrorManager.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/BuilderValidationTest.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/KBValidator.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/validation/SeamProjectPropertyValidatorWrapper.java
Log:
https://issues.jboss.org/browse/JBIDE-10738 As-you-type EL validation
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -2532,8 +2532,22 @@
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationErrorManager#getPreferencePageId()
+ */
@Override
protected String getPreferencePageId() {
return PREFERENCE_PAGE_ID;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.TempMarkerManager#getMessageBundleName()
+ */
+ @Override
+ protected String getMessageBundleName() {
+ // TODO
+ return null;
+ }
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContext.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -11,8 +11,10 @@
package org.jboss.tools.common.el.core.resolver;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.el.core.ELReference;
/**
@@ -71,4 +73,11 @@
* @param file
*/
void setResource(IFile file);
+
+ /**
+ * Returns all the EL references for the region.
+ *
+ * @return
+ */
+ Set<ELReference> getELReferences(IRegion region);
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/ELContextImpl.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -11,8 +11,11 @@
package org.jboss.tools.common.el.core.resolver;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.jboss.tools.common.el.core.ELReference;
@@ -116,4 +119,16 @@
}
return null;
}
+
+ @Override
+ public Set<ELReference> getELReferences(IRegion region) {
+ Set<ELReference> references = new HashSet<ELReference>();
+ ELReference[] refs = getELReferences();
+ for (int i = 0; i < refs.length; i++) {
+ if(refs[i].getStartPosition()>=region.getOffset() &&
(refs[i].getStartPosition() + refs[i].getLength()<=region.getOffset() +
region.getLength())) {
+ references.add(refs[i]);
+ }
+ }
+ return references;
+ }
}
\ No newline at end of file
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/resolver/SimpleELContext.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -11,9 +11,12 @@
package org.jboss.tools.common.el.core.resolver;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
import org.jboss.tools.common.el.core.ELReference;
/**
@@ -104,4 +107,9 @@
public ELReference getELReference(int offset) {
return null;
}
+
+ @Override
+ public Set<ELReference> getELReferences(IRegion region) {
+ return Collections.emptySet();
+ }
}
\ No newline at end of file
Modified: trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF 2012-02-15
00:19:29 UTC (rev 38732)
+++ trunk/common/plugins/org.jboss.tools.common.validation/META-INF/MANIFEST.MF 2012-02-15
01:50:33 UTC (rev 38733)
@@ -17,7 +17,8 @@
org.eclipse.jface;bundle-version="3.7.0",
org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.wst.validation.ui;bundle-version="1.2.204",
- org.eclipse.jdt.core;bundle-version="3.7.0"
+ org.eclipse.jdt.core;bundle-version="3.7.0",
+ org.eclipse.wst.sse.ui;bundle-version="1.3.0";visibility:=reexport
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: %providerName
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+
+/**
+ * This Manager is responsible for as-you-type validation.
+ * It's registred as WTP source validator and delegates validation to the
corresponding JBT validators.
+ * @author Alexey Kazakov
+ */
+public class AsYouTypeValidatorManager implements ISourceValidator,
org.eclipse.wst.validation.internal.provisional.core.IValidator {
+
+ private IDocument document;
+ private IFile file;
+ private EditorValidationContext context;
+ private Map<IValidator, IProject> rootProjects;
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator#connect(org.eclipse.jface.text.IDocument)
+ */
+ @Override
+ public void connect(IDocument document) {
+ this.document = document;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator#disconnect(org.eclipse.jface.text.IDocument)
+ */
+ @Override
+ public void disconnect(IDocument document) {
+ context = null;
+ }
+
+ private boolean init(IValidationContext helper, IReporter reporter) {
+ if(context==null) {
+ String[] uris = helper.getURIs();
+ if(uris.length==0) {
+ return false;
+ }
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ file = root.getFile(new Path(uris[0]));
+ if(!file.isAccessible()) {
+ return false;
+ }
+ context = new EditorValidationContext(file.getProject(), document);
+ if(context.getValidators().isEmpty()) {
+ return false;
+ }
+ rootProjects = new HashMap<IValidator, IProject>();
+ for (IValidator validator : context.getValidators()) {
+ Map<IProject, IValidatingProjectSet> projectTree =
context.getValidatingProjectTree(validator).getBrunches();
+ if(!projectTree.isEmpty()) {
+ IProject rootProject = projectTree.keySet().iterator().next();
+ rootProjects.put(validator, rootProject);
+ }
+ }
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator#validate(org.eclipse.jface.text.IRegion,
org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ @Override
+ public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter)
{
+ if(!init(helper, reporter)) {
+ return;
+ }
+ for (IValidator validator : context.getValidators()) {
+ IProject rootProject = rootProjects.get(validator);
+ IValidatingProjectSet projectBrunch =
context.getValidatingProjectTree(validator).getBrunches().get(rootProject);
+ if(projectBrunch!=null) {
+ ((IAsYouTypeValidator)validator).validate(this, rootProject, dirtyRegion, helper,
reporter, context, projectBrunch.getRootContext(), file);
+ }
+ }
+// reporter.removeAllMessages(this, file);
+ }
+
+ @Override
+ public void cleanup(IReporter reporter) {
+ }
+
+ @Override
+ public void validate(IValidationContext helper, IReporter reporter) throws
ValidationException {
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/AsYouTypeValidatorManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/EditorValidationContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/EditorValidationContext.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/EditorValidationContext.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * Validation context used in as-you-type validation.
+ * @author Alexey Kazakov
+ */
+public class EditorValidationContext extends ValidationContext {
+
+ private IDocument document;
+
+ public EditorValidationContext(IProject project, IDocument document) {
+ super(project);
+ this.document = document;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.ValidationContext#shouldValidate(org.jboss.tools.common.validation.IValidator,
org.eclipse.core.resources.IProject)
+ */
+ @Override
+ protected boolean shouldValidate(IValidator validator, IProject project) {
+ return validator instanceof IAsYouTypeValidator &&
super.shouldValidate(validator, project);
+ }
+
+ /**
+ * @return the document
+ */
+ public IDocument getDocument() {
+ return document;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/EditorValidationContext.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IAsYouTypeValidator.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IAsYouTypeValidator.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IAsYouTypeValidator.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+import org.eclipse.wst.validation.internal.provisional.core.IValidator;
+
+/**
+ * Interface to allow for "partial document" as you type validation.
+ * @author Alexey Kazakov
+ */
+public interface IAsYouTypeValidator {
+
+ /**
+ * Validates the region.
+ * @param validatorManager
+ * @param rootProject
+ * @param dirtyRegion
+ * @param helper
+ * @param reporter
+ * @param validationContext
+ * @param projectContext
+ * @param file
+ */
+ void validate(IValidator validatorManager, IProject rootProject, IRegion dirtyRegion,
IValidationContext helper, IReporter reporter, EditorValidationContext validationContext,
IProjectValidationContext projectContext, IFile file);
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IAsYouTypeValidator.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationErrorManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationErrorManager.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/IValidationErrorManager.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -25,7 +25,7 @@
public interface IValidationErrorManager {
/**
- * inits validator error manager
+ * Inits validator error manager
* @param project
* @param validationHelper
* @param manager
@@ -34,6 +34,17 @@
void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, IValidator manager, IReporter reporter);
/**
+ * Inits validator error manager
+ * @param project
+ * @param validationHelper
+ * @param validationContext
+ * @param manager
+ * @param reporter
+ * @param asYouTypeValidation
+ */
+ void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, IValidator manager, IReporter reporter,
boolean asYouTypeValidation);
+
+ /**
* Adds a marker to the resource
* @param message
* @param preferenceKey
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.validation;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.wst.validation.internal.core.Message;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidator;
+import org.jboss.tools.common.CommonPlugin;
+import org.jboss.tools.common.text.ITextSourceReference;
+
+/**
+ * @author Alexey Kazakov
+ */
+abstract public class TempMarkerManager extends ValidationErrorManager {
+
+ protected abstract String getMessageBundleName();
+
+ public IMessage addMesssage(IFile target, ITextSourceReference location, String
preferenceKey, String textMessage, String[] messageArguments) {
+ return addMesssage(target, -1, location, preferenceKey, textMessage,
messageArguments);
+ }
+
+ public IMessage addMesssage(IFile target, int lineNumber, ITextSourceReference location,
String preferenceKey, String textMessage, String[] messageArguments) {
+ int severity = getSeverity(preferenceKey, target);
+ IMessage message = null;
+ try {
+ if(severity!=-1 && (severity!=IMessage.NORMAL_SEVERITY ||
!hasSuppressWarningsAnnotation(preferenceKey, location))) {
+ message = addMesssage(target, lineNumber, location.getStartPosition(),
location.getLength(), severity, preferenceKey, textMessage, messageArguments);
+ }
+ } catch (JavaModelException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ return message;
+ }
+
+ public IMessage addMesssage(IFile target, int offset, int length, String
preferenceKey, String message, String[] messageArguments) {
+ return addMesssage(target, -1, offset, length, preferenceKey, message,
messageArguments);
+ }
+
+ public IMessage addMesssage(IFile target, int lineNumber, int offset, int length, String
preferenceKey, String message, String[] messageArguments) {
+ int severity = getSeverity(preferenceKey, target);
+ return severity!=-1?addMesssage(target, lineNumber, offset, length, severity,
preferenceKey, message, messageArguments):null;
+ }
+
+ private IMessage addMesssage(IFile target, int lineNumber, int offset, int length, int
severity, String preferenceKey, String textMessage, String[] messageArguments) {
+ if(lineNumber<0) {
+ try {
+ lineNumber = document.getLineOfOffset(offset) + 1;
+ } catch (BadLocationException e) {
+ CommonPlugin.getDefault().logError(e);
+ }
+ }
+ IMessage message = addMesssage(validationManager, this.reporter, offset, length,
target, lineNumber, severity, textMessage, messageArguments, getMessageBundleName());
+ return message;
+ }
+
+ private static IMessage addMesssage(IValidator validator, IReporter reporter, int
offset, int length, IFile file, int lineNumber, int severity, String textMessage, Object[]
messageArguments, String bundleName) {
+ Message message = new ValidationMessage(severity, MessageFormat.format(textMessage,
messageArguments), file);
+ message.setOffset(offset);
+ message.setLength(length);
+ message.setLineNo(lineNumber);
+ message.setBundleName(bundleName);
+ reporter.addMessage(validator, message);
+ return message;
+ }
+
+ static class ValidationMessage extends Message {
+
+ private String message;
+
+ public ValidationMessage(int severity, String message, IFile file) {
+ super(CommonPlugin.PLUGIN_ID, severity, message, null, file);
+ this.message = message;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.wst.validation.internal.core.Message#getText(java.util.Locale,
java.lang.ClassLoader)
+ */
+ @Override
+ public java.lang.String getText(Locale locale, ClassLoader classLoader) {
+ return message;
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/TempMarkerManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationContext.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -62,7 +62,7 @@
}
}
- public void init(IProject project) {
+ protected List<IValidator> getAllValidators(IProject project) {
projectTree.clear();
validators.clear();
validationResourceRegister = null;
@@ -86,10 +86,14 @@
}
// We should add all the dependent validators (e.g. EL validator) to the very end of
the list.
allValidators.addAll(dependentValidators);
+ return allValidators;
+ }
+ public void init(IProject project) {
+ List<IValidator> allValidators = getAllValidators(project);
// Init context for given project.
for (IValidator validator : allValidators) {
- if(validator.shouldValidate(project)) {
+ if(shouldValidate(validator, project)) {
IValidatingProjectTree prTree = validator.getValidatingProjects(project);
if(prTree!=null) {
validators.add(validator);
@@ -99,6 +103,10 @@
}
}
+ protected boolean shouldValidate(IValidator validator, IProject project) {
+ return validator.shouldValidate(project);
+ }
+
/*
* (non-Javadoc)
* @see org.jboss.tools.jst.web.kb.validation.IValidationContextManager#isObsolete()
Modified:
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/common/plugins/org.jboss.tools.common.validation/src/org/jboss/tools/common/validation/ValidationErrorManager.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -63,6 +63,7 @@
protected String markerId;
protected IProjectValidationContext validationContext;
protected TextFileDocumentProvider documentProvider;
+ protected IDocument document;
protected Set<IFile> dirtyFiles;
private String messageIdQuickFixAttributeName;
@@ -83,9 +84,17 @@
/*
* (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.IValidationErrorManager#init(org.eclipse.core.resources.IProject,
org.jboss.tools.common.validation.ContextValidationHelper,
org.jboss.tools.common.validation.IProjectValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IValidator,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
+ */
+ public void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, IValidator manager, IReporter reporter) {
+ init(project, validationHelper, validationContext, manager, reporter, false);
+ }
+
+ /*
+ * (non-Javadoc)
* @see
org.jboss.tools.jst.web.kb.validation.IValidationErrorManager#init(org.eclipse.core.resources.IProject,
org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
org.jboss.tools.jst.web.kb.validation.IProjectValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IValidator,
org.eclipse.wst.validation.internal.provisional.core.IReporter)
*/
- public void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, IValidator manager, IReporter reporter) {
+ public void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, IValidator manager, IReporter reporter,
boolean asYouTypeValidation) {
cleanSavedMarkers();
setProject(project);
setCoreHelper(validationHelper);
@@ -93,14 +102,9 @@
setReporter(reporter);
setValidationContext(validationContext);
setMarkerId(org.jboss.tools.common.validation.IValidator.MARKED_RESOURCE_MESSAGE_GROUP);
- dirtyFiles = EclipseUIUtil.getDirtyFiles();
+ dirtyFiles = asYouTypeValidation?new
HashSet<IFile>():EclipseUIUtil.getDirtyFiles();
}
- public void init(IProject project, ContextValidationHelper validationHelper,
IProjectValidationContext validationContext, IValidator manager, IReporter reporter,
String messageIdQuickFixAttributeName) {
- this.init(project, validationHelper, validationContext, manager, reporter);
- setMessageIdQuickFixAttributeName(messageIdQuickFixAttributeName);
- }
-
protected boolean shouldBeValidated(IFile file) {
return file.isAccessible() && !dirtyFiles.contains(file);
}
@@ -235,7 +239,7 @@
return false;
}
- private static boolean hasSuppressWarningsAnnotation(String preferenceKey,
ITextSourceReference location) throws JavaModelException {
+ protected static boolean hasSuppressWarningsAnnotation(String preferenceKey,
ITextSourceReference location) throws JavaModelException {
boolean result = false;
if(location instanceof IJavaSourceReference) {
IJavaElement element = ((IJavaSourceReference) location).getSourceElement();
@@ -332,7 +336,7 @@
abstract protected String getPreferencePageId();
- private int getSeverity(String preferenceKey, IResource target) {
+ protected int getSeverity(String preferenceKey, IResource target) {
String preferenceValue = getPreference(target.getProject(), preferenceKey);
int severity = -1;
if (!SeverityPreferences.IGNORE.equals(preferenceValue)) {
@@ -363,7 +367,6 @@
marker.setAttribute(PREFERENCE_KEY_ATTRIBUTE_NAME, preferenceKey);
marker.setAttribute(PREFERENCE_PAGE_ID_NAME, preferencePageId);
}
-
}
} catch(CoreException e) {
CommonPlugin.getDefault().logError(e);
@@ -434,7 +437,7 @@
connected = true;
documentProvider.connect(target);
IDocument doc = documentProvider.getDocument(target);
- if(doc != null){
+ if(doc != null) {
try {
lineNumber = doc.getLineOfOffset(offset) + 1;
} catch (BadLocationException e) {
@@ -495,6 +498,13 @@
* @return
*/
public IMarker addError(String message, int severity, Object[] messageArguments, int
lineNumber, int length, int offset, IResource target, TextFileDocumentProvider
documentProvider, String markerId, Class markerOwner) {
+ if(document != null && lineNumber < 0) {
+ try {
+ lineNumber = document.getLineOfOffset(offset) + 1;
+ } catch (BadLocationException e) {
+ CommonPlugin.getDefault().logError("Wrong offset [" + offset + "] of
the problem marker [" + MessageFormat.format(message, messageArguments) + "]
for resource: " + target.getFullPath().toOSString(), e); //$NON-NLS-1$
//$NON-NLS-2$//$NON-NLS-3$
+ }
+ }
return addError(message, severity, messageArguments, lineNumber, length, offset,
target, documentProvider, markerId, markerOwner,
getMaxNumberOfMarkersPerFile(target.getProject()), getMarkerType());
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/validation/composite/CompositeComponentValidator.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -379,8 +379,22 @@
return false;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationErrorManager#getPreferencePageId()
+ */
@Override
protected String getPreferencePageId() {
return PREFERENCE_PAGE_ID;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.TempMarkerManager#getMessageBundleName()
+ */
+ @Override
+ protected String getMessageBundleName() {
+ // TODO
+ return null;
+ }
}
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/BuilderValidationTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/BuilderValidationTest.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/validation/BuilderValidationTest.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -33,7 +33,7 @@
/**
* See
https://issues.jboss.org/browse/JBIDE-10872
- * EL incremental validation doesnt work for complex ELs.
+ * EL incremental validation doesn't work for complex ELs.
* @throws Exception
*/
public void testFullBuildValidation() throws Exception {
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageContextFactory.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -167,9 +167,13 @@
* @return
*/
public static ELContext createPageContext(IDocument document) {
- return createPageContext(document, null);
+ return createPageContext(document, null, false);
}
+ public static ELContext createPageContext(IDocument document, boolean dontUseCache) {
+ return createPageContext(document, null, dontUseCache);
+ }
+
/**
* Creates a page context for the specified context document
*
@@ -178,9 +182,13 @@
* @return
*/
public static ELContext createPageContext(IDocument document, String contextType) {
- return createPageContext(document, null, contextType);
+ return createPageContext(document, null, contextType, false);
}
+ public static ELContext createPageContext(IDocument document, String contextType,
boolean dontUseCache) {
+ return createPageContext(document, null, contextType, dontUseCache);
+ }
+
/**
* Creates a page context for the specified context file
*
@@ -211,9 +219,13 @@
* @return
*/
public static ELContext createPageContext(IDocument document, IFile file, String
contextType) {
- return getInstance().createPageContext(document, file, new ArrayList<String>(),
contextType);
+ return getInstance().createPageContext(document, file, new ArrayList<String>(),
contextType, false);
}
+ public static ELContext createPageContext(IDocument document, IFile file, String
contextType, boolean dontUseCache) {
+ return getInstance().createPageContext(document, file, new ArrayList<String>(),
contextType, dontUseCache);
+ }
+
/**
* Cleans up the context for the file specified
*
@@ -341,15 +353,16 @@
* @param parents List of parent contexts
* @return
*/
- private ELContext createPageContext(IDocument document, IFile file, List<String>
parents, String defaultContextType) {
- if (file == null)
+ private ELContext createPageContext(IDocument document, IFile file, List<String>
parents, String defaultContextType, boolean dontUseCache) {
+ if (file == null) {
file = getResource(document);
-
- boolean isContextCachingAllowed = !EclipseUIUtil.isOpenInActiveEditor(file);
+ }
+
+ boolean isContextCachingAllowed = !dontUseCache &&
!EclipseUIUtil.isOpenInActiveEditor(file);
ELContext context = isContextCachingAllowed ? getSavedContext(file) : null;
if (context == null) {
String typeId = getContentTypeIdentifier(file == null ? document : file);
-
+
if(JavaCore.JAVA_SOURCE_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
context = createJavaContext(file);
} else if(JAVA_PROPERTIES_CONTENT_TYPE.equalsIgnoreCase(typeId)) {
@@ -401,14 +414,14 @@
}
}
}
-
- if (context != null && isContextCachingAllowed) {
- saveConvext(context);
+
+ if (context != null) { // && isContextCachingAllowed) { <- Save context
even for modified files to prevent multiple initialization when invoked from NON-UI
thread.
+ saveConvext(context);
}
}
return context;
}
-
+
private static IProject getActiveProject() {
ITextEditor editor = EclipseUIUtil.getActiveEditor();
if (editor == null) return null;
@@ -656,7 +669,7 @@
if (fileName != null && !fileName.trim().isEmpty()) {
IFile file = getFileFromProject(fileName, context.getResource());
if (file != null && checkCycling(parents, file)) { // checkCycling is to
fix for JBIDE-5083
- ELContext includedContext = createPageContext(null, file, newParentList, null);
+ ELContext includedContext = createPageContext(null, file, newParentList, null,
false);
if (includedContext != null)
((IIncludedContextSupport)context).addIncludedContext(includedContext);
}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -32,8 +32,11 @@
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
+import org.eclipse.wst.validation.internal.provisional.core.IValidator;
import org.jboss.tools.common.CommonPlugin;
import org.jboss.tools.common.EclipseUtil;
import org.jboss.tools.common.el.core.ELReference;
@@ -57,6 +60,8 @@
import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.common.java.IJavaSourceReference;
import org.jboss.tools.common.validation.ContextValidationHelper;
+import org.jboss.tools.common.validation.EditorValidationContext;
+import org.jboss.tools.common.validation.IAsYouTypeValidator;
import org.jboss.tools.common.validation.IELValidationDelegate;
import org.jboss.tools.common.validation.IProjectValidationContext;
import org.jboss.tools.common.validation.IValidatingProjectTree;
@@ -70,7 +75,7 @@
* EL Validator
* @author Alexey Kazakov
*/
-public class ELValidator extends WebValidator {
+public class ELValidator extends WebValidator implements IAsYouTypeValidator {
public static final String ID = "org.jboss.tools.jst.web.kb.ELValidator";
//$NON-NLS-1$
public static final String PROBLEM_TYPE =
"org.jboss.tools.jst.web.kb.elproblem"; //$NON-NLS-1$
@@ -202,7 +207,7 @@
validateFile(file);
}
for (ELReference el : elsToValidate) {
- validateEL(el);
+ validateEL(el, false, null);
coreHelper.getValidationContextManager().addValidatedProject(this,
el.getResource().getProject());
}
@@ -239,6 +244,21 @@
return OK_STATUS;
}
+ /*
+ * (non-Javadoc)
+ * @see
org.jboss.tools.common.validation.IAsYouTypeValidator#validate(org.eclipse.core.resources.IProject,
org.eclipse.jface.text.IRegion,
org.eclipse.wst.validation.internal.provisional.core.IValidationContext,
org.eclipse.wst.validation.internal.provisional.core.IReporter,
org.jboss.tools.common.validation.EditorValidationContext,
org.eclipse.core.resources.IFile)
+ */
+ @Override
+ public void validate(IValidator validatorManager, IProject rootProject, IRegion
dirtyRegion, IValidationContext helper, IReporter reporter, EditorValidationContext
validationContext, IProjectValidationContext projectContext, IFile file) {
+ init(rootProject, null, projectContext, validatorManager, reporter);
+ this.document = validationContext.getDocument();
+ ELContext elContext =
PageContextFactory.createPageContext(validationContext.getDocument(), true);
+ Set<ELReference> references = elContext.getELReferences(dirtyRegion);
+ for (ELReference elReference : references) {
+ validateEL(elReference, true, elContext);
+ }
+ }
+
private int markers;
private void validateFile(IFile file) {
@@ -253,42 +273,52 @@
if(context!=null) {
ELReference[] references = context.getELReferences();
for (int i = 0; i < references.length; i++) {
- if(!references[i].getSyntaxErrors().isEmpty()) {
- for (SyntaxError error: references[i].getSyntaxErrors()) {
- markers++;
- IJavaSourceReference reference = getJavaReference(file,
references[i].getStartPosition() + error.getPosition(), 1);
- if(reference == null) {
- addError(ELValidationMessages.EL_SYNTAX_ERROR,
ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()},
references[i].getLineNumber(), 1, references[i].getStartPosition() + error.getPosition(),
context.getResource());
- } else {
- addError(ELValidationMessages.EL_SYNTAX_ERROR,
ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()}, reference,
context.getResource());
- }
- }
- }
if(markers<getMaxNumberOfMarkersPerFile(file.getProject())) {
- validateEL(references[i]);
+ validateEL(references[i], false, context);
}
}
}
}
- private void validateEL(ELReference el) {
- if(!reporter.isCancelled() && shouldBeValidated(el.getResource())) {
+ private void validateEL(ELReference el, boolean asYouType, ELContext context) {
+ if(asYouType || (!reporter.isCancelled() &&
shouldBeValidated(el.getResource()))) {
displaySubtask(ELValidationMessages.VALIDATING_EL_FILE, new
String[]{el.getResource().getProject().getName(), el.getResource().getName()});
- el.deleteMarkers();
+ if(!asYouType) {
+ el.deleteMarkers();
+ }
+ if(context!=null && !el.getSyntaxErrors().isEmpty()) {
+ for (SyntaxError error: el.getSyntaxErrors()) {
+ markers++;
+ IJavaSourceReference reference = getJavaReference(el.getResource(),
el.getStartPosition() + error.getPosition(), 1);
+ if(reference == null) {
+ if(asYouType) {
+ addMesssage(el.getResource(), el.getStartPosition() + error.getPosition(), 1,
ELSeverityPreferences.EL_SYNTAX_ERROR, ELValidationMessages.EL_SYNTAX_ERROR, new
String[]{error.getProblem()});
+ } else {
+ addError(ELValidationMessages.EL_SYNTAX_ERROR,
ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()},
el.getLineNumber(), 1, el.getStartPosition() + error.getPosition(),
context.getResource());
+ }
+ } else {
+ if(asYouType) {
+ addMesssage(el.getResource(), reference, ELSeverityPreferences.EL_SYNTAX_ERROR,
ELValidationMessages.EL_SYNTAX_ERROR, new String[]{error.getProblem()});
+ } else {
+ addError(ELValidationMessages.EL_SYNTAX_ERROR,
ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()}, reference,
context.getResource());
+ }
+ }
+ }
+ }
for (ELExpression expresion : el.getEl()) {
- validateELExpression(el, expresion);
+ validateELExpression(el, expresion, asYouType, context);
}
}
}
- private void validateELExpression(ELReference elReference, ELExpression el) {
+ private void validateELExpression(ELReference elReference, ELExpression el, boolean
asYouType, ELContext context) {
List<ELInvocationExpression> es = el.getInvocations();
for (ELInvocationExpression token: es) {
- validateElOperand(elReference, token);
+ validateElOperand(elReference, token, asYouType, context);
}
}
- private void validateElOperand(ELReference elReference, ELInvocationExpression
operandToken) {
+ private void validateElOperand(ELReference elReference, ELInvocationExpression
operandToken, boolean asYouType, ELContext context) {
IFile file = elReference.getResource();
int documnetOffset = elReference.getStartPosition();
String operand = operandToken.getText();
@@ -300,8 +330,10 @@
int lengthOfVarName = varName.length();
boolean unresolvedTokenIsVariable = false;
ELResolution resolution = null;
- ELContext context = PageContextFactory.createPageContext(file);
if(context==null) {
+ context = PageContextFactory.createPageContext(file);
+ }
+ if(context==null) {
context = new SimpleELContext();
context.setResource(file);
context.setElResolvers(resolvers);
@@ -320,17 +352,13 @@
if(elResolution==null) {
continue;
}
-// ELSegment previousSegment = null;
- for (ELSegment segment : elResolution.getSegments()) {
- IResource resource = segment.getResource();
- if(resource instanceof IFile) {
- validationContext.addLinkedEl(resource.getFullPath().toString(), elReference);
-// if(!segment.isResolved() && previousSegment!=null &&
previousSegment.isResolved() && previousSegment instanceof JavaMemberELSegment) {
-// IJavaElement element = ((JavaMemberELSegment)previousSegment).getJavaElement();
-// element
-// }
+ if(!asYouType) {
+ for (ELSegment segment : elResolution.getSegments()) {
+ IResource resource = segment.getResource();
+ if(resource instanceof IFile) {
+ validationContext.addLinkedEl(resource.getFullPath().toString(), elReference);
+ }
}
-// previousSegment = segment;
}
if(elResolution.isResolved()) {
resolution = elResolution;
@@ -350,10 +378,12 @@
if(resolution==null) {
return;
}
- if(!resolution.isResolved()) {
- Set<String> names = findVariableNames(operandToken);
- for (String name : names) {
- validationContext.addLinkedEl(name, elReference);
+ if(!asYouType) {
+ if(!resolution.isResolved()) {
+ Set<String> names = findVariableNames(operandToken);
+ for (String name : names) {
+ validationContext.addLinkedEl(name, elReference);
+ }
}
}
@@ -387,11 +417,19 @@
IJavaSourceReference reference = getJavaReference(file, startPosition, length);
IMarker marker = null;
if(reference != null) {
- marker = addError(ELValidationMessages.UNPAIRED_GETTER_OR_SETTER,
ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName}, reference, file);
- elReference.addMarker(marker);
+ if(asYouType) {
+ addMesssage(file, reference, ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER,
ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName});
+ } else {
+ marker = addError(ELValidationMessages.UNPAIRED_GETTER_OR_SETTER,
ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName}, reference, file);
+ elReference.addMarker(marker);
+ }
} else {
- marker = addError(ELValidationMessages.UNPAIRED_GETTER_OR_SETTER,
ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName}, elReference.getLineNumber(), length, startPosition,
file);
- elReference.addMarker(marker);
+ if(asYouType) {
+ addMesssage(file, startPosition, length,
ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER,
ELValidationMessages.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName});
+ } else {
+ marker = addError(ELValidationMessages.UNPAIRED_GETTER_OR_SETTER,
ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, new String[]{propertyName,
existedMethodName, missingMethodName}, elReference.getLineNumber(), length, startPosition,
file);
+ elReference.addMarker(marker);
+ }
}
if(marker!=null) {
markers++;
@@ -399,9 +437,11 @@
}
}
}
- // Save links between resource and used variables names
- for(IVariable variable: usedVariables) {
- validationContext.addLinkedEl(variable.getName(), elReference);
+ if(!asYouType) {
+ // Save links between resource and used variables names
+ for(IVariable variable: usedVariables) {
+ validationContext.addLinkedEl(variable.getName(), elReference);
+ }
}
if (resolution.isResolved() || !resolution.isValidatable()) {
@@ -425,26 +465,35 @@
if(usedVariables.isEmpty()) {
unresolvedTokenIsVariable = true;
}
- IJavaSourceReference reference = getJavaReference(file, offsetOfVarName,
lengthOfVarName);
+ IJavaSourceReference javaReference = getJavaReference(file, offsetOfVarName,
lengthOfVarName);
IMarker marker = null;
// Mark invalid EL
+
+ String message = ELValidationMessages.UNKNOWN_EL_VARIABLE_PROPERTY_NAME;
+ String preference = ELSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME;
if(unresolvedTokenIsVariable) {
- if(reference == null) {
- marker = addError(ELValidationMessages.UNKNOWN_EL_VARIABLE_NAME,
ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, new String[]{varName},
elReference.getLineNumber(), lengthOfVarName, offsetOfVarName, file);
+ message = ELValidationMessages.UNKNOWN_EL_VARIABLE_NAME;
+ preference = ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME;
+ }
+ if(javaReference == null) {
+ if(asYouType) {
+ addMesssage(file, offsetOfVarName, lengthOfVarName, preference, message, new
String[]{varName});
} else {
- marker = addError(ELValidationMessages.UNKNOWN_EL_VARIABLE_NAME,
ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, new String[]{varName}, reference, file);
+ marker = addError(message, preference, new String[]{varName},
elReference.getLineNumber(), lengthOfVarName, offsetOfVarName, file);
}
} else {
- if(reference == null) {
- marker = addError(ELValidationMessages.UNKNOWN_EL_VARIABLE_PROPERTY_NAME,
ELSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, new String[]{varName},
elReference.getLineNumber(), lengthOfVarName, offsetOfVarName, file);
+ if(asYouType) {
+ addMesssage(file, javaReference, preference, message, new String[]{varName});
} else {
- marker = addError(ELValidationMessages.UNKNOWN_EL_VARIABLE_PROPERTY_NAME,
ELSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, new String[]{varName}, reference,
file);
+ marker = addError(message, preference, new String[]{varName}, javaReference, file);
}
}
if(marker != null) {
- elReference.addMarker(marker);
+ if(!asYouType) {
+ elReference.addMarker(marker);
+ }
markers++;
}
}
@@ -573,8 +622,23 @@
return true;
}
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.ValidationErrorManager#getPreferencePageId()
+ */
@Override
protected String getPreferencePageId() {
return PREFERENCE_PAGE_ID;
}
+
+ private static final String BUNDLE_NAME =
"org.jboss.tools.jst.web.kb.internal.validation.messages";
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.common.validation.TempMarkerManager#getMessageBundleName()
+ */
+ @Override
+ protected String getMessageBundleName() {
+ return BUNDLE_NAME;
+ }
}
\ No newline at end of file
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/KBValidator.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/KBValidator.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/KBValidator.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -29,7 +29,7 @@
import org.jboss.tools.common.validation.IValidatingProjectSet;
import org.jboss.tools.common.validation.IValidatingProjectTree;
import org.jboss.tools.common.validation.IValidator;
-import org.jboss.tools.common.validation.ValidationErrorManager;
+import org.jboss.tools.common.validation.TempMarkerManager;
import org.jboss.tools.common.validation.internal.SimpleValidatingProjectTree;
import org.jboss.tools.common.validation.internal.ValidatingProjectSet;
import org.jboss.tools.jst.web.kb.IKbProject;
@@ -39,7 +39,7 @@
/**
* @author Alexey Kazakov
*/
-public abstract class KBValidator extends ValidationErrorManager implements IValidator {
+public abstract class KBValidator extends TempMarkerManager implements IValidator {
protected boolean notValidatedYet(IResource resource) {
IProject pr = resource.getProject();
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/validation/SeamProjectPropertyValidatorWrapper.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/validation/SeamProjectPropertyValidatorWrapper.java 2012-02-15
00:19:29 UTC (rev 38732)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/validation/SeamProjectPropertyValidatorWrapper.java 2012-02-15
01:50:33 UTC (rev 38733)
@@ -205,4 +205,14 @@
support.add(marker);
return marker;
}
+
+ @Override
+ public void init(
+ IProject project,
+ ContextValidationHelper validationHelper,
+ IProjectValidationContext validationContext,
+ org.eclipse.wst.validation.internal.provisional.core.IValidator manager,
+ IReporter reporter, boolean asYouTypeValidation) {
+ this.init(project, validationHelper, validationContext, manager, reporter, false);
+ }
}
\ No newline at end of file