use of org.eclipse.wst.validation.internal.operations.IWorkbenchContext in project webtools.sourceediting by eclipse.
the class HTMLValidator method validateFull.
/**
*/
private void validateFull(IValidationContext helper, IReporter reporter) {
IProject project = null;
String[] fileDelta = helper.getURIs();
if (helper instanceof IWorkbenchContext) {
IWorkbenchContext wbHelper = (IWorkbenchContext) helper;
project = wbHelper.getProject();
} else if (fileDelta.length > 0) {
// won't work for project validation (b/c nothing in file delta)
project = getResource(fileDelta[0]).getProject();
}
if (project == null)
return;
validateContainer(helper, reporter, project);
}
use of org.eclipse.wst.validation.internal.operations.IWorkbenchContext in project webtools.sourceediting by eclipse.
the class JsValidator method validate.
public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
/* Added by BC ---- */
// if(true) return;
/* end Added by BC ---- */
String[] uris = helper.getURIs();
if (uris.length > 0) {
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IFile currentFile = null;
for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
currentFile = wsRoot.getFile(new Path(uris[i]));
reporter.removeAllMessages(this, currentFile);
if (currentFile != null && currentFile.exists()) {
if (shouldValidate(currentFile)) {
// && fragmentCheck(currentFile)) {
int percent = (i * 100) / uris.length + 1;
// $NON-NLS-1$
IMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + uris[i]);
reporter.displaySubtask(this, message);
validateFile(currentFile, reporter);
}
if (DEBUG) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("validating: [" + uris[i] + "]");
}
}
}
} else {
// if uris[] length 0 -> validate() gets called for each project
if (helper instanceof IWorkbenchContext) {
IProject project = ((IWorkbenchContext) helper).getProject();
JSFileVisitor visitor = new JSFileVisitor(reporter);
try {
// collect all jsp files for the project
project.accept(visitor, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
if (DEBUG) {
e.printStackTrace();
}
}
IFile[] files = visitor.getFiles();
for (int i = 0; i < files.length && !reporter.isCancelled(); i++) {
int percent = (i * 100) / files.length + 1;
// $NON-NLS-1$
IMessage message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + files[i].getFullPath().toString());
reporter.displaySubtask(this, message);
validateFile(files[i], reporter);
if (DEBUG) {
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("validating: [" + files[i] + "]");
}
}
}
}
}
use of org.eclipse.wst.validation.internal.operations.IWorkbenchContext in project webtools.sourceediting by eclipse.
the class JSPValidator method validate.
public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
String[] uris = helper.getURIs();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
if (uris.length > 0) {
IFile currentFile = null;
for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
// might be called with just project path?
currentFile = wsRoot.getFile(new Path(uris[i]));
if (currentFile != null && currentFile.exists()) {
if (shouldValidate(currentFile) && fragmentCheck(currentFile)) {
Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, uris[i]);
reporter.displaySubtask(this, message);
validateFile(currentFile, reporter);
}
if (DEBUG)
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("validating: [" + uris[i] + "]");
}
}
} else {
// if uris[] length 0 -> validate() gets called for each project
if (helper instanceof IWorkbenchContext) {
IProject project = ((IWorkbenchContext) helper).getProject();
JSPFileVisitor visitor = new JSPFileVisitor(reporter);
try {
// collect all jsp files for the project
project.accept(visitor, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
if (DEBUG)
e.printStackTrace();
}
IFile[] files = visitor.getFiles();
for (int i = 0; i < files.length && !reporter.isCancelled(); i++) {
if (shouldValidate(files[i]) && fragmentCheck(files[i])) {
int percent = (i * 100) / files.length + 1;
Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, percent + "% " + files[i].getFullPath().toString());
reporter.displaySubtask(this, message);
validateFile(files[i], reporter);
}
if (DEBUG)
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("validating: [" + files[i] + "]");
}
}
}
}
use of org.eclipse.wst.validation.internal.operations.IWorkbenchContext in project webtools.sourceediting by eclipse.
the class JSPBatchValidator method doValidate.
void doValidate(IValidationContext helper, IReporter reporter) throws ValidationException {
String[] uris = helper.getURIs();
if (uris.length > 0) {
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IFile currentFile = null;
for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
currentFile = wsRoot.getFile(new Path(uris[i]));
if (currentFile != null && currentFile.exists()) {
if (shouldValidate(currentFile) && fragmentCheck(currentFile)) {
Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, currentFile.getFullPath().toString().substring(1));
reporter.displaySubtask(this, message);
validateFile(currentFile, reporter);
}
if (DEBUG)
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("validating: [" + uris[i] + "]");
}
}
} else {
// if uris[] length 0 -> validate() gets called for each project
if (helper instanceof IWorkbenchContext) {
IProject project = ((IWorkbenchContext) helper).getProject();
Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, NLS.bind(JSPCoreMessages.JSPBatchValidator_0, project.getFullPath()));
reporter.displaySubtask(this, message);
JSPFileVisitor visitor = new JSPFileVisitor(reporter);
try {
// collect all jsp files for the project
project.accept(visitor, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
if (DEBUG)
e.printStackTrace();
}
IFile[] files = visitor.getFiles();
for (int i = 0; i < files.length && !reporter.isCancelled(); i++) {
if (shouldValidate(files[i]) && fragmentCheck(files[i])) {
message = new LocalizedMessage(IMessage.LOW_SEVERITY, files[i].getFullPath().toString().substring(1));
reporter.displaySubtask(this, message);
validateFile(files[i], reporter);
}
if (DEBUG)
// $NON-NLS-1$ //$NON-NLS-2$
System.out.println("validating: [" + files[i] + "]");
}
}
}
}
use of org.eclipse.wst.validation.internal.operations.IWorkbenchContext in project webtools.sourceediting by eclipse.
the class MarkupValidator method validateV1Project.
/**
* @param helper
* @param reporter
*/
private void validateV1Project(IValidationContext helper, final IReporter reporter) {
// if uris[] length 0 -> validate() gets called for each project
if (helper instanceof IWorkbenchContext) {
IProject project = ((IWorkbenchContext) helper).getProject();
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException {
if (shouldValidate(proxy)) {
validateV1File((IFile) proxy.requestResource(), reporter);
}
return true;
}
};
try {
// collect all jsp files for the project
project.accept(visitor, IResource.DEPTH_INFINITE);
} catch (CoreException e) {
Logger.logException(e);
}
}
}
Aggregations