cwi-swat / php-analysis

PHP language analyses in Rascal
BSD 2-Clause "Simplified" License
27 stars 8 forks source link

buildBinaries() fails #13

Closed jiahao42 closed 5 years ago

jiahao42 commented 5 years ago

Hi Mark, I am following the steps in readme to build this tool, the checkConfiguration(); works fine, but when I tried to run buildBinaries();, the console said

project://PHPAnalysis/src/lang/php/util/Utils.rsc|(10110,11,<249,17>,<249,28>): Undeclared variable: getProducts

Also, when I tried to execute import lang::php::stats::Unfriendly;, the console said

project://PHPAnalysis/src/lang/php/stats/Unfriendly.rsc|(52997,12,<1091,30>,<1091,42>): Undeclared type: getLinesType

Here is some info of my setup:

Any ideas on how to fix this? Thank you so much!

mahills commented 5 years ago

How are you starting the console? You may want to start it by opening lang::php::util::Utils, right-clicking inside the opened editor window, and selecting Start Console. It sounds like the interpreter is not finding the imports properly, so it may not have the proper project context. I will try to replicate the problem here, but I just tried it on Eclipse 2019-03, macOS 10.14.5, PHP 7.1.10, Java 1.8.0_111 and it works fine.

jiahao42 commented 5 years ago

Hi @mahills, thanks for the reply! I am selecting the Start Console in the editor window of lang::php::util::Utils, and import lang::php::util::Utils; works fine, it's the buildBinaries(); fails, and says Utils.rsc|(10110,11,<249,17>,<249,28>): Undeclared variable: getProducts. I think I may misunderstand the readme somewhere, just to be sure, I put the corpus in the root directory, is that correct? Here is how my root directory looks like. Thanks again!

php-analysis
├── META-INF
├── PHP-Parser
├── README.md
├── bin
├── build.properties
├── build.xml
├── corpus-icse13
├── corpus-includes-extension
├── doc
├── lib
├── serialized
└── src
mahills commented 5 years ago

The corpus can actually be anywhere, but it is easiest if all the data (including systems and serialized information) lives in one place. I usually create a directory PHP-Analysis in my home folder, then put the corpus under PHP-Analysis/systems (e.g., PHP-Analysis/systems/WordPress for WordPress, with individual versions of WordPress in the WordPress directory) and the php-analysis project itself under PHP-Analysis/rascal (so, PHP-Analysis/rascal/php-analysis). If you put it in the project folder, it should work, but git will want to do something with the files so I would avoid this. Here is part of my configuration:

public loc parserLoc = |file:///Users/mhills/PHPAnalysis/PHP-Parser|;
public loc analysisLoc = |file:///Users/mhills/PHPAnalysis/php-analysis/|;
public loc baseLoc = |home:///PHPAnalysis|;
public loc parsedDir = baseLoc + "serialized/parsed";
public loc statsDir = baseLoc + "serialized/stats";
public loc corpusRoot = baseLoc + "systems";
public loc countsDir = baseLoc + "serialized/counts";

baseLoc drives most of this -- the corpus (corpusRoot), and all the extracted info, generally live under it. analysisLoc is where the Rascal php-analysis project is located.

jiahao42 commented 5 years ago

I imported the project again, and now it works fine. Thanks for your help!

mahills commented 5 years ago

@jiahao42 I'm glad it is working for you! If you have any questions please do not hesitate to ask, I'm happy to answer them.