Ejemplo n.º 1
0
        private void FindReferencesClicked(object sender, EventArgs args)
        {
            //GotoAction ga = new GotoAction();
            List <SymbolsViewerSymbol> syms = CodeCompletionActionsManager.FindReferences(CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea);

            FindSymbolsResultWindow.FindSymbolResults.Show(syms);
        }
Ejemplo n.º 2
0
 private void RenameClicked(object sender, EventArgs args)
 {
     //GotoAction ga = new GotoAction();
     if (CodeCompletionActionsManager.CanGoTo(CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea))
     {
         CodeCompletionActionsManager.Rename(CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea);
     }
 }
Ejemplo n.º 3
0
        private void LabelEditFinished(object sender, NodeLabelEditEventArgs e)
        {
            this.tvProjectExplorer.LabelEdit = false;
            PascalABCCompiler.IFileInfo fi = items[e.Node] as PascalABCCompiler.IFileInfo;
            if (e.Label == null)
            {
                return;
            }
            if (!PascalABCCompiler.Tools.CheckFileNameValid(e.Label))
            {
                e.CancelEdit = true;
                MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_NAME"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (string.Compare(Path.GetExtension(e.Label), ".pas", true) != 0)
            {
                e.CancelEdit = true;
                MessageBox.Show(Form1StringResources.Get("INVALID_SOURCE_FILE_EXTENSION"), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (File.Exists(Path.Combine(Path.GetDirectoryName(fi.Name), e.Label)))
            {
                e.CancelEdit = true;
                MessageBox.Show(string.Format(Form1StringResources.Get("FILE_ALREADY_EXISTS{0}"), e.Label), PascalABCCompiler.StringResources.Get("!ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string oldFileName = fi.Path;

            ProjectFactory.Instance.RenameFile(fi, e.Label);
            if (oldFileName == ProjectFactory.Instance.CurrentProject.MainFile)
            {
                ProjectFactory.Instance.CurrentProject.MainFile = System.IO.Path.Combine(ProjectFactory.Instance.CurrentProject.ProjectDirectory, e.Label);
            }
            WorkbenchServiceFactory.FileService.RenameFile(oldFileName, fi.Path);
            CodeCompletionActionsManager.RenameUnit(fi.Path, Path.GetFileNameWithoutExtension(e.Label));
            string oldFileNameWithoutExt = Path.Combine(Path.GetDirectoryName(oldFileName), Path.GetFileNameWithoutExtension(oldFileName));
            string newFilePath           = Path.Combine(Path.GetDirectoryName(oldFileName), e.Label);

            if (File.Exists(oldFileNameWithoutExt + ".fmabc"))
            {
                string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc");
                File.Copy(fmabcFullName, Path.Combine(Path.GetDirectoryName(oldFileName), Path.GetFileNameWithoutExtension(e.Label) + ".fmabc"), true);
                File.Delete(fmabcFullName);
            }
            ProjectFactory.Instance.SaveProject();
            WorkbenchServiceFactory.FileService.SaveAll(false);
            WorkbenchServiceFactory.FileService.CloseFile(newFilePath);
            WorkbenchServiceFactory.FileService.OpenFile(newFilePath, Path.GetFileName(newFilePath));
            WorkbenchServiceFactory.DesignerService.SetActiveDesignerDirty();
            WorkbenchServiceFactory.DesignerService.GenerateAllDesignersCode();

            /*if (File.Exists(oldFileNameWithoutExt + ".resources"))
             * {
             *  string fmabcFullName = Path.Combine(Path.GetDirectoryName(oldFileName), oldFileNameWithoutExt + ".fmabc");
             *  File.Copy(fmabcFullName, Path.Combine(Path.GetDirectoryName(e.Label), Path.GetFileNameWithoutExtension(e.Label) + ".fmabc"), true);
             *  File.Delete(fmabcFullName);
             * }*/
        }
Ejemplo n.º 4
0
        private void __gaFindReferences(object state)
        {
            //GotoAction ga = new GotoAction();
            List <SymbolsViewerSymbol> syms = CodeCompletionActionsManager.FindReferences(__textarea);

            __syms_count = syms.Count;
            FindSymbolResults.Show(syms);
            BeginInvoke(new proc(__gaFindReferencesEnd));
        }
Ejemplo n.º 5
0
        private void OpeningContextMenu(object sender, CancelEventArgs args)
        {
            GotoAction ga = new GotoAction();
            TextArea   ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;

            this.cmGotoDefinition.Enabled      = CodeCompletionActionsManager.CanGoTo(ta);
            this.cmGotoRealization.Enabled     = CodeCompletionActionsManager.CanGoToRealization(ta);
            this.cmFindAllReferences.Enabled   = CodeCompletionActionsManager.CanFindReferences(ta);
            this.cmGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta);
            this.cmRename.Enabled = CodeCompletionActionsManager.CanGoTo(ta);
        }
Ejemplo n.º 6
0
 void tsIntellisense_DropDownOpened(object sender, EventArgs e)
 {
     if (UserOptions.AllowCodeCompletion)
     {
         //GotoAction ga = new GotoAction();
         TextArea ta = CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea;
         this.tsGotoDefinition.Enabled    = CodeCompletionActionsManager.CanGoTo(ta);
         this.tsGotoRealization.Enabled   = CodeCompletionActionsManager.CanGoToRealization(ta);
         this.tsFindAllReferences.Enabled = CodeCompletionActionsManager.CanFindReferences(ta);
         //this.cmFindAllReferences.Enabled = ga.CanFindReferences(ta);
         this.miGenerateRealization.Enabled = CodeCompletionActionsManager.CanGenerateRealization(ta);
     }
 }
        public static void DefinitionByMouseClickManager_TextAreaMouseDown(object sender, EventArgs e)
        {
            TextArea textArea = (TextArea)sender;

            if (Control.ModifierKeys == Keys.Control && textArea.SelectionManager.SelectionCollection.Count == 0)
            {
                gotoInProgress = true;
                if (CodeCompletionActionsManager.CanGoToRealization(textArea))
                {
                    CodeCompletionActionsManager.GotoRealization(textArea);
                }
                else if (CodeCompletionActionsManager.CanGoTo(textArea))
                {
                    CodeCompletionActionsManager.GotoDefinition(textArea);
                }
                gotoInProgress = false;
            }
        }
Ejemplo n.º 8
0
        private bool isDotNetItem(string s, ref Position position)
        {
            /*if (!File.Exists(DotNetHelpFileName))
             *  return false;*/
            switch (s.ToLower())
            {
            case "integer":
            case "real":
            case "byte":
            case "shortint":
            case "smallint":
            case "boolean":
            case "single":
            case "word":
            case "longword":
            case "uint64":
            case "longint":
            case "int64":
            case "char":
            case "string":
                return(false);
            }
            if (CodeCompletion.CodeCompletionController.CurrentParser == null)
            {
                return(false);
            }
            List <Position> poses = CodeCompletionActionsManager.GetDefinitionPosition(CurrentSyntaxEditor.TextEditor.ActiveTextAreaControl.TextArea, true);

            if (poses == null || poses.Count == 0)
            {
                return(false);
            }
            foreach (Position pos in poses)
            {
                if (pos.from_metadata)
                {
                    position = pos;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 9
0
        public override void Execute(TextArea _textArea)
        {
            //try
            {
                textArea = _textArea;
                int    off  = textArea.Caret.Offset;
                string text = textArea.Document.TextContent.Substring(0, textArea.Caret.Offset);
                if (key == '\0')
                {
                    if (off > 2 && text[off - 1] == '/' && text[off - 2] == '/' && text[off - 3] == '/')
                    {
                        CodeCompletionActionsManager.GenerateCommentTemplate(textArea);
                        return;
                    }
                    else
                    {
                        string prev = get_prev_text(text, off - 1);
                        if (!string.IsNullOrEmpty(prev))
                        {
                            CodeCompletionActionsManager.GenerateTemplate(prev, textArea);
                            return;
                        }
                    }
                }
                if (!WorkbenchServiceFactory.Workbench.UserOptions.CodeCompletionDot)
                {
                    return;
                }
                if (CodeCompletion.CodeCompletionController.CurrentParser == null)
                {
                    return;
                }
                CodeCompletionProvider completionDataProvider = new CodeCompletionProvider();

                bool is_pattern = false;


                is_begin = true;

                completionDataProvider.preSelection = CodeCompletion.CodeCompletionController.CurrentParser.LanguageInformation.FindPattern(off, text, out is_pattern);

                if (!is_pattern && off > 0 && text[off - 1] == '.')
                {
                    key = '$';
                }
                codeCompletionWindow = PABCNETCodeCompletionWindow.ShowCompletionWindow(
                    VisualPABCSingleton.MainForm,              // The parent window for the completion window
                    textArea.MotherTextEditorControl,          // The text editor to show the window for
                    textArea.MotherTextEditorControl.FileName, // Filename - will be passed back to the provider
                    completionDataProvider,                    // Provider to get the list of possible completions
                    key,                                       // Key pressed - will be passed to the provider
                    false,
                    false,
                    PascalABCCompiler.Parsers.KeywordKind.None
                    );
                key = '_';
                CodeCompletionNamesOnlyInModuleAction.comp_windows[textArea] = codeCompletionWindow;

                if (codeCompletionWindow != null)
                {
                    // ShowCompletionWindow can return null when the provider returns an empty list
                    codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                }
            }
            //catch (Exception e)
            {
            }
        }
Ejemplo n.º 10
0
 public override void Execute(TextArea textArea)
 {
     CodeCompletionActionsManager.GotoDefinition(textArea);
 }
Ejemplo n.º 11
0
 public override void Execute(TextArea textArea)
 {
     CodeCompletionActionsManager.GenerateMethodImplementationHeaders(textArea);
 }
Ejemplo n.º 12
0
 public override void Execute(TextArea textArea)
 {
     CodeCompletionActionsManager.GenerateClassOrMethodRealization(textArea);
 }
Ejemplo n.º 13
0
 public override void Execute(TextArea textArea)
 {
     CodeCompletionActionsManager.GenerateOverridableMethods(textArea);
 }
Ejemplo n.º 14
0
 private void GotoRealizationClicked(object sender, EventArgs args)
 {
     //GotoAction ga = new GotoAction();
     CodeCompletionActionsManager.GotoRealization(CurrentCodeFileDocument.TextEditor.ActiveTextAreaControl.TextArea);
 }