Author: dgolovin
Date: 2011-08-24 19:07:29 -0400 (Wed, 24 Aug 2011)
New Revision: 34249
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java
Log:
code cleanup:
1. Removed null check that never works
2. Static variable initialization moved from constructor to static initialization block
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 2011-08-24
22:52:40 UTC (rev 34248)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/validation/ELValidator.java 2011-08-24
23:07:29 UTC (rev 34249)
@@ -29,6 +29,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.jboss.tools.common.el.core.ELReference;
@@ -72,6 +73,27 @@
private static final String EXTENSION_POINT_ID =
"org.jboss.tools.jst.web.kb.elValidationDelegate"; //$NON-NLS-1$
private static Set<IELValidationDelegate> DELEGATES;
+ static {
+ DELEGATES = new HashSet<IELValidationDelegate>();
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID);
+ if (extensionPoint != null) {
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ IExtension extension = extensions[i];
+ IConfigurationElement[] elements = extension.getConfigurationElements();
+ for (int j = 0; j < elements.length; j++) {
+ try {
+ IELValidationDelegate delegate = (IELValidationDelegate) elements[j]
+ .createExecutableExtension("class"); //$NON-NLS-1$
+ DELEGATES.add(delegate);
+ } catch (CoreException e) {
+ WebKbPlugin.getDefault().logError(e);
+ }
+ }
+ }
+ }
+ }
private ELResolver[] resolvers;
protected ELParserFactory mainFactory;
@@ -80,26 +102,6 @@
private boolean validateVars = true;
public ELValidator() {
- if(DELEGATES==null) {
- DELEGATES = new HashSet<IELValidationDelegate>();
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint(EXTENSION_POINT_ID);
- if (extensionPoint != null) {
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i=0; i<extensions.length; i++) {
- IExtension extension = extensions[i];
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for(int j=0; j<elements.length; j++) {
- try {
- IELValidationDelegate delegate =
(IELValidationDelegate)elements[j].createExecutableExtension("class");
//$NON-NLS-1$
- DELEGATES.add(delegate);
- } catch (CoreException e) {
- WebKbPlugin.getDefault().logError(e);
- }
- }
- }
- }
- }
}
/*
@@ -166,7 +168,7 @@
Set<IPath> unnamedResources = validationContext.getUnnamedElResources();
for (IPath path : unnamedResources) {
IFile file = wsRoot.getFile(path);
- if(file!=null && file.isAccessible() && notValidatedYet(file)) {
+ if(file.isAccessible() && notValidatedYet(file)) {
filesToValidate.add(file);
}
}
@@ -180,7 +182,7 @@
int i=0;
for (ELReference el : els) {
IResource resource = el.getResource();
- if(resource!=null && resource.isAccessible() &&
!filesToValidate.contains(resource) && notValidatedYet(resource)) {
+ if(resource.isAccessible() && !filesToValidate.contains(resource) &&
notValidatedYet(resource)) {
// Don't re-validate more than 1000 ELs.
if(i++>1000) {
break;
@@ -247,7 +249,7 @@
if(!references[i].getSyntaxErrors().isEmpty()) {
for (SyntaxError error: references[i].getSyntaxErrors()) {
markers++;
- addError(ELValidationMessages.EL_SYNTAX_ERROR,
ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{"" + error.getProblem()},
references[i].getLineNumber(), 1, references[i].getStartPosition() + error.getPosition(),
context.getResource());
+ addError(ELValidationMessages.EL_SYNTAX_ERROR,
ELSeverityPreferences.EL_SYNTAX_ERROR, new String[]{error.getProblem()},
references[i].getLineNumber(), 1, references[i].getStartPosition() + error.getPosition(),
context.getResource());
}
}
if(markers<getMaxNumberOfMarkersPerFile(file.getProject())) {
@@ -268,7 +270,6 @@
}
private void validateELExpression(ELReference elReference, ELExpression el) {
- if(el == null) return;
List<ELInvocationExpression> es = el.getInvocations();
for (ELInvocationExpression token: es) {
validateElOperand(elReference, token);
Show replies by date