Problem in finding class name and the associated file name

41 views
Skip to first unread message

Parvez

unread,
Feb 16, 2016, 5:49:59 PM2/16/16
to Boa Language and Infrastructure User Forum

For my research I am trying to find user defined exception classes including the file name containing those classes:

Please see the following code:
p: Project = input;
myout: output collection [string][string][string] of int;
file_name: string;
code_repo: string;
class_name:string;

visit(p, visitor {
    
 before node: CodeRepository -> {
            code_repo = node.url;
            snapshot := getsnapshot(node, "SOURCE_JAVA_JLS");
            
            foreach (i: int; def(snapshot[i])){
                file_name = snapshot[i].name;
                visit(snapshot[i]);
            }
    }
 
 before n: Declaration ->{
 
    #I am looking those classes that are extend from Exception class
    if(n.kind == TypeKind.CLASS && def(n.parents) && len(n.parents) > 0 && match(`Exception`, n.parents[0].name)) {
         myout[code_repo][file_name][n.name] << 1;
    }
 }
 
    
});

Here is the first few lines of output:
myout[https://github.com/1mobilesuper/1mobile_download.git [src/me/onemobile/android/download/DownloadThread.java][GenerateSaveFileError] = 1

I can find the class names but I am receiving the same class names multiple times associated with different source files. Can you point me what is wrong in the code? (For example, the WavFileException class is defined in WavFileException.java not in the ISignal.java)
 

Robert E Dyer

unread,
Feb 16, 2016, 10:09:34 PM2/16/16
to boa-...@googlegroups.com
You need to add a ‘stop;’ statement after the foreach() block in your CodeRepository visit clause.

Otherwise, you manually visit each snapshot and then *also* do the default traversal which visits *every* node in the tree (using the last snapshot’s filename).

- Robert

--
More information about Boa: http://boa.cs.iastate.edu/
---
You received this message because you are subscribed to the Google Groups "Boa Language and Infrastructure User Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to boa-user+u...@googlegroups.com.
To post to this group, send email to boa-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

________________________________________________
Robert Dyer | Assistant Professor | Department of Computer Science
BGSU | rd...@bgsu.edu | 419.372.3469 | 244 Hayes | Bowling Green, OH

Want to mine ultra-large-scale software repositories with minimal initial
investment? Check out Boa! http://boa.cs.iastate.edu/

Parvez

unread,
Feb 16, 2016, 10:24:44 PM2/16/16
to Boa Language and Infrastructure User Forum
Thanks Robert for your kind help. This clarifies the issue.

-Parvez
Reply all
Reply to author
Forward
0 new messages