Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button btn = sender as Button;

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            if (dlg.ShowDialog() == true)
            {
                if (btn.Tag.Equals("run"))
                {
                    IDEProject.inst().Settings.RunExe = dlg.FileName;
                }
                else if (btn.Tag.Equals("debug"))
                {
                    IDEProject.inst().Settings.DebugExe = dlg.FileName;
                }
                else if (btn.Tag.Equals("compile"))
                {
                    IDEProject.inst().Settings.CompilerPath = dlg.FileName;
                }
                else if (btn.Tag.Equals("sourcetree"))
                {
                    IDEProject.inst().Settings.SourceTree = dlg.FileName;
                }
            }
        }
Пример #2
0
        public static void Compile()
        {
            if (IDEProject.inst().Settings.CompilerPath == null || IDEProject.inst().Settings.CompilerPath.Trim().Length == 0)
            {
                if (ModernDialog.ShowMessage("You need to set a compile file in settings", "No princess here", System.Windows.MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    IDESettingsDlg dlg = new IDESettingsDlg();
                    dlg.ShowDialog();
                }
                return;
            }
            IDEProject.inst().CompilerOutput = "";
            IDEProject.inst().CompileErrors.Clear();
            foreach (PluginLib.ICompilerService comp in PluginManager.inst().Compilers)
            {
                comp.CompileFile(IDEProject.inst().Settings.CompilerPath, IDEProject.inst(), ErrorHandler.inst());
            }
            //Activity.CompilerActivity.Compile(IDEProject.inst().Settings.CompilerPath);
            if (IDEProject.inst().CompileErrors.Count != 0)
            {
                Dlg.CompErrDlg dlg = new Dlg.CompErrDlg();
                dlg.ShowDialog();
            }

            if (IDEProject.inst().CompileErrors.Count == 0)
            {
                foreach (PluginLib.ICompilerService comp in PluginManager.inst().Compilers)
                {
                    comp.PostCompile(IDEProject.inst().Settings.CompilerPath, IDEProject.inst().Settings.SourceTree, ErrorHandler.inst());
                }
                Dlg.CompSuccessDlg dlg = new Dlg.CompSuccessDlg();
                dlg.ShowDialog();
            }
        }
        private void errorDoubleClick(object sender, MouseEventArgs args)
        {
            DataGridRow row = sender as DataGridRow;

            PluginLib.CompileError result = row.DataContext as PluginLib.CompileError;
            foreach (string str in IDEProject.inst().GetIncludeDirs())
            {
                string path = System.IO.Path.Combine(IDEProject.inst().ProjectDir, str);
                path = System.IO.Path.Combine(path, result.File);
                if (System.IO.File.Exists(path))
                {
                    IDEEditor editor = ideTabs.OpenFile(new FileLeafItem
                    {
                        Path = path,
                        Name = System.IO.Path.GetFileName(path)
                    });
                    if (result.Line != -1)
                    {
                        editor.Editor.TextArea.Caret.Line = result.Line;
                        editor.Editor.ScrollToLine(result.Line);
                    }
                    return;
                }
            }
        }
Пример #4
0
 private void txtSearchString_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         Activity.SearchActivity.doSearch(txtSearchString.Text, IDEProject.inst().ProjectDir);
     }
 }
Пример #5
0
        private void onDocumentClasses(object sender, RoutedEventArgs e)
        {
            MenuItem    item = sender as MenuItem;
            ContextMenu menu = item.CommandParameter as ContextMenu;

            TypeInfo ti = (menu.PlacementTarget as StackPanel).Tag as TypeInfo;

            if (ti != null)
            {
                IDEProject.inst().DocDatabase.Document(ti.Name);
                return;
            }
            PropInfo pi = (menu.PlacementTarget as StackPanel).Tag as PropInfo;

            if (pi != null)
            {
                // Get the parent treeitem
                TreeViewItem treeViewItem = VisualUpwardSearch(VisualTreeHelper.GetParent(VisualUpwardSearch(menu.PlacementTarget as DependencyObject)));
                TypeInfo     parentType   = treeViewItem.DataContext as TypeInfo;
                IDEProject.inst().DocDatabase.Document(parentType.Name + "::" + pi.Name);
                return;
            }
            FunctionInfo fi = (menu.PlacementTarget as StackPanel).Tag as FunctionInfo;

            if (fi != null)
            {
                TreeViewItem treeViewItem = VisualUpwardSearch(VisualTreeHelper.GetParent(VisualUpwardSearch(menu.PlacementTarget as DependencyObject)));
                TypeInfo     parentType   = treeViewItem.DataContext as TypeInfo;
                IDEProject.inst().DocDatabase.Document(parentType.Name + "::" + fi.Name + fi.Inner);
                return;
            }
        }
