-
-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with creating matcher. #2982
Comments
Thanks for the bug report. It should work. Could you make a pull-request with a failing test case? |
I tried to reproduce the problem, but this works fine:
output:
@MakroCZ, maybe you forgot to build the model or add |
Sorry for my inactivity. I didn't have access to PC and have exams. |
@MakroCZ, you don't need to create a new Launcher inside your processor, but you still have to pass input sources with See the example here: http://spoon.gforge.inria.fr/first_analysis_processor.html Alternatively, you can create Launcher from code and use addInputResources and addProcessor, insead of cli interface. Can you show how you run your processor? |
I am launching it from java SwingWorker (code below) @Override
protected Void doInBackground() throws Exception {
for (int i = 0; i < files.size(); i++) {
Launcher l = new Launcher();
l.addInputResource(files.get(i).getPath());
for (MyAbstractProcessor t : processors) {
l.addProcessor(t);
}
publish(i+1);
l.run();
}
return null;
} @Egor18 As you mentioned to add it as input. I don't want it to be global, it's why I asked about creating new Launcher in processor to build the matcher model. |
@MakroCZ, I don't quite get the idea of creating a new Launcher in the processor. The launcher runs processors over the input sources. Does the exception still occur? |
I am creating new Launcher for each file because it was the only way I was able to find to have some progress measurement (I am showing index of actually processed file). I don't want to add all matchers to all processors (input resource in SwingWorker) because of globality (I don't know it but I think that with many processors and many different matchers used globally, whole model will be pretty big and can cause performance problems - navigating throught the AST) so I want matchers to be local, only for processor which needs them. And because of this I am asking if I have to create new Launcher in processor which will build AST from matcher class. I am actually not able to test if exception still occurs but I will test it as soon as possible. |
After finishing my exams and returning from vacation I tested creating launcher in processor, add matcher class to launcher, build model from it and it looks working. But I think that there is one bad understable documentation (at least for me) or maybe bug?:
|
|
Closing this issue. Don't hesitate to create a new issue of you have a new problem that is not related to matchers. |
Hello,
I'm trying to implement template matcher (patterns give me some internal missing CtElement for to provide Factory error).
My matcher class is from website:
I'm trying to create matcher in processor:
variable e is CtMethod.
Problem is that body of method (variable block) contains no statements, so the last statement gives me IndexOutOfBoundException: 0.
Thanks for help.
The text was updated successfully, but these errors were encountered: