public ICompletionData[] GenerateCompletionDataForOverridableMethods(string fileName, TextArea textArea) { controller = new CodeCompletion.CodeCompletionController(); List <ICompletionData> lst = new List <ICompletionData>(); int line = textArea.Caret.Line; int col = textArea.Caret.Column; try { CodeCompletion.DomConverter dconv = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[fileName]; SymInfo[] mis = null; if (dconv != null) { mis = dconv.GetOverridableMethods(line, col); } if (mis != null) { foreach (SymInfo mi in mis) { UserDefaultCompletionData ddd = new UserDefaultCompletionData(mi.name, mi.description, ImagesProvider.GetPictureNum(mi), true); lst.Add(ddd); } } } catch (Exception e) { } //lst.Sort(); ICompletionData[] res_arr = lst.ToArray(); controller = null; return(res_arr); }
public static void RenameUnit(string FileName, string new_val) { if (CodeCompletion.CodeCompletionController.CurrentParser == null) return; ccp = new CodeCompletionProvider(); IDocument doc = null; CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; PascalABCCompiler.SyntaxTree.compilation_unit cu = controller.ParseOnlySyntaxTree(FileName, text); PascalABCCompiler.SyntaxTree.ident unitName = null; if (cu is PascalABCCompiler.SyntaxTree.unit_module) { unitName = (cu as PascalABCCompiler.SyntaxTree.unit_module).unit_name.idunit_name; } else if (cu is PascalABCCompiler.SyntaxTree.program_module) { if ((cu as PascalABCCompiler.SyntaxTree.program_module).program_name == null) return; unitName = (cu as PascalABCCompiler.SyntaxTree.program_module).program_name.prog_name; } List<SymbolsViewerSymbol> refers = ccp.Rename(unitName.name, unitName.name, FileName, unitName.source_context.begin_position.line_num, unitName.source_context.begin_position.column_num); if (refers == null || new_val == null) return; int addit = 0; PascalABCCompiler.SourceLocation tmp = new PascalABCCompiler.SourceLocation(null, 0, 0, 0, 0); string file_name = null; VisualPABCSingleton.MainForm.StopTimer(); WorkbenchServiceFactory.CodeCompletionParserController.StopParseThread(); foreach (IFileInfo fi in ProjectFactory.Instance.CurrentProject.SourceFiles) { WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(fi.Path); } WorkbenchServiceFactory.CodeCompletionParserController.ParseInThread(); foreach (SymbolsViewerSymbol svs in refers) { if (svs.SourceLocation.BeginPosition.Line != tmp.BeginPosition.Line) addit = 0; else if (svs.SourceLocation.BeginPosition.Column < tmp.BeginPosition.Column) addit = 0; if (svs.SourceLocation.FileName != file_name) { CodeFileDocumentControl cfdoc = VisualPABCSingleton.MainForm.FindTab(svs.SourceLocation.FileName); if (cfdoc == null) continue; doc = cfdoc.TextEditor.ActiveTextAreaControl.TextArea.Document; file_name = svs.SourceLocation.FileName; } tmp = svs.SourceLocation; TextLocation tl_beg = new TextLocation(svs.SourceLocation.BeginPosition.Column - 1, svs.SourceLocation.BeginPosition.Line - 1); //TextLocation tl_end = new TextLocation(svs.SourceLocation.EndPosition.Line,svs.SourceLocation.EndPosition.Column); int offset = doc.PositionToOffset(tl_beg); //addit += new_val.Length - unitName.name.Length; doc.Replace(offset, unitName.name.Length, new_val); doc.CommitUpdate(); } WorkbenchServiceFactory.CodeCompletionParserController.RunParseThread(); VisualPABCSingleton.MainForm.StartTimer(); }
private List <SymbolsViewerSymbol> InternalFindReferences(string fname, PascalABCCompiler.SyntaxTree.expression expr, int line, int col, bool for_refact) { List <PascalABCCompiler.Parsers.Position> lst = new List <PascalABCCompiler.Parsers.Position>(); List <SymbolsViewerSymbol> svs_lst = new List <SymbolsViewerSymbol>(); try { CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[fname] as CodeCompletion.DomConverter; IBaseScope fnd_scope = null; IBaseScope cur_sc = null; if (dc != null) { fnd_scope = dc.GetSymDefinition(expr, line, col, keyword); cur_sc = dc.FindScopeByLocation(line, col); } if (fnd_scope != null) { foreach (string FileName in CodeCompletionParserController.open_files.Keys) { CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; PascalABCCompiler.SyntaxTree.compilation_unit cu = controller.ParseOnlySyntaxTree(FileName, text); if (cu != null) { dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; CodeCompletion.ReferenceFinder rf = null; if (dc != null && dc.visitor.entry_scope != null) { rf = new CodeCompletion.ReferenceFinder(fnd_scope, dc.visitor.entry_scope, cu, FileName, for_refact); lst.AddRange(rf.FindPositions()); } } } PascalABCCompiler.Parsers.Position p = fnd_scope.GetPosition(); bool need_add_def = !for_refact; // true if (p.file_name != null && need_add_def) { svs_lst.Add(new SymbolsViewerSymbol(new PascalABCCompiler.SourceLocation(p.file_name, p.line, p.column, p.end_line, p.end_column), ImagesProvider.GetPictureNum(fnd_scope.SymbolInfo))); } foreach (PascalABCCompiler.Parsers.Position pos in lst) { if (pos.file_name != null) { svs_lst.Add(new SymbolsViewerSymbol(new PascalABCCompiler.SourceLocation(pos.file_name, pos.line, pos.column, pos.end_line, pos.end_column), ImagesProvider.IconNumberGotoText)); } } } } catch (Exception e) { } GC.Collect(); return(svs_lst); //return svs_lst.ToArray(); }
public ICompletionData[] GenerateCompletionDataByFirstChar(string fileName, TextArea textArea, char charTyped, PascalABCCompiler.Parsers.KeywordKind keyw) { controller = new CodeCompletion.CodeCompletionController(); int off = textArea.Caret.Offset; string text = textArea.Document.TextContent.Substring(0, textArea.Caret.Offset); //controller.Compile(fileName, text /*+ ")))));end."*/); FileName = fileName; Text = text; ICompletionData[] data = GetCompletionDataByFirst(off, text, textArea.Caret.Line, textArea.Caret.Column, charTyped, keyw); CodeCompletion.AssemblyDocCache.CompleteDocumentation(); CodeCompletion.UnitDocCache.CompleteDocumentation(); controller = null; //GC.Collect(); return(data); }
public ICompletionData[] GenerateCompletionDataWithKeyword(string fileName, TextArea textArea, char charTyped, PascalABCCompiler.Parsers.KeywordKind keyw) { controller = new CodeCompletion.CodeCompletionController(); int off = textArea.Caret.Offset; string text = textArea.Document.TextContent.Substring(0, textArea.Caret.Offset); //controller.Compile(fileName, text /*+ ")))));end."*/); FileName = fileName; Text = text; //System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(CompileInThread)); //th.Start(); //while (th.ThreadState == System.Threading.ThreadState.Running) {} ICompletionData[] data = GetCompletionData(off, text, textArea.Caret.Line, textArea.Caret.Column, charTyped, keyw); CodeCompletion.AssemblyDocCache.CompleteDocumentation(); CodeCompletion.UnitDocCache.CompleteDocumentation(); controller = null; //GC.Collect(); return(data); }
public static void TestIntellisense(string dir) { //string dir = Path.Combine(@"c:\Work\Miks\_PABCNETGitHub\TestSuite", "intellisense_tests"); var comp = new PascalABCCompiler.Compiler(); var controller = new CodeCompletion.CodeCompletionController(); CodeCompletion.CodeCompletionController.comp = comp; CodeCompletion.CodeCompletionController.SetParser(".pas"); CodeCompletion.CodeCompletionController.ParsersController = comp.ParsersController; var files = Directory.GetFiles(dir, "*.pas"); var parser = comp.ParsersController; for (int i = 0; i < files.Length; i++) { var FileName = files[i]; var content = File.ReadAllText(FileName); var dc = controller.Compile(FileName, content); string expr_without_brackets = null; var tmp = content; var ind = -1; ind = tmp.IndexOf("{@"); while (ind != -1) { var lines = tmp.Split(new string[] { System.Environment.NewLine }, System.StringSplitOptions.None); var pos = ind - 1; var line = GetLineByPos(lines, pos); var col = GetColByPos(lines, pos); var desc = CodeCompletion.CodeCompletionTester.GetDescription(pos, tmp, line, col, FileName, dc, comp.ParsersController); var should_desc = tmp.Substring(ind + 2, tmp.IndexOf("@}") - ind - 2); if (desc == null) { desc = ""; } desc = desc.Split(new string[] { "\n" }, StringSplitOptions.None)[0].Trim(); assert(desc.Replace(", ", ",") == should_desc.Replace(", ", ","), FileName + ", should: " + should_desc + ", is: " + desc); tmp = tmp.Remove(ind, tmp.IndexOf("@}") + 2 - ind); ind = tmp.IndexOf("{@"); } } }
public static void TestIntellisense(string dir) { //string dir = Path.Combine(@"c:\Work\Miks\_PABCNETGitHub\TestSuite", "intellisense_tests"); var comp = new PascalABCCompiler.Compiler(); var controller = new CodeCompletion.CodeCompletionController(); CodeCompletion.CodeCompletionController.comp = comp; CodeCompletion.CodeCompletionController.SetParser(".pas"); CodeCompletion.CodeCompletionController.ParsersController = comp.ParsersController; var files = Directory.GetFiles(dir, "*.pas"); var parser = comp.ParsersController; for (int i = 0; i < files.Length; i++) { var FileName = files[i]; var content = File.ReadAllText(FileName); var dc = controller.Compile(FileName, content); string expr_without_brackets = null; var tmp = content; var ind = -1; ind = tmp.IndexOf("{@"); while (ind != -1) { var lines = tmp.Split(new string[] { System.Environment.NewLine }, System.StringSplitOptions.None); var pos = ind-1; var line = GetLineByPos(lines, pos); var col = GetColByPos(lines, pos); var desc = CodeCompletion.CodeCompletionTester.GetDescription(pos, tmp, line, col, FileName, dc, comp.ParsersController); var should_desc = tmp.Substring(ind + 2, tmp.IndexOf("@}") - ind - 2); if (desc == null) desc = ""; desc = desc.Split(new string[] { "\n"},StringSplitOptions.None)[0].Trim(); assert(desc == should_desc, FileName+", should: "+should_desc+", is: "+desc); tmp = tmp.Remove(ind, tmp.IndexOf("@}") + 2 - ind); ind = tmp.IndexOf("{@"); } } }
public ICompletionData[] GenerateCompletionDataByFirstChar(string fileName, TextArea textArea, char charTyped, PascalABCCompiler.Parsers.KeywordKind keyw) { controller = new CodeCompletion.CodeCompletionController(); int off = textArea.Caret.Offset; string text = textArea.Document.TextContent.Substring(0, textArea.Caret.Offset); //controller.Compile(fileName, text /*+ ")))));end."*/); FileName = fileName; Text = text; //System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(CompileInThread)); //th.Start(); //while (th.ThreadState == System.Threading.ThreadState.Running) {} ICompletionData[] data = GetCompletionDataByFirst(off, text, textArea.Caret.Line, textArea.Caret.Column, charTyped, keyw); CodeCompletion.AssemblyDocCache.CompleteDocumentation(); CodeCompletion.UnitDocCache.CompleteDocumentation(); controller = null; //GC.Collect(); return data; }
public ICompletionData[] GenerateCompletionDataForOverridableMethods(string fileName, TextArea textArea) { controller = new CodeCompletion.CodeCompletionController(); List<ICompletionData> lst = new List<ICompletionData>(); int line = textArea.Caret.Line; int col = textArea.Caret.Column; try { CodeCompletion.DomConverter dconv = (CodeCompletion.DomConverter)CodeCompletion.CodeCompletionController.comp_modules[fileName]; SymInfo[] mis = null; if (dconv != null) { mis = dconv.GetOverridableMethods(line, col); } if (mis != null) { foreach (SymInfo mi in mis) { UserDefaultCompletionData ddd = new UserDefaultCompletionData(mi.name, mi.describe, ImagesProvider.GetPictureNum(mi), true); lst.Add(ddd); } } } catch (Exception e) { } //lst.Sort(); ICompletionData[] res_arr = lst.ToArray(); controller = null; return res_arr; }
private List<SymbolsViewerSymbol> InternalFindReferences(string fname, PascalABCCompiler.SyntaxTree.expression expr, int line, int col, bool for_refact) { List<PascalABCCompiler.Parsers.Position> lst = new List<PascalABCCompiler.Parsers.Position>(); List<SymbolsViewerSymbol> svs_lst = new List<SymbolsViewerSymbol>(); try { CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[fname] as CodeCompletion.DomConverter; IBaseScope fnd_scope = null; IBaseScope cur_sc = null; if (dc != null) { fnd_scope = dc.GetSymDefinition(expr, line, col, keyword); cur_sc = dc.FindScopeByLocation(line, col); } if (fnd_scope != null) { foreach (string FileName in CodeCompletionParserController.open_files.Keys) { CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = VisualPABCSingleton.MainForm.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; PascalABCCompiler.SyntaxTree.compilation_unit cu = controller.ParseOnlySyntaxTree(FileName, text); if (cu != null) { dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; CodeCompletion.ReferenceFinder rf = null; if (dc != null && dc.stv.entry_scope != null) { rf = new CodeCompletion.ReferenceFinder(fnd_scope, dc.stv.entry_scope, cu, FileName, for_refact); lst.AddRange(rf.FindPositions()); } } } PascalABCCompiler.Parsers.Position p = fnd_scope.GetPosition(); bool need_add_def = true; if (for_refact) foreach (PascalABCCompiler.Parsers.Position pos in lst) if (p.file_name == pos.file_name && p.line == pos.line && p.column == pos.column && p.end_line == pos.end_line && p.end_column == pos.end_column) { need_add_def = false; break; } if (p.file_name != null && need_add_def) svs_lst.Add(new SymbolsViewerSymbol(new PascalABCCompiler.SourceLocation(p.file_name, p.line, p.column, p.end_line, p.end_column), ImagesProvider.GetPictureNum(fnd_scope.SymbolInfo))); foreach (PascalABCCompiler.Parsers.Position pos in lst) { if (pos.file_name != null) svs_lst.Add(new SymbolsViewerSymbol(new PascalABCCompiler.SourceLocation(pos.file_name, pos.line, pos.column, pos.end_line, pos.end_column), ImagesProvider.IconNumberGotoText)); } } } catch (Exception e) { } GC.Collect(); return svs_lst; //return svs_lst.ToArray(); }
public static void RenameUnit(string FileName, string new_val) { if (CodeCompletion.CodeCompletionController.CurrentParser == null) { return; } ccp = new CodeCompletionProvider(); IDocument doc = null; CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = WorkbenchServiceFactory.Workbench.VisualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; PascalABCCompiler.SyntaxTree.compilation_unit cu = controller.ParseOnlySyntaxTree(FileName, text); PascalABCCompiler.SyntaxTree.ident unitName = null; if (cu is PascalABCCompiler.SyntaxTree.unit_module) { unitName = (cu as PascalABCCompiler.SyntaxTree.unit_module).unit_name.idunit_name; } else if (cu is PascalABCCompiler.SyntaxTree.program_module) { if ((cu as PascalABCCompiler.SyntaxTree.program_module).program_name == null) { return; } unitName = (cu as PascalABCCompiler.SyntaxTree.program_module).program_name.prog_name; } List <SymbolsViewerSymbol> refers = ccp.Rename(unitName.name, unitName.name, FileName, unitName.source_context.begin_position.line_num, unitName.source_context.begin_position.column_num); if (refers == null || new_val == null) { return; } int addit = 0; PascalABCCompiler.SourceLocation tmp = new PascalABCCompiler.SourceLocation(null, 0, 0, 0, 0); string file_name = null; VisualPABCSingleton.MainForm.StopTimer(); WorkbenchServiceFactory.CodeCompletionParserController.StopParseThread(); foreach (IFileInfo fi in ProjectFactory.Instance.CurrentProject.SourceFiles) { WorkbenchServiceFactory.CodeCompletionParserController.RegisterFileForParsing(fi.Path); } WorkbenchServiceFactory.CodeCompletionParserController.ParseInThread(); foreach (SymbolsViewerSymbol svs in refers) { if (svs.SourceLocation.BeginPosition.Line != tmp.BeginPosition.Line) { addit = 0; } else if (svs.SourceLocation.BeginPosition.Column < tmp.BeginPosition.Column) { addit = 0; } if (svs.SourceLocation.FileName != file_name) { CodeFileDocumentControl cfdoc = VisualPABCSingleton.MainForm.FindTab(svs.SourceLocation.FileName); if (cfdoc == null) { continue; } doc = cfdoc.TextEditor.ActiveTextAreaControl.TextArea.Document; file_name = svs.SourceLocation.FileName; } tmp = svs.SourceLocation; TextLocation tl_beg = new TextLocation(svs.SourceLocation.BeginPosition.Column - 1, svs.SourceLocation.BeginPosition.Line - 1); //TextLocation tl_end = new TextLocation(svs.SourceLocation.EndPosition.Line,svs.SourceLocation.EndPosition.Column); int offset = doc.PositionToOffset(tl_beg); //addit += new_val.Length - unitName.name.Length; doc.Replace(offset, unitName.name.Length, new_val); doc.CommitUpdate(); } WorkbenchServiceFactory.CodeCompletionParserController.RunParseThread(); VisualPABCSingleton.MainForm.StartTimer(); }
internal void ParseInThread() { try { Hashtable open_files2 = (Hashtable)open_files.Clone(); Hashtable recomp_files = new Hashtable(StringComparer.OrdinalIgnoreCase); bool is_comp = false; foreach (string FileName in open_files2.Keys) { //(ssyy) 18.05.08 Вставил проверку на null object o = open_files[FileName]; if (o != null && (bool)o == true) { is_comp = true; CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = visualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; CodeCompletion.DomConverter tmp = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; long cur_mem = Environment.WorkingSet; CodeCompletion.DomConverter dc = controller.Compile(FileName, text); mem_delta += Environment.WorkingSet - cur_mem; open_files[FileName] = false; if (dc.is_compiled) { //CodeCompletion.CodeCompletionController.comp_modules.Remove(FileName); if (tmp != null && tmp.stv.entry_scope != null) { tmp.stv.entry_scope.Clear(); if (tmp.stv.cur_scope != null) tmp.stv.cur_scope.Clear(); } CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; recomp_files[FileName] = FileName; open_files[FileName] = false; if (ParseInformationUpdated != null) ParseInformationUpdated(dc.stv.entry_scope, FileName); } else if (CodeCompletion.CodeCompletionController.comp_modules[FileName] == null) CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; } } foreach (string FileName in open_files2.Keys) { CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; CodeCompletion.SymScope ss = null; if (dc != null) { if (dc.stv.entry_scope != null) ss = dc.stv.entry_scope; else if (dc.stv.impl_scope != null) ss = dc.stv.impl_scope; int j = 0; while (j < 2) { if (j == 0) { ss = dc.stv.entry_scope; j++; } else { ss = dc.stv.impl_scope; j++; } if (ss != null) { for (int i = 0; i < ss.used_units.Count; i++) { string s = ss.used_units[i].file_name; if (s != null && open_files2.ContainsKey(s) && recomp_files.ContainsKey(s)) { is_comp = true; CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = visualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; CodeCompletion.DomConverter tmp = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; long cur_mem = Environment.WorkingSet; dc = controller.Compile(FileName, text); mem_delta += Environment.WorkingSet - cur_mem; open_files[FileName] = false; CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; if (dc.is_compiled) { /*if (tmp != null && tmp.stv.entry_scope != null) { tmp.stv.entry_scope.Clear(); if (tmp.stv.cur_scope != null) tmp.stv.cur_scope.Clear(); }*/ CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; recomp_files[FileName] = FileName; ss.used_units[i] = dc.stv.entry_scope; if (ParseInformationUpdated != null) ParseInformationUpdated(dc.stv.entry_scope, FileName); } else if (CodeCompletion.CodeCompletionController.comp_modules[FileName] == null) CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; } } } } } } if (is_comp && Environment.WorkingSet > 60000000 /*&& mem_delta > 10000000*/) //postavil delta dlja pamjati, posle kototoj delaetsja sborka musora { mem_delta = 0; GC.Collect(); } } catch (Exception e) { } }
internal void ParseInThread() { try { Hashtable open_files2 = (Hashtable)open_files.Clone(); Hashtable recomp_files = new Hashtable(StringComparer.OrdinalIgnoreCase); bool is_comp = false; foreach (string FileName in open_files2.Keys) { //(ssyy) 18.05.08 Вставил проверку на null object o = open_files[FileName]; if (o != null && (bool)o == true) { is_comp = true; CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = visualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; if (string.IsNullOrEmpty(text)) { text = "begin end."; } CodeCompletion.DomConverter tmp = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; long cur_mem = Environment.WorkingSet; CodeCompletion.DomConverter dc = controller.Compile(FileName, text); mem_delta += Environment.WorkingSet - cur_mem; open_files[FileName] = false; if (dc.is_compiled) { //CodeCompletion.CodeCompletionController.comp_modules.Remove(FileName); if (tmp != null && tmp.visitor.entry_scope != null) { tmp.visitor.entry_scope.Clear(); if (tmp.visitor.cur_scope != null) { tmp.visitor.cur_scope.Clear(); } } CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; recomp_files[FileName] = FileName; open_files[FileName] = false; if (ParseInformationUpdated != null) { ParseInformationUpdated(dc.visitor.entry_scope, FileName); } } else if (CodeCompletion.CodeCompletionController.comp_modules[FileName] == null) { CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; } } } foreach (string FileName in open_files2.Keys) { CodeCompletion.DomConverter dc = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; CodeCompletion.SymScope ss = null; if (dc != null) { if (dc.visitor.entry_scope != null) { ss = dc.visitor.entry_scope; } else if (dc.visitor.impl_scope != null) { ss = dc.visitor.impl_scope; } int j = 0; while (j < 2) { if (j == 0) { ss = dc.visitor.entry_scope; j++; } else { ss = dc.visitor.impl_scope; j++; } if (ss != null) { for (int i = 0; i < ss.used_units.Count; i++) { string s = ss.used_units[i].file_name; if (s != null && open_files2.ContainsKey(s) && recomp_files.ContainsKey(s)) { is_comp = true; CodeCompletion.CodeCompletionController controller = new CodeCompletion.CodeCompletionController(); string text = visualEnvironmentCompiler.SourceFilesProvider(FileName, PascalABCCompiler.SourceFileOperation.GetText) as string; CodeCompletion.DomConverter tmp = CodeCompletion.CodeCompletionController.comp_modules[FileName] as CodeCompletion.DomConverter; long cur_mem = Environment.WorkingSet; dc = controller.Compile(FileName, text); mem_delta += Environment.WorkingSet - cur_mem; open_files[FileName] = false; CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; if (dc.is_compiled) { /*if (tmp != null && tmp.stv.entry_scope != null) * { * tmp.stv.entry_scope.Clear(); * if (tmp.stv.cur_scope != null) tmp.stv.cur_scope.Clear(); * }*/ CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; recomp_files[FileName] = FileName; ss.used_units[i] = dc.visitor.entry_scope; if (ParseInformationUpdated != null) { ParseInformationUpdated(dc.visitor.entry_scope, FileName); } } else if (CodeCompletion.CodeCompletionController.comp_modules[FileName] == null) { CodeCompletion.CodeCompletionController.comp_modules[FileName] = dc; } } } } } } } if (is_comp && mem_delta > 20000000 /*&& mem_delta > 10000000*/) //postavil delta dlja pamjati, posle kototoj delaetsja sborka musora { mem_delta = 0; GC.Collect(); } } catch (Exception e) { } }