Adding Tasks to the TaskList using TODO [message #318820] |
Tue, 07 August 2007 09:41  |
Eclipse User |
|
|
|
Hi,
I'm creating an editor plug-in for Eclipse and I's wish to have the same
TODO behavior as in the standard Java editor. So far, I've found out
how to add Tasks using the IResource#createMarker(...) method. I've
also found out that I should be using a RuleBasedScanner on my editor
that uses a PatternRule (so far I've been trying to work with an
EndOfLineRule). So all of this seems to work fine with most of my
rules. But I'm having some trouble with the TODO rule. Since the
pattern must be
// [Some character]* TODO [Some character]* \n
I've tried working with a "//" startSequence. I'm having quite a lot of
trouble finding the TODO part though. Since sequenceDetected uses a
scanner, the only way I found of doing the work would be to advance
character by character and try to find either the endOfLineDelimiter or
the TODO sequence. But I got the feeling there must be an easier and
more effective way to do this.
Any ideas?
|
|
|
|
Re: Adding Tasks to the TaskList using TODO [message #318885 is a reply to message #318837] |
Wed, 08 August 2007 11:12   |
Eclipse User |
|
|
|
Ok I found something for the file problem. I ended up getting the
editor's file when creating the scanner and using it. I'm still having
lots of problems though, mostly with handling the refresh of my TODOs.
What I do is that whenever I want to create a marker, I check if there
is already a marker on this line and update it if there is. Here's the
problem : If I have a TODO on, say, line 24 and then add a new method
starting at line 24 and add a TODO at the top, I then have a new Marker
to add on line 24. Since I didn't save or anything, the old Marker is
still considered to be on line 24 and I end up overwriting this one
instead so I don't have any markers on line, say, 40 where the old
marker is now. And since it only refreshes the lines that have been
modified, I get no new Marker for the old one.
Also, I ended up just changing the TODO rule to :
// (' ')* TODO [Some character]* \n
instead. So the TODO tag must be at the beginning of the comment,
preceded only by a number of spaces.
I can't stop thinking that the initial idea of using the scanner and
rules wasn't the right thing to do. But I couldn't find anything better.
I also couldn't find the way that the TODO mechanisms were done inside
of eclipse (couldn't quite find my way through the sea of code on the
CVS server).
Does anyone know a better way or knows how it works inside Eclipse?
Just knowing where that code is in Eclipse would help a lot too.
Thanks a lot!
Franck Dubé wrote:
> Hi again,
>
> I'm also having some problems getting the file that is currently being
> checked. The scanner uses an IDocument and I can't seem to be able to
> find the file path.
>
> Any help on this would be much appreciated,
> Thanks!
>
>
> Franck Dubé wrote:
>> Hi,
>>
>> I'm creating an editor plug-in for Eclipse and I's wish to have the
>> same TODO behavior as in the standard Java editor. So far, I've found
>> out how to add Tasks using the IResource#createMarker(...) method.
>> I've also found out that I should be using a RuleBasedScanner on my
>> editor that uses a PatternRule (so far I've been trying to work with
>> an EndOfLineRule). So all of this seems to work fine with most of my
>> rules. But I'm having some trouble with the TODO rule. Since the
>> pattern must be
>> // [Some character]* TODO [Some character]* \n
>> I've tried working with a "//" startSequence. I'm having quite a lot
>> of trouble finding the TODO part though. Since sequenceDetected uses
>> a scanner, the only way I found of doing the work would be to advance
>> character by character and try to find either the endOfLineDelimiter
>> or the TODO sequence. But I got the feeling there must be an easier
>> and more effective way to do this.
>>
>> Any ideas?
|
|
|
Re: Adding Tasks to the TaskList using TODO [message #318903 is a reply to message #318885] |
Wed, 08 August 2007 16:12   |
Eclipse User |
|
|
|
Well, I ended up doing the check in the performSave method of the editor
instead of using a scanner. I still don't feel this is the best
solution though. If anyone has any other idea, please go ahead and
speak your mind!
Thanks.
Franck Dubé wrote:
> Ok I found something for the file problem. I ended up getting the
> editor's file when creating the scanner and using it. I'm still having
> lots of problems though, mostly with handling the refresh of my TODOs.
> What I do is that whenever I want to create a marker, I check if there
> is already a marker on this line and update it if there is. Here's the
> problem : If I have a TODO on, say, line 24 and then add a new method
> starting at line 24 and add a TODO at the top, I then have a new Marker
> to add on line 24. Since I didn't save or anything, the old Marker is
> still considered to be on line 24 and I end up overwriting this one
> instead so I don't have any markers on line, say, 40 where the old
> marker is now. And since it only refreshes the lines that have been
> modified, I get no new Marker for the old one.
>
> Also, I ended up just changing the TODO rule to :
> // (' ')* TODO [Some character]* \n
> instead. So the TODO tag must be at the beginning of the comment,
> preceded only by a number of spaces.
>
> I can't stop thinking that the initial idea of using the scanner and
> rules wasn't the right thing to do. But I couldn't find anything better.
>
> I also couldn't find the way that the TODO mechanisms were done inside
> of eclipse (couldn't quite find my way through the sea of code on the
> CVS server).
>
> Does anyone know a better way or knows how it works inside Eclipse? Just
> knowing where that code is in Eclipse would help a lot too.
>
> Thanks a lot!
>
>
> Franck Dubé wrote:
>> Hi again,
>>
>> I'm also having some problems getting the file that is currently being
>> checked. The scanner uses an IDocument and I can't seem to be able to
>> find the file path.
>>
>> Any help on this would be much appreciated,
>> Thanks!
>>
>>
>> Franck Dubé wrote:
>>> Hi,
>>>
>>> I'm creating an editor plug-in for Eclipse and I's wish to have the
>>> same TODO behavior as in the standard Java editor. So far, I've
>>> found out how to add Tasks using the IResource#createMarker(...)
>>> method. I've also found out that I should be using a
>>> RuleBasedScanner on my editor that uses a PatternRule (so far I've
>>> been trying to work with an EndOfLineRule). So all of this seems to
>>> work fine with most of my rules. But I'm having some trouble with
>>> the TODO rule. Since the pattern must be
>>> // [Some character]* TODO [Some character]* \n
>>> I've tried working with a "//" startSequence. I'm having quite a lot
>>> of trouble finding the TODO part though. Since sequenceDetected uses
>>> a scanner, the only way I found of doing the work would be to advance
>>> character by character and try to find either the endOfLineDelimiter
>>> or the TODO sequence. But I got the feeling there must be an easier
>>> and more effective way to do this.
>>>
>>> Any ideas?
|
|
|
Re: Adding Tasks to the TaskList using TODO [message #319028 is a reply to message #318820] |
Fri, 10 August 2007 01:35  |
Eclipse User |
|
|
|
Hi,
I have created a small lexer to do this kind of job for me in ANTLR (well
this is just a small part of what the lexer does).
It is run when the reconcile / initialReconcile function of my
IReconcilingStrategy implementation is called.
Kristof
"Franck Dub
|
|
|
Powered by
FUDForum. Page generated in 0.04970 seconds