[jbosstools-dev] Fwd: [jbosstools-commits] JBoss Tools SVN: r5362 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation.
Max Rydahl Andersen
max.andersen at redhat.com
Wed Dec 19 10:55:46 EST 2007
> Well, I will try to be more carefull in next time.
>
> I have changed validator in this way.
thanks.
/max
> ----- Original Message -----
> From: "Max Rydahl Andersen" <max.andersen at redhat.com>
> To: "Denis Golovin" <dgolovin at exadel.com>
> Cc: <jbosstools-dev at lists.jboss.org>; <dazarov at exadel.com>
> Sent: Wednesday, December 19, 2007 11:54 AM
> Subject: Re: [jbosstools-dev] Fwd: [jbosstools-commits] JBoss Tools SVN:
> r5362 -
> trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/intern
> al/core/validation.
>
>
>> For now I would place instance of TextFileDocumentProvider class in
>> SeamValidation Helper and call it in SeamValidator.addError
>>
>> try {
>> coreHelper.getDocumentProvider().connect(target);
>>
>>
> message.setLineNo(coreHelper.getDocumentProvider().getDocument(target).getLi
> neOfOffset(offset)+1);
>> } catch (BadLocationException e) {
>> // TBD error logging
>> } catch (CoreException e) {
>> // TBD error logging }
>>
>> that means it will create at least one IDocument instance per file
>> during validation session, not for every error marker.
>
> Sounds much better yes!
>
> We need to be carefull about performance, especially in the validators!
>
> /max
>
>
>> Denis.
>>
>>
>> Max Rydahl Andersen wrote:
>>> Parsing every file when there is an error !? I find that hard to belive
>>> being a proper solution to this.
>>> It will definitly not scale - you can have hundreds even thousands of
>>> warnings and each of them parsing that file yet another time is not a
>>> good way.
>>>
>>> Is that how all other validators does it ?
>>>
>>> -max
>>>
>>> ------- Forwarded message -------
>>> From: jbosstools-commits at lists.jboss.org
>>> To: jbosstools-commits at lists.jboss.org
>>> Cc:
>>> Subject: [jbosstools-commits] JBoss Tools SVN: r5362 -
>>>
> trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/intern
> al/core/validation.
>>> Date: Tue, 18 Dec 2007 18:25:47 +0100
>>>
>>> Author: dazarov
>>> Date: 2007-12-18 12:25:47 -0500 (Tue, 18 Dec 2007)
>>> New Revision: 5362
>>>
>>> Modified:
>>>
>>>
> trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/intern
> al/core/validation/SeamValidator.java
>>> Log:
>>> http://jira.jboss.com/jira/browse/JBIDE-1489
>>>
>>> Modified:
>>>
> trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/intern
> al/core/validation/SeamValidator.java
>>> ===================================================================
>>> ---
>>>
> trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/intern
> al/core/validation/SeamValidator.java
>>> 2007-12-18 16:41:55 UTC (rev 5361)
>>> +++
>>>
> trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/intern
> al/core/validation/SeamValidator.java
>>> 2007-12-18 17:25:47 UTC (rev 5362)
>>> @@ -12,15 +12,21 @@
>>>
>>> import java.util.Set;
>>>
>>> +
>>> +import org.eclipse.core.resources.IFile;
>>> import org.eclipse.core.resources.IResource;
>>> +import org.eclipse.core.runtime.CoreException;
>>> import org.eclipse.core.runtime.IStatus;
>>> import org.eclipse.core.runtime.Status;
>>> 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.jboss.tools.common.util.FileUtil;
>>> import org.jboss.tools.seam.core.ISeamProject;
>>> import org.jboss.tools.seam.core.ISeamTextSourceReference;
>>> +import org.jboss.tools.seam.core.SeamCorePlugin;
>>> import org.jboss.tools.seam.core.SeamPreferences;
>>> +import org.eclipse.jface.text.Document;
>>>
>>> /**
>>> * Abstract implementation of ISeamvalidator
>>> @@ -71,10 +77,40 @@
>>> IMessage message = new Message(getBaseName(), messageSeverity,
>>> messageId, messageArguments, target,
>>> ISeamValidator.MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
>>> message.setLength(length);
>>> message.setOffset(offset);
>>> + int lineNumber = getLineNumber(target, offset);
>>> + if(lineNumber != 0)message.setLineNo(lineNumber);
>>> if(!ignore) {
>>> reporter.addMessage(validationManager, message);
>>> }
>>> }
>>> + + private int getLineNumber(IResource resource, int offset){
>>> + if(resource.getType() == IResource.FILE){
>>> + IFile file = (IFile)resource;
>>> + String content;
>>> + try {
>>> + if(!file.isSynchronized(IResource.DEPTH_ZERO)) {
>>> + // The resource is out of sync with the file system
>>> + // Just ignore this resource.
>>> + return 0;
>>> + }
>>> + content = FileUtil.readStream(file.getContents());
>>> + } catch (CoreException e) {
>>> + SeamCorePlugin.getPluginLog().logError(e);
>>> + return 0;
>>> + }
>>> + Document document = new Document(content);
>>> + int lineNumber=0;
>>> + try{
>>> + lineNumber = document.getLineOfOffset(offset);
>>> + return lineNumber+1;
>>> + }catch(Exception e){
>>> + SeamCorePlugin.getPluginLog().logError(e);
>>> + return 0;
>>> + }
>>> + }
>>> + return 0;
>>> + }
>>>
>>> protected void displaySubtask(String messageId) {
>>> displaySubtask(messageId, null);
>>>
>>> _______________________________________________
>>> jbosstools-commits mailing list
>>> jbosstools-commits at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/jbosstools-commits
>>>
>>>
>>>
>>
>
>
>
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the jbosstools-dev
mailing list