Permalink
Browse files

this commit fixes the issue #811.

  • Loading branch information...
1 parent cfc8be7 commit e1b9b12f173cb5af18af8b4fda4135983650733e @vahdat-ab vahdat-ab committed Apr 10, 2016
@@ -159,6 +159,9 @@ class ParserDataPackage
//the filename of the file that is being parsed
filename;
+ //This is used to save the full address of the fileName.
+ fullFileAddress = "";
+
GrammarAnalyzer analyzer;
//the string that is the file that is being parsed
@@ -550,6 +550,7 @@ class ParserDataPackage
public void init(Position usePosition)
{
String file = filename;
+ fullFileAddress = filename;
filename = file.split("\\Q"+File.separator+"\\E")[file.split("\\Q"+File.separator+"\\E").length-1];
int offset = 0;
int linenumber = 0;
@@ -33,15 +33,30 @@ class UseStatementParserAction{
public void onSuccess(Token token, ParserDataPackage data)
{
String value = token.getValue("use");
+ String fileName="";
+ String path = "";
+ int index =-1;
+ if (data!=null && data.getFullFileAddress()!=null) index = data.getFullFileAddress().lastIndexOf("/") ;
+ if (index==-1) index = data.getFullFileAddress().lastIndexOf("\\");
+ if (index!=-1){
+ path = data.getFullFileAddress().substring(0,index+1 );
+ }
+
synchronized(data.getHasParsed())
{
- if(!data.getHasParsed().contains(value))
+ fileName = data.getAnalyzer().getFile().getAbsoluteFile().getParentFile().getAbsolutePath() + File.separator + value;
+ //I used this technique because I noticed this function is used to several purposes.
+ // The correct implementation is just to set fileName = path +value; and remove the above code.
+ //TODO: this issue must be investigated more. Currently it is working with the following solution.
+ File f = new File(fileName);
+ if (!f.exists()) fileName = path +value;
+ if(!data.getHasParsed().contains(fileName))
{
- data.getHasParsed().add(value);
+ data.getHasParsed().add(fileName);
RuleBasedParserThread thread = new RuleBasedParserThread(
data.getAnalyzer().getRules().get("$ROOT$"),
token,
- data.getAnalyzer().getFile().getAbsoluteFile().getParentFile().getAbsolutePath() + File.separator + value,
+ fileName,
data
);
data.getAnalyzer().addThread(thread);

0 comments on commit e1b9b12

Please sign in to comment.