Пример #6
0
 public static void Compile()
 {
     if (IDEProject.inst().Settings.CompilerPath == null || IDEProject.inst().Settings.CompilerPath.Trim().Length == 0)
     {
         if (ModernDialog.ShowMessage("You need to set a compile file in settings", "No princess here", System.Windows.MessageBoxButton.OKCancel) == MessageBoxResult.OK)
         {
             IDESettingsDlg dlg = new IDESettingsDlg();
             dlg.ShowDialog();
         }
         return;
     }
     IDEProject.inst().CompilerOutput = "";
     IDEProject.inst().CompileErrors.Clear();
     Activity.CompilerActivity.Compile(IDEProject.inst().Settings.CompilerPath);
     if (IDEProject.inst().CompileErrors.Count != 0)
     {
         Dlg.CompErrDlg dlg = new Dlg.CompErrDlg();
         dlg.ShowDialog();
     }
     else
     {
         Dlg.CompSuccessDlg dlg = new Dlg.CompSuccessDlg();
         dlg.ShowDialog();
     }
 }
Пример #7
0
        public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
        {
            if (IDEProject.inst() == null)
            {
                IDEProject.open();
                System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog();
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    IDEProject.inst().Settings   = IDESettings.GetOrCreate(dlg.SelectedPath);
                    IDEProject.inst().ProjectDir = dlg.SelectedPath;
                    UserData.inst().AddRecentFile(dlg.SelectedPath);
                }
                else
                {
                    MainWindow.inst().ContentSource = new Uri("Screens/LaunchScreen.xaml", UriKind.Relative);
                    IDEProject.inst().destroy();
                    return;
                }
            }

            if (IDEProject.inst() == null)
            {
                project_ = new IDEProject();
            }
            else
            {
                project_ = IDEProject.inst();
            }
            if (folder_ == null)
            {
                folder_ = new Folder {
                    Path = project_.ProjectDir
                }
            }
            ;
            fileTree.DataContext         = folder_;
            objectTree.DataContext       = IDEProject.inst();
            txtConsole.DataContext       = IDEProject.inst();
            gridErrors.DataContext       = IDEProject.inst();
            errorTabCount.DataContext    = IDEProject.inst();
            stackErrorHeader.DataContext = IDEProject.inst();

            eventsDoc.Tree.DataContext = IDEProject.inst().Documentation.DocumentNode.Children[0];
            eventsDoc.CommandText      = new string[] { "Copy Subscription", "Copy Unsubscription" };
            eventsDoc.CommandFormats   = new string[] { "SubscribeToEvent(\"{0}\",\"Handle{0}\");", "UnsubscribeFromEvent(\"Handle{0}\");" };
            eventsDoc.LowerText        = new string[] { "Copy event getter" };
            eventsDoc.LowerCommands    = new string[] { "eventData[\"{0}\"];" };

            attrDoc.Tree.DataContext   = IDEProject.inst().Documentation.DocumentNode.Children[1];
            scriptDoc.Tree.DataContext = IDEProject.inst().Documentation.DocumentNode.Children[2];
            //eventsDoc.MiddleMenuBuilder = new Controls.EventSubscriptionDocMenu();
            //eventsDoc.BottomMenuBuilder = new Controls.EventDataDocMenu();
            //eventsDoc.Root = IDEProject.inst().Documentation.DocumentNode.Children[0];
            //attrDoc.Shallow = true;
            //attrDoc.MiddleMenuBuilder = new Controls.AttrDocMenu();
            //attrDoc.Root = IDEProject.inst().Documentation.DocumentNode.Children[1];
            //scriptDoc.Shallow = true;
            //scriptDoc.Root = IDEProject.inst().Documentation.DocumentNode.Children[2];
        }
Пример #8
0
 public IDESettingsDlg()
 {
     InitializeComponent();
     txtCompileFile.DataContext = IDEProject.inst().Settings;
     txtDebugExe.DataContext    = IDEProject.inst().Settings;
     txtDebugParams.DataContext = IDEProject.inst().Settings;
     txtRunExe.DataContext      = IDEProject.inst().Settings;
     txtRunParams.DataContext   = IDEProject.inst().Settings;
 }
        public static void Compile()
        {
            if (IDEProject.inst().Settings.CompilerPath == null || IDEProject.inst().Settings.CompilerPath.Trim().Length == 0)
            {
                if (ModernDialog.ShowMessage("You need to set a compile file in settings", "No princess here", System.Windows.MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    IDESettingsDlg dlg = new IDESettingsDlg();
                    dlg.ShowDialog();
                }
                return;
            }
            IDEProject.inst().CompilerOutput = "";
            IDEProject.inst().CompileErrors.Clear();
            PluginLib.ICompilerService comp = null;

            if (IDEProject.inst().Settings.Compiler != null && IDEProject.inst().Settings.Compiler.Length > 0)
            {
                comp = PluginManager.inst().Compilers.FirstOrDefault(c => c.Name.Equals(IDEProject.inst().Settings.Compiler));
                if (comp == null)
                {
                    ModernDialog.ShowMessage(String.Format("Unable to find compiler: \"{0}\"", IDEProject.inst().Settings.Compiler), "Error", MessageBoxButton.OK);
                    return;
                }
            }
            else
            {
                comp = PluginManager.inst().Compilers.FirstOrDefault();
                if (comp == null)
                {
                    ModernDialog.ShowMessage("No compiler plugins are installed", "Error", MessageBoxButton.OK);
                    return;
                }
            }


            Parago.Windows.ProgressDialogResult result = Parago.Windows.ProgressDialog.Execute(null, "Compiling...", (a, b) => {
                comp.CompileFile(IDEProject.inst().Settings.CompilerPath, IDEProject.inst(), ErrorHandler.inst());

                MainWindow.inst().Dispatcher.Invoke(delegate() {
                    if (IDEProject.inst().CompileErrors.Count != 0)
                    {
                        Dlg.CompErrDlg dlg = new Dlg.CompErrDlg();
                        dlg.ShowDialog();
                    }

                    if (IDEProject.inst().CompileErrors.Count == 0)
                    {
                        foreach (PluginLib.ICompilerService c in PluginManager.inst().Compilers)
                        {
                            c.PostCompile(IDEProject.inst().Settings.CompilerPath, IDEProject.inst().Settings.SourceTree, ErrorHandler.inst());
                        }
                        Dlg.CompSuccessDlg dlg = new Dlg.CompSuccessDlg();
                        dlg.ShowDialog();
                    }
                });
            });
        }
Пример #10
0
        private void errorDoubleClick(object sender, MouseEventArgs args)
        {
            DataGridRow  row    = sender as DataGridRow;
            CompileError result = row.DataContext as CompileError;
            IDEEditor    editor = ideTabs.OpenFile(new FileLeafItem {
                Path = result.File,
                Name = result.File.Replace(IDEProject.inst().ProjectDir, "")
            });

            if (result.Line != -1)
            {
                editor.Editor.TextArea.Caret.Line = result.Line;
                editor.Editor.ScrollToLine(result.Line);
            }
        }
        public IDESettingsDlg() {
            foreach (PluginLib.ICompilerService compiler in PluginManager.inst().Compilers)
                compilers_.Add(new Compiler { Name = compiler.Name, Value = compiler.Name });

            InitializeComponent();
            txtCompileFile.DataContext = IDEProject.inst().Settings;
            txtDebugExe.DataContext = IDEProject.inst().Settings;
            txtDebugParams.DataContext = IDEProject.inst().Settings;
            txtRunExe.DataContext = IDEProject.inst().Settings;
            txtRunParams.DataContext = IDEProject.inst().Settings;
            txtSourceTree.DataContext = IDEProject.inst().Settings;
            comboCompile.ItemsSource = compilers_;
            comboCompile.DataContext = IDEProject.inst().Settings;
            txtIncludePaths.DataContext = IDEProject.inst().Settings;
        }
Пример #12
0
 public static void open(string aPath = "")
 {
     if (aPath == string.Empty)
     {
         inst_ = new IDEProject();
     }
     else
     {
         try {
             IDEProject.open(); //Interesting?
         }
         catch (Exception ex) {
             ErrorHandler.inst().Error(ex);
         }
     }
 }
Пример #13
0
 public bool NewProject()
 {
     Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
     dlg.DefaultExt = "prj";
     dlg.Filter     = "Project files (*.prj)|*.prj";
     if (dlg.ShowDialog() == true)
     {
         IDEProject prj = new IDEProject()
         {
             FilePath = dlg.FileName, ProjectDir = Path.GetDirectoryName(dlg.FileName)
         };
         prj.Settings = IDESettings.GetOrCreate(dlg.FileName);
         prj.Save();
         UserData.inst().AddRecentFile(dlg.FileName);
     }
     return(false);
 }
Пример #14
0
 public string[] GetIncludeDirectories()
 {
     if (IncludePaths != null)
     {
         string[] paths = IncludePaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
         for (int i = 0; i < paths.Length; ++i)
         {
             paths[i] = paths[i].Trim();
             // Root the path if need be
             if (!System.IO.Path.IsPathRooted(paths[i]))
             {
                 paths[i] = System.IO.Path.Combine(IDEProject.inst().ProjectDir, paths[i]);
             }
         }
         return(paths);
     }
     return(null);
 }
Пример #15
0
        private void btnDebug_Click(object sender, RoutedEventArgs e)
        {
            if (IDEProject.inst().Settings.RunExe == null || IDEProject.inst().Settings.RunExe.Trim().Length == 0)
            {
                if (ModernDialog.ShowMessage("You need to set a 'debug' target", "Debug what?", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    btnSettings_Click(null, null);
                }
                return;
            }
            Process pi = new Process();

            pi.StartInfo.FileName               = IDEProject.inst().Settings.DebugExe;
            pi.StartInfo.Arguments              = IDEProject.inst().Settings.CompilerPath + " " + IDEProject.inst().Settings.DebugParams;
            pi.EnableRaisingEvents              = true;
            pi.StartInfo.UseShellExecute        = false;
            pi.StartInfo.CreateNoWindow         = false;
            pi.StartInfo.RedirectStandardOutput = false;
            pi.Start();
        }
 private void txtSearchString_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         if (comboSearchType.SelectedItem == null)
         {
             return;
         }
         searchResults_.Clear();
         string selSearchKind = comboSearchType.SelectedItem.ToString();
         foreach (PluginLib.ISearchService searchService in PluginManager.inst().SearchServices)
         {
             if (searchService.Name.Equals(selSearchKind))
             {
                 searchService.Search(IDEProject.inst().ProjectDir, new string[] { txtSearchString.Text }, this);
                 break;
             }
         }
     }
 }
Пример #17
0
        public void Draw(TextView textView, System.Windows.Media.DrawingContext drawingContext)
        {
            if (pen == null)
            {
                pen = new Pen(textView.FindResource("WavyBrush") as Brush, 4);
            }
            Size renderSize = textView.RenderSize;

            if (textView != null && textView.VisualLinesValid)
            {
                foreach (VisualLine line in textView.VisualLines)
                {
                    PluginLib.CompileError err = IDEProject.inst().CompileErrors.FirstOrDefault(l => l.Line == line.FirstDocumentLine.LineNumber && l.File.Equals(file.Path));
                    if (err != null)
                    {
                        drawingContext.DrawLine(pen,
                                                new Point(0, line.VisualTop + line.Height - textView.ScrollOffset.Y),
                                                new Point(renderSize.Width, line.VisualTop - textView.ScrollOffset.Y + line.Height));
                    }
                }
            }
        }
Пример #18
0
 public IDEProject()
 {
     inst_          = this;
     documentation_ = new API.APIDocumentation();
     docDatabase_   = new Docs.DocDatabase();
 }
Пример #19
0
        void editor_KeyUp(object sender, KeyEventArgs e)
        {
            // These keys halt and terminate intellisense
            switch (e.Key)
            {
            case Key.Home:
            case Key.End:
            case Key.Left:
            case Key.Right:
            case Key.Escape:
            case Key.LWin:
            case Key.RWin:
            case Key.Space:
                if (currentComp != null)
                {
                    currentComp.Close();
                }
                return;
            }
            // These keys halt further checks
            switch (e.Key)
            {
            case Key.Up:
            case Key.Down:
            case Key.PageDown:
            case Key.PageUp:
            case Key.LeftShift:
            case Key.RightShift:
            case Key.LeftAlt:
            case Key.RightAlt:
            case Key.LeftCtrl:
            case Key.RightCtrl:
            case Key.Scroll:
            case Key.Capital:
            case Key.CrSel:
            case Key.Clear:
            case Key.Insert:
            case Key.PrintScreen:
            case Key.Print:
                return;
            }

            char KEY = KeyHelpers.GetCharFromKey(e.Key);

            if (KEY == ')' || KEY == ';')
            {
                if (currentComp != null)
                {
                    currentComp.Close();
                }
                return;
            }
            int curOfs = editor.TextArea.Caret.Offset;
            int line   = editor.TextArea.Caret.Line;

            // Do not attempt intellisense inside of comments
            string txt = editor.Document.GetText(editor.Document.Lines[editor.TextArea.Caret.Line - 1]);

            if (txt.Trim().StartsWith("//"))
            {
                return;
            }

            if (e.Key == Key.OemPeriod || KEY == ':')
            {
                //IntellisenseHelper.ResemblesDotPath(editor.Document, curOfs-1, line-1)) {
                int ofs = TextUtilities.GetNextCaretPosition(editor.Document, curOfs, LogicalDirection.Backward, CaretPositioningMode.WordStart);
                ofs = TextUtilities.GetNextCaretPosition(editor.Document, ofs, LogicalDirection.Backward, CaretPositioningMode.WordStart);
                string word = "";
                for (; ofs < curOfs; ++ofs)
                {
                    if (editor.Document.Text[ofs] != '.')
                    {
                        word += editor.Document.Text[ofs];
                    }
                }

                NameResolver reso  = new NameResolver(IDEProject.inst().GlobalTypes, scanner);
                BaseTypeInfo info  = null;
                string[]     words = IntellisenseHelper.DotPath(editor.Document, curOfs - 1, line - 1);
                if (words.Length > 1)
                {
                    for (int i = 0; i < words.Length - 1; ++i)
                    {
                        if (info == null)
                        {
                            info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]);
                        }
                        else if (info != null)
                        {
                            info = info.ResolvePropertyPath(IDEProject.inst().GlobalTypes, words[i]);
                            //if (info.Properties.ContainsKey(words[i]))
                            //    info = info.Properties[words[i]];
                        }
                    }
                }

                bool functionsOnly = false;
                //attempt to resolve it locally
                if (info == null)
                {
                    info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, word);
                }
                //attempt to resolve it from globals
                if (info == null && IDEProject.inst().GlobalTypes != null && IDEProject.inst().GlobalTypes.Properties.ContainsKey(word))
                {
                    info = IDEProject.inst().GlobalTypes.Properties[word];
                }
                if (info == null && word.Contains("::"))
                {
                    if (IDEProject.inst().GlobalTypes == null)
                    {
                        return;
                    }
                    if (word.Length > 2)
                    {
                        if (IDEProject.inst().GlobalTypes.Classes.ContainsKey(word.Replace("::", "")))
                        {
                            EnumInfo ti = IDEProject.inst().GlobalTypes.Classes[word.Replace("::", "")] as EnumInfo;
                            if (ti != null)
                            {
                                currentComp = new CompletionWindow(editor.TextArea);
                                IList <ICompletionData> data = currentComp.CompletionList.CompletionData;
                                foreach (string str in ti.Values)
                                {
                                    data.Add(new BaseCompletionData(null, str));
                                }
                                currentComp.Show();
                                currentComp.Closed += comp_Closed;
                                return;
                            }
                            else
                            {
                                TypeInfo ty = IDEProject.inst().GlobalTypes.Classes.FirstOrDefault(p => p.Key.Equals(word.Replace("::", ""))).Value;
                                if (ty != null)
                                {
                                    info          = ty;
                                    functionsOnly = true;
                                }
                            }
                        }
                        else     //list global functions
                        {
                            Globals globs = IDEProject.inst().GlobalTypes;
                            currentComp = new CompletionWindow(editor.TextArea);
                            IList <ICompletionData> data = currentComp.CompletionList.CompletionData;
                            foreach (string str in globs.Properties.Keys)
                            {
                                data.Add(new PropertyCompletionData(globs.Properties[str], str));
                            }
                            foreach (FunctionInfo fi in globs.Functions)
                            {
                                data.Add(new FunctionCompletionData(fi));
                            }
                            currentComp.Show();
                            currentComp.Closed += comp_Closed;
                            return;
                        }
                    }
                }

                //build the list
                if (info != null && info is TypeInfo)
                {
                    TypeInfo ti = info as TypeInfo;
                    currentComp = new CompletionWindow(editor.TextArea);
                    IList <ICompletionData> data = currentComp.CompletionList.CompletionData;
                    if (!functionsOnly)
                    {
                        foreach (string str in ti.Properties.Keys)
                        {
                            data.Add(new PropertyCompletionData(ti.Properties[str], str, ti.ReadonlyProperties.Contains(str)));
                        }
                    }
                    foreach (FunctionInfo fi in ti.Functions)
                    {
                        data.Add(new FunctionCompletionData(fi));
                    }
                    currentComp.Show();
                    currentComp.Closed += comp_Closed;
                }
            }
            else if (KEY == '(' && IntellisenseHelper.ResemblesDotPath(editor.Document, curOfs - 2, line - 1))
            {
                NameResolver reso  = new NameResolver(IDEProject.inst().GlobalTypes, scanner);
                TypeInfo     info  = null;
                FunctionInfo func  = null;
                string[]     words = IntellisenseHelper.DotPath(editor.Document, curOfs - 2, line - 1);
                if (words.Length > 1)
                {
                    for (int i = 0; i < words.Length; ++i)
                    {
                        if (i == words.Length - 1 && info != null)
                        {
                            func = info.Functions.FirstOrDefault(f => f.Name.Equals(words[i]));
                        }
                        else
                        {
                            if (info == null)
                            {
                                info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]);
                            }
                            else if (info != null)
                            {
                                if (info.Properties.ContainsKey(words[i]))
                                {
                                    info = info.Properties[words[i]];
                                }
                            }
                        }
                    }
                }
                if (func != null)
                {
                    List <FunctionInfo> data = new List <FunctionInfo>();
                    foreach (FunctionInfo fi in info.Functions.Where(f => { return(f.Name.Equals(func.Name)); }))
                    {
                        data.Add(fi);
                    }
                    if (data.Count > 0)
                    {
                        OverloadInsightWindow window = new OverloadInsightWindow(editor.TextArea);
                        window.Provider = new OverloadProvider(info, data.ToArray());
                        window.Show();
                        //compWindow.Closed += comp_Closed;
                    }
                }
                else if (func == null && info == null) // Found nothing
                {
                    List <FunctionInfo> data = new List <FunctionInfo>();
                    foreach (FunctionInfo fi in IDEProject.inst().GlobalTypes.Functions.Where(f => { return(f.Name.Equals(words[1])); }))
                    {
                        data.Add(fi);
                    }
                    if (data.Count > 0)
                    {
                        OverloadInsightWindow window = new OverloadInsightWindow(editor.TextArea);
                        window.Provider = new OverloadProvider(info, data.ToArray());
                        window.Show();
                        //compWindow.Closed += comp_Closed;
                    }
                }
            }
            else if (Char.IsLetter(KEY))
            {
                if (currentComp != null || editor.TextArea.Caret.Line == 1)
                {
                    return;
                }

                int ofs     = TextUtilities.GetNextCaretPosition(editor.Document, curOfs, LogicalDirection.Backward, CaretPositioningMode.WordStart);
                int nextOfs = TextUtilities.GetNextCaretPosition(editor.Document, ofs, LogicalDirection.Backward, CaretPositioningMode.WordStart);
                if (nextOfs > 0)
                {
                    if (editor.Document.Text[nextOfs] == '.')
                    {
                        return;
                    }
                }
                string word = "";
                if (ofs < 0)
                {
                    return;
                }
                for (; ofs < curOfs; ++ofs)
                {
                    if (editor.Document.Text[ofs] != '.')
                    {
                        word += editor.Document.Text[ofs];
                    }
                }
                if (word.Contains("."))
                {
                    if (currentComp != null)
                    {
                        currentComp.Close();
                    }
                    //editor_KeyUp(sender, e);
                    return;
                }

                NameResolver  reso        = new NameResolver(IDEProject.inst().GlobalTypes, scanner);
                List <string> suggestions = new List <string>();
                reso.GetNameMatch(editor.Document, editor.TextArea.Caret.Line - 1, word, ref suggestions);

                CompletionWindow compWindow = new CompletionWindow(editor.TextArea);
                compWindow.StartOffset = TextUtilities.GetNextCaretPosition(editor.Document, curOfs, LogicalDirection.Backward, CaretPositioningMode.WordStart);
                IList <ICompletionData> data = compWindow.CompletionList.CompletionData;
                //attempt local name resolution first
                if (suggestions.Count > 0)
                {
                    foreach (string str in suggestions) //text suggestions are of lower priority
                    {
                        data.Add(new BaseCompletionData(null, str)
                        {
                            Priority = 0.5
                        });
                    }
                }
                //Scal globals
                if (IDEProject.inst().GlobalTypes != null)
                {
                    foreach (string str in IDEProject.inst().GlobalTypes.Classes.Keys)
                    {
                        if (str.StartsWith(word))
                        {
                            data.Add(new ClassCompletionData(IDEProject.inst().GlobalTypes.Classes[str]));
                        }
                    }
                    foreach (FunctionInfo fun in IDEProject.inst().GlobalTypes.Functions)
                    {
                        if (fun.Name.StartsWith(word))
                        {
                            data.Add(new FunctionCompletionData(fun));
                        }
                    }
                }
                if (data.Count > 0)
                {
                    currentComp = compWindow;
                    currentComp.Show();
                    currentComp.Closed += comp_Closed;
                }
            }
        }
Пример #20
0
        void editor_MouseHover(object sender, MouseEventArgs e)
        {
            TextViewPosition?pos = editor.GetPositionFromPoint(e.GetPosition(editor));

            if (pos != null)
            {
                try {
                    int     line   = pos.Value.Line;
                    int     offset = editor.Document.GetOffset(pos.Value.Location);
                    Globals globs  = IDEProject.inst().GlobalTypes;
                    if (globs != null)
                    {
                        bool     isFunc = false;
                        string[] words  = IntellisenseHelper.ExtractPath(editor.Document, offset, pos.Value.Location.Line, out isFunc);
                        if (words != null && words.Length > 0)
                        {
                            TypeInfo     info = null;
                            FunctionInfo func = null;
                            NameResolver reso = new NameResolver(globs, scanner);
                            if (words.Length > 1)
                            {
                                for (int i = 0; i < words.Length; ++i)
                                {
                                    if (i == words.Length - 1 && info != null && isFunc)
                                    {
                                        func = info.Functions.FirstOrDefault(f => f.Name.Equals(words[i]));
                                    }
                                    else
                                    {
                                        if (info == null)
                                        {
                                            info = reso.GetClassType(editor.Document, editor.TextArea.Caret.Line, words[i]);
                                        }
                                        else if (info != null)
                                        {
                                            if (info.Properties.ContainsKey(words[i]))
                                            {
                                                info = info.Properties[words[i]];
                                            }
                                        }
                                    }
                                }
                            }
                            else if (isFunc && words.Length == 1)
                            {
                                func = globs.Functions.FirstOrDefault(f => f.Name.Equals(words[0]));
                            }
                            else if (!isFunc && words.Length == 1)
                            {
                                info = reso.GetClassType(editor.Document, line, words[0]);
                                if (info == null)
                                {
                                    KeyValuePair <string, TypeInfo> ty = globs.Classes.FirstOrDefault(p => p.Value.Equals(words[0]));
                                    if (ty.Value != null)
                                    {
                                        info = ty.Value;
                                    }
                                }
                            }

                            string msg = "";
                            // Ask documentation for the information
                            if (info != null && func != null)   //member function
                            {
                                msg = func.ReturnType.Name + " " + func.Name;
                                string m = IDEProject.inst().DocDatabase.GetDocumentationFor(info.Name + "::" + func.Name + func.Inner);
                                if (m != null)
                                {
                                    msg += "\r\n" + m;
                                }
                            }
                            else if (func != null)     //global function
                            {
                                msg = func.ReturnType.Name + " " + func.Name;
                                string m = IDEProject.inst().DocDatabase.GetDocumentationFor(func.Name + func.Inner);
                                if (m != null)
                                {
                                    msg += "\r\n" + m;
                                }
                            }
                            else if (info != null)     //global or member type
                            {
                                msg = info.Name;
                                string m = IDEProject.inst().DocDatabase.GetDocumentationFor(info.Name);
                                if (m != null)
                                {
                                    msg += "\r\n" + m;
                                }
                            }

                            if (msg.Length > 0)
                            {
                                InsightWindow window = new InsightWindow(editor.TextArea);
                                window.Content = msg;
                                window.Show();
                            }
                        }
                    }
                }
                catch (Exception ex) { }
            }
        }
        public void OnNavigatedTo(FirstFloor.ModernUI.Windows.Navigation.NavigationEventArgs e)
        {
            if (e.NavigationType == FirstFloor.ModernUI.Windows.Navigation.NavigationType.New)
            {
                if (IDEProject.inst() == null)
                {
                    IDEProject.open();
                    System.Windows.Forms.FolderBrowserDialog dlg = new System.Windows.Forms.FolderBrowserDialog();
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        IDEProject.inst().Settings   = IDESettings.GetOrCreate(dlg.SelectedPath);
                        IDEProject.inst().ProjectDir = dlg.SelectedPath;
                        UserData.inst().AddRecentFile(dlg.SelectedPath);
                    }
                    else
                    {
                        MainWindow.inst().ContentSource = new Uri("Screens/LaunchScreen.xaml", UriKind.Relative);
                        IDEProject.inst().destroy();
                        return;
                    }
                }

                if (IDEProject.inst() == null)
                {
                    project_ = new IDEProject();
                }
                else
                {
                    project_ = IDEProject.inst();
                }
                if (folder_ == null)
                {
                    folder_ = new Folder {
                        Path = project_.ProjectDir
                    }
                }
                ;
                if (fileTree.DataContext == null)
                {
                    fileTree.DataContext = folder_;
                }
                Action <object> searchAction = delegate(object o)
                {
                    if (o == null)
                    {
                        return;
                    }
                    leftSideTabs.SelectedItem = classesTab;
                    objectTree.SelectItemNamed(((PropInfo)o).Type.Name);
                };
                objectTree.DataContext    = IDEProject.inst();
                objectTree.ItemBinding    = new Binding("GlobalTypes.TypeInfo");
                objectTree.CallOnViewType = searchAction;

                globalsTree.DataContext    = IDEProject.inst();
                globalsTree.CallOnViewType = searchAction;
                globalsTree.ItemBinding    = new Binding("GlobalTypes.UIView");

                localsTree.DataContext    = IDEProject.inst();
                localsTree.CallOnViewType = searchAction;
                localsTree.ItemBinding    = new Binding("LocalTypes.AllUIView");

                txtConsole.DataContext       = IDEProject.inst();
                gridErrors.DataContext       = IDEProject.inst();
                errorTabCount.DataContext    = IDEProject.inst();
                stackErrorHeader.DataContext = IDEProject.inst();

                if (infoTabs.Items.Count == 0)
                {
                    foreach (PluginLib.IInfoTab infoTab in PluginManager.inst().InfoTabs)
                    {
                        PluginLib.IExternalControlData data = infoTab.CreateTabContent(IDEProject.inst().ProjectDir);
                        if (data == null)
                        {
                            continue;
                        }
                        TabItem item = new TabItem
                        {
                            Header  = infoTab.GetTabName(),
                            Tag     = data,
                            Content = data.Control
                        };
                        infoTabs.Items.Add(item);
                    }
                }
            }
            else
            {
                infoTabs.Items.Clear();
            }
        }
Пример #22
0
 public void destroy()
 {
     inst_ = null;
 }
Пример #23
0
 public IDEProject()
 {
     inst_        = this;
     docDatabase_ = new Docs.DocDatabase();
     errors_.CollectionChanged += (o, p) => { OnPropertyChanged("CompileWarningCt"); OnPropertyChanged("CompileErrorCt"); };
 }