i created this patch to make it a bit more simple for script types to overwrite the find comment behavior:
I think the TodoTaskParser should be an interface or something not an direct class.
johan
### Eclipse Workspace Patch 1.0
#P org.eclipse.dltk.validators.core
Index: src/org/eclipse/dltk/validators/core/AbstractTodoTaskBuildParticipantType.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.validators.core/src/org/eclipse/dltk/validators/core/AbstractTodoTaskBuildParticipantType.java,v
retrieving revision 1.1
diff -u -r1.1 AbstractTodoTaskBuildParticipantType.java
--- src/org/eclipse/dltk/validators/core/AbstractTodoTaskBuildParticipantType.java 28 Sep 2008 20:04:29 -0000 1.1
+++ src/org/eclipse/dltk/validators/core/AbstractTodoTaskBuildParticipantType.java 29 Sep 2008 10:02:18 -0000
@@ -65,15 +65,20 @@
*/
protected IBuildParticipant getBuildParticipant(
ITodoTaskPreferences preferences) {
- return new TodoTaskBuildParticipant(preferences);
+ return new TodoTaskBuildParticipant(createTodoParser(preferences));
+ }
+
+ protected TodoTaskAstParser createTodoParser(ITodoTaskPreferences preferences)
+ {
+ return new TodoTaskAstParser(preferences);
}
private class TodoTaskBuildParticipant implements IBuildParticipant {
private TodoTaskAstParser parser;
- public TodoTaskBuildParticipant(ITodoTaskPreferences preferences) {
- parser = new TodoTaskAstParser(preferences);
+ public TodoTaskBuildParticipant(TodoTaskAstParser parser) {
+ this.parser = parser;
}
public void build(ISourceModule module, ModuleDeclaration ast,
#P org.eclipse.dltk._javascript_.core
Index: src/org/eclipse/dltk/internal/_javascript_/parser/_javascript_TodoParserType.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/_javascript_/plugins/org.eclipse.dltk._javascript_.core/src/org/eclipse/dltk/internal/_javascript_/parser/_javascript_TodoParserType.java,v
retrieving revision 1.1
diff -u -r1.1 _javascript_TodoParserType.java
--- src/org/eclipse/dltk/internal/_javascript_/parser/_javascript_TodoParserType.java 28 Sep 2008 20:04:12 -0000 1.1
+++ src/org/eclipse/dltk/internal/_javascript_/parser/_javascript_TodoParserType.java 29 Sep 2008 10:02:19 -0000
@@ -1,6 +1,8 @@
package org.eclipse.dltk.internal._javascript_.parser;
import org.eclipse.core.runtime.Preferences;
+import org.eclipse.dltk.compiler.task.ITodoTaskPreferences;
+import org.eclipse.dltk.compiler.task.TodoTaskAstParser;
import org.eclipse.dltk._javascript_.core._javascript_Nature;
import org.eclipse.dltk._javascript_.core._javascript_Plugin;
import org.eclipse.dltk.validators.core.AbstractTodoTaskBuildParticipantType;
@@ -22,4 +24,27 @@
public String getNature() {
return _javascript_Nature.NATURE_ID;
}
+
+ /**
+ * @see org.eclipse.dltk.validators.core.AbstractTodoTaskBuildParticipantType#createTodoParser(org.eclipse.dltk.compiler.task.ITodoTaskPreferences)
+ */
+ protected TodoTaskAstParser createTodoParser(
+ ITodoTaskPreferences preferences) {
+ return new TodoTaskAstParser(preferences) {
+ /**
+ * @see org.eclipse.dltk.compiler.task.TodoTaskAstParser#findCommentStart(char[],
+ * int, int)
+ */
+ protected int findCommentStart(char[] content, int begin, int end) {
+ for (int i = begin; i < end; ++i) {
+ if (content[i] == '/'
+ && (i + 1 < end && (content[i + 1] == '/' || content[i + 1] == '*'))
+ && checkRange(i)) {
+ return i + 2;
+ }
+ }
+ return -1;
+ }
+ };
+ }
}
#P org.eclipse.dltk.core
Index: compiler/org/eclipse/dltk/compiler/task/TodoTaskAstParser.java
===================================================================
RCS file: /cvsroot/technology/org.eclipse.dltk/core/plugins/org.eclipse.dltk.core/compiler/org/eclipse/dltk/compiler/task/TodoTaskAstParser.java,v
retrieving revision 1.5
diff -u -r1.5 TodoTaskAstParser.java
--- compiler/org/eclipse/dltk/compiler/task/TodoTaskAstParser.java 26 Sep 2008 10:04:06 -0000 1.5
+++ compiler/org/eclipse/dltk/compiler/task/TodoTaskAstParser.java 29 Sep 2008 10:02:20 -0000
@@ -53,7 +53,7 @@
* @param i
* @return
*/
- private boolean checkRange(int location) {
+ protected final boolean checkRange(int location) {
for (int i = 0; i < rangeCount; ++i) {
if (location >= ranges[i * 2] && location < ranges[i * 2 + 1]) {
return false;
On Mon, Sep 29, 2008 at 11:50 AM, Johan Compagner
<jcompagner@xxxxxxxxx> wrote:
Hi
i looked into the _javascript_ part and i got it working for single line comments like:
// TODO please look at this
/* FIXME asap! */
But not multi line comments yet like:
/*
* TODO multi
*/
or
/*
TODO multi
*/
because then the TodoTaskSimpleParser.public void parse(ITaskReporter reporter, char[] content)
must be a bit smarter and just ask something for the complete comment and search in that comment for those tasks
But i guess this is why it is called SimpleParser :)
What i needed todo in _javascript_ to get that support is add this in the _javascript_TodoParserType
/**
* @see org.eclipse.dltk.validators.core.AbstractTodoTaskBuildParticipantType#getBuildParticipant(org.eclipse.dltk.compiler.task.ITodoTaskPreferences)
*/
protected IBuildParticipant getBuildParticipant(
ITodoTaskPreferences preferences) {
return new _javascript_TodoTaskBuildParticipant(preferences);
}
private class _javascript_TodoTaskBuildParticipant implements
IBuildParticipant {
private TodoTaskAstParser parser;
public _javascript_TodoTaskBuildParticipant(
ITodoTaskPreferences preferences) {
parser = new TodoTaskAstParser(preferences) {
/**
* @see org.eclipse.dltk.compiler.task.TodoTaskAstParser#findCommentStart(char[],
* int, int)
*/
protected int findCommentStart(char[] content, int begin,
int end) {
for (int i = begin; i < end; ++i) {
if (content[i] == '/'
&& (i + 1 < end && (content[i + 1] == '/' || content[i + 1] == '*'))
&& checkRange(i)) {
return i + 2;
}
}
return -1;
}
};
}
public void build(ISourceModule module, ModuleDeclaration ast,
IProblemReporter reporter) throws CoreException {
parser.build(module, ast, reporter);
}
}
so including the inner class _javascript_TodoTaskBuildParticipant, which is pretty much a complete copy
just to override the findCommentStart method.
Also the TodoTaskAstParser is in the general packages of dltk but isnt that comment # very specific to a script implementation?
i dont mind that it is default there but i would just find it more and easier to find for scripting implementations that that findCommentStart method
is a abstract method that has its implementations in the various script types.
johan
hello all -
support for 'todo' task tags has been added for the python plugin and is 99% done for the _javascript_ plugin. it still needs a comment scanner implementation that supports '//' as a comment. i believe the pdt folks may be working on this, which is why i have not investigated further (anyone from pdt care to comment?).
i also created a mini tutortial that lists the steps one must complete to add this support which can be found here:
http://wiki.eclipse.org/Adding_Todo_Task_Tag_Support
i used snippets from the python plugin in the examples. if anyone wishes to tweak it further, feel free.
let me know if there are any comments/questions/problems.
thx!
--
-jae