Re: [Boa Users] Help needed with Boa ASTRoot imports attribute

32 views
Skip to first unread message

Yijia Huang

unread,
Apr 3, 2019, 2:31:26 AM4/3/19
to ssri...@oakland.edu, boa-...@googlegroups.com, Rajan, Hridesh [COM S]
Hi Srilakshmi,

Sorry for the delay in response. For your questions,

Goal 1: "To print the smallest GitHub project with 2 or fewer imports."
Problem 1: "My output project has more than 2 imports." 
The data schema is like this
  • A project contains an array of CodeRepository
  • A CodeRepository contains an array of Revision
  • A Revision contains an array of ChangedFile
  • A ChangedFile contains one ASTRoot
In your source code line 24, the attribute "imports" is an array of string under ASTRoot. To check the number of imports in each ChangedFile, you need to use "len(node.imports)" instead of "len(node.imports[i])". So, the before clause for the node : ASTRoot should be:

before node: ASTRoot -> {

if (len(node.imports) <= 2) {

import_count << p.project_url weight astCount / 1000000;

}

}


Problem 2: "When I use "exists", "for each" quantifiers to check if the project is java project. It is fetching me not just Java but also c++, c projects too. " 
If you are looking for projects written in Java only, the code should be:

if (len(p.programming_languages) == 1 && lowercase(p.programming_languages[0]) == "java") {

# TODO

}


If you are looking for projects containing Java, the code should be:


exists (i: int; lowercase(p.programming_languages[i]) == "java") {

# TODO

}


To check if the ChangedFile is a java file, you can use this function which is used for checking file extension:

isJavaFile := function(file: ChangedFile) : bool {

return match(format(`\.%s$`, "java"), lowercase(file.name));

};


Problem 3: "How can I modify it to fetch only certain language projects?"
Use the if statement in Problem 2 and replace "java" by other languages.

Goal 2: "I want to test if a certain library is being used by a project. As in, Is "java.io" being used in any projects?"

visit(p, visitor {

    before node: ASTRoot -> {

        exists (i: int; strfind("java.io", lowercase(node.imports[i])) != -1) {

        # TODO

        }

    }

});


If you have more questions, feel free to ask.

best regards,

On Tue, Apr 2, 2019 at 5:47 PM Rajan, Hridesh [COM S] <hri...@iastate.edu> wrote:

From: ssri...@oakland.edu
Date: March 25, 2019 at 11:28:13 AM EDT
To: Boa Language and Infrastructure User Forum <boa-...@googlegroups.com>
Subject: [Boa Users] Help needed with Boa ASTRoot imports attribute
Reply-To: boa-...@googlegroups.com


My goal: 
1. To print the smallest GitHub project with 2 or fewer imports.
2. I want to test if a certain library is being used by a projects. As in, Is "java.io" being used in any projects?

Attached code:
1. job id : 76985
2. job id:  76970

Problems:
1. My output project has more than 2 imports.
2. When I use "exists", "for each" quantifiers to check if the project is java project. It is fetching me not just Java but also c++, c projects too.
How can I modify it to fetch only certain language projects?

Appreciate any help provided, I am in tight schedule for my Research work.

Thank you in advance,

-Srilakshmi Sripathi

--
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.


--
Yijia Huang

Research Assistant
Iowa State University
Laboratory for Software Design
115-2 Atanasoff Hall
Ames, IA 50011-1090 

Srilakshmi Sripathi

unread,
Apr 3, 2019, 8:57:29 AM4/3/19
to boa-...@googlegroups.com, Rajan, Hridesh [COM S]
Thank you so much for detailed information, Yijia. This is very helpful. 
Reply all
Reply to author
Forward
0 new messages