// TODO: ask Anton on possibility of parsing of several files // TODO: make returning of IList<string> public static string getKnowledgeFilePath(Knowledge.Editor.AddIn.Environment environment) { log.Debug(" getting path of knowledge file"); foreach (Project project in environment.ApplicationObject.Solution.Projects) { string projectFileName = project.FileName; log.Debug(" project = " + projectFileName); foreach (ProjectItem item in project.ProjectItems) { string itemFileName = item.Name; log.Debug(" item = " + itemFileName); if (projectFileName.EndsWith("csproj") && itemFileName.EndsWith(".expert")) { // TODO: prItem.Document.FullName is null !!! for some reason // SO -> RESTRICTION: file inside other dirs will not be found // TODO: ->Anton: System.Exit() replace to return is the file is not found // TODO: ->Anton: flush() should be added, otherwise looks // like parser is not ready for this twice actions string workdir = projectFileName.Substring(0, projectFileName.LastIndexOf("\\")); string filepath = (workdir + "\\" + itemFileName); log.Debug(" file - " + filepath); return(filepath); } } } log.Debug(" no knowledge "); return(null); }
public void buildModel(Knowledge.Editor.AddIn.Environment environment) { log.Debug(" building model ... "); data = new KnowledgeAdapter(); data.parse(environment); log.Debug(" model built. "); }
public void parse(Knowledge.Editor.AddIn.Environment environment) { log.Debug(" parsing model ... "); try { string filepath = KnowledgeAdapter.getKnowledgeFilePath(environment); ExpComp.Clear(); Scanner scanner = new Scanner(filepath); ExpComp.parser = new Parser(scanner); ExpComp.parser.Parse(); KnowledgeAdapter.filepath = filepath; isEmpty = false; log.Debug(" building model successed. "); } catch (Exception e) { log.Debug(" building model failed. " + e); } }