Determine if file has errors [message #215589] |
Tue, 17 June 2008 10:22  |
Eclipse User |
|
|
|
Is it possible to determine whether the file you have open in your editor
has errors programatically? What I would like to be able to do is to
disable a page in my editor if I determine that the file being edited has
errors in it (in this case it's an XML file, but I think it could apply to
any type). I am using a StructuredTextEditor and a FormPage as the two
pages for my editor.
|
|
|
|
|
|
Re: Determine if file has errors [message #215771 is a reply to message #215740] |
Wed, 18 June 2008 14:44  |
Eclipse User |
|
|
|
lmandel@ca.ibm.com wrote:
> 1. I haven't tried this with the new (WTP 3.0) WTP validation framework
> but it looks like you can do this by calling
> ValidationFramework.getDefault().getValidatorsFor(YourIResou rce);
> and then iterating through the validators and calling validate on each
> one. JavaDoc for the new validation framework is available in the WTP help
> centre (Help->Help Contents->Web Tools Platform User
> Guide->Reference->Validation Framework API Reference in Eclipse)
> 2. Take a look at findMarkers on IResource. This should allow you to find
> the error markers. You don't need to worry about the depth as you should
> have the IFile. You are probably interested in subtypes. For example, if I
> remember correctly there is a WSDL error subtype for WSDL errors. For
> example, you might want to make a call like
> IMarker[] problemMarkers = myIFile.findMarkers(IMarker.PROBLEM, true, 0);
>
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse. platform.doc.isv/reference/api/org/eclipse/core/resources/IR esource.html
> Lawrence Mandel
> -
> Co-author Eclipse Web Tools Platform: Developing Java Web Applications
> http://www.eclipsewtp.org
I tried method #2 as suggested by someone else on the rcp newsgroup, but
it didn't work (I think its cause my errors only show up as little red
markers on the right vertical bar, not as problem markers on the left
vertical bar like normal errors). I will give #1 a shot and let you know.
Thanks,
Philippe
|
|
|
Powered by
FUDForum. Page generated in 0.04317 seconds