コード例 #1
0
 public void LocationChanged(int LineNum, int ColumnNum, string FileName)
 {
     SourceLocation sl = null;
     /*if (lines_to_locations.TryGetValue(LineNum, out sl))
         if (sl.FileName == FileName)
         {
             sl.BeginPosition.Column = sl.EndPosition.Column = ColumnNum;
             locations.Remove(sl);
             locations.Add(sl);
             return;
         }*/
     if (locations.Count > 0)
     {
         sl = locations[navigatePosition];
         if (sl.FileName == FileName && Math.Abs(sl.BeginPosition.Line-LineNum)<2)
         {
             sl.BeginPosition.Column = sl.EndPosition.Column = ColumnNum;
             sl.BeginPosition.Line = sl.EndPosition.Line = LineNum;
             return;
         }
     }
     sl = new SourceLocation(FileName, LineNum, ColumnNum, LineNum, ColumnNum);
     if (locations.Count == 0)
     {
         locations.Add(sl);
         navigatePosition = 0;
     }
     else
     {
         locations.Insert(navigatePosition+1, sl);
         navigatePosition++;
     }
     stateChanged();
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        public static void Rename(TextArea textArea)
        {
            if (CodeCompletion.CodeCompletionController.CurrentParser == null)
            {
                return;
            }
            IDocument doc         = textArea.Document;
            string    textContent = doc.TextContent;

            ccp = new CodeCompletionProvider();
            string name                       = null;
            string expressionResult           = FindOnlyIdent(textContent, textArea, ref name).Trim(' ', '\n', '\t', '\r');
            string new_val                    = null;
            List <SymbolsViewerSymbol> refers = ccp.Rename(expressionResult, name, textArea.MotherTextEditorControl.FileName, textArea.Caret.Line, textArea.Caret.Column, ref new_val);

            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;

            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 + addit, 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 - name.Length;
                doc.Replace(offset, name.Length, new_val);
                doc.CommitUpdate();
            }
        }
コード例 #4
0
 public static void Rename(TextArea textArea)
 {
     if (CodeCompletion.CodeCompletionController.CurrentParser == null) return;
     IDocument doc = textArea.Document;
     string textContent = doc.TextContent;
     ccp = new CodeCompletionProvider();
     string name = null;
     string expressionResult = FindOnlyIdent(textContent, textArea, ref name).Trim(' ', '\n', '\t', '\r');
     string new_val = null;
     List<SymbolsViewerSymbol> refers = ccp.Rename(expressionResult, name, textArea.MotherTextEditorControl.FileName, textArea.Caret.Line, textArea.Caret.Column, ref new_val);
     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;
     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 + addit, 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 - name.Length;
         doc.Replace(offset, name.Length, new_val);
         doc.CommitUpdate();
     }
 }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: SymbolsViwer.cs プロジェクト: lisiynos/pascalabcnet
 public SymbolsViewerSymbol(SourceLocation sl, int imageIndex)
 {
     this.sl = sl ;
     this.imageIndex = imageIndex;
 }
コード例 #7
0
 public SourceLocation(SourceLocation Begin,SourceLocation End)
 {
     fileName = Begin.FileName;
     beginPosition = Begin.beginPosition;
     endPosition = End.EndPosition;
 }