Exemplo n.º 1
0
        public static void BuildIntellisenseDatabase()
        {
            string dir = System.Reflection.Assembly.GetEntryAssembly().Location;

            dir = System.IO.Path.GetDirectoryName(dir);
            dir = System.IO.Path.Combine(dir, "bin");
            string file = System.IO.Path.Combine(dir, "dump.h");

            if (watcher_ == null)
            {
                watcher_                     = new FileSystemWatcher(dir);
                watcher_.Changed            += watcher__Changed;
                watcher_.EnableRaisingEvents = true;
            }
            Thread thread = new Thread(delegate() {
                Globals globs     = new Globals(true);
                DumpParser parser = new DumpParser();
                try
                {
                    StringReader rdr = new StringReader(File.ReadAllText(file));
                    parser.ParseDumpFile(rdr, globs);
                    MainWindow.inst().Dispatcher.Invoke(delegate()
                    {
                        IDEProject.inst().GlobalTypes = globs;
                    });
                }
                catch (Exception ex)
                {
                    // swallow all exceptions
                }
            });

            thread.Start();
        }
Exemplo n.º 2
0
        public static void CreateDumps()
        {
            string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

            dir = System.IO.Path.Combine(dir, "bin");
            string parentDir = System.IO.Directory.GetParent(IDEProject.inst().ProjectDir).ToString();

            // Check for a source tree
            if (IDEProject.inst().Settings.SourceTree != null && IDEProject.inst().Settings.SourceTree.Length > 0)
            {
                parentDir = IDEProject.inst().Settings.SourceTree;
            }

            Thread thread = new Thread(delegate()
            {
                //Thread thread = new Thread(delegate() {
                Process pi                    = new Process();
                pi.StartInfo.FileName         = System.IO.Path.Combine(dir, "ScriptCompiler.exe");
                pi.StartInfo.Arguments        = " -dumpapi " + parentDir + " ScriptAPI.dox dump.h";
                pi.StartInfo.UseShellExecute  = false;
                pi.StartInfo.CreateNoWindow   = true;
                pi.StartInfo.WorkingDirectory = dir;
                pi.Start();
                pi.WaitForExit();
            });

            thread.Start();
        }
Exemplo n.º 3
0
 public override void DocumentChanged(TextEditor editor, FileBaseItem item)
 {
     MainWindow.inst().Dispatcher.Invoke(delegate()
     {
         Parsers.HLSLParser asp       = new Parsers.HLSLParser(GetHLSLGlobals());
         IDEProject.inst().LocalTypes = documentGlobals_ = asp.Parse(item.Path, System.IO.File.ReadAllText(item.Path), IDEProject.inst().Settings.GetIncludeDirectories());
     });
 }
Exemplo n.º 4
0
 // Present usage only wants classes
 public void MergeIntoThis(Globals other)
 {
     foreach (string k in other.Classes.Keys)
     {
         if (!Classes.ContainsKey(k))
             Classes[k] = IDEProject.inst().GlobalTypes.Classes[k];
     }
 }
Exemplo n.º 5
0
 public override Globals GetGlobals()
 {
     if (IDEProject.inst() == null)
     {
         return(null);
     }
     if (documentGlobals_ != null)
     {
         documentGlobals_.Parent = IDEProject.inst().GlobalTypes;
         return(documentGlobals_);
     }
     return(IDEProject.inst().GlobalTypes);
 }
 void docBtn_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (source != null)
     {
         string docName = source.Name + "::" + functions_[SelectedIndex].Name + functions_[SelectedIndex].Inner;
         IDEProject.inst().DocDatabase.Document(docName);
     }
     else
     {
         string docName = functions_[SelectedIndex].Name + functions_[SelectedIndex].Inner;
         IDEProject.inst().DocDatabase.Document(docName);
     }
 }
Exemplo n.º 7
0
        static void pi_ErrorDataReceived(object sender, DataReceivedEventArgs e)
        {
            IDEProject.inst().CompilerOutput += e.Data + "\r\n";
            if (e.Data == null)
            {
                return;
            }
            string str = e.Data;

            if (str.Contains("ERROR:"))
            {
                str = str.Replace("ERROR: ", "");
                int    firstColon = str.IndexOf(':');
                string fileName   = str.Substring(0, firstColon);

                string part   = "";
                int    line   = -1;
                int    column = -1;
                //move to first number
                ++firstColon;
                for (; firstColon < str.Length; ++firstColon)
                {
                    if (str[firstColon] == ',')
                    {
                        if (line == -1)
                        {
                            line = int.Parse(part);
                        }
                        else
                        {
                            column = int.Parse(part);
                        }
                    }
                    if (str[firstColon] == ' ')
                    {
                        break;
                    }
                    part += str[firstColon];
                }
                string       msg   = str.Substring(firstColon);
                CompileError error = new CompileError {
                    File    = IDEProject.inst().ProjectDir + fileName,
                    Line    = line,
                    Message = msg
                };
                MainWindow.inst().Dispatcher.Invoke(delegate() {
                    IDEProject.inst().CompileErrors.Add(error);
                });
            }
        }
        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)));
                if (treeViewItem == null)
                {
                    IDEProject.inst().DocDatabase.Document(pi.Name);
                }
                else
                {
                    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)));
                if (treeViewItem == null)
                {
                    IDEProject.inst().DocDatabase.Document(fi.Name + fi.Inner);
                }
                else
                {
                    TypeInfo parentType = treeViewItem.DataContext as TypeInfo;
                    IDEProject.inst().DocDatabase.Document(parentType.Name + "::" + fi.Name + fi.Inner);
                }
                return;
            }
        }
        public override Globals Parse(string path, string fileCode, string[] includePaths)
        {
            Globals ret = new Globals(false);

            // Merge global app registered types into it
            ret.Parent = IDEProject.inst().GlobalTypes;

            List <string> existingPaths = new List <string>();

            // Inline #includes
            fileCode = ProcessIncludes(path, fileCode, includePaths, existingPaths);
            // Strip comments
            fileCode = StripComments(fileCode);
            DepthScanner scanner = new DepthScanner();

            scanner.Process(fileCode);
            Parse(new StringReader(fileCode), scanner, ret);
            return(ret);
        }
Exemplo n.º 10
0
        public override void HookEditor(ICSharpCode.AvalonEdit.TextEditor editor, FileBaseItem item)
        {
            editor.SyntaxHighlighting = AvalonExtensions.LoadHighlightingDefinition("Debugger.Resources.Angelscript.xshd");

            editor.ContextMenu.Items.Add(new MenuItem
            {
                Header  = "Compile",
                Command = new RelayCommand(p =>
                {
                    IDEView.Compile();
                })
            });
            editor.ContextMenu.Items.Add(new Separator());
            editor.ContextMenu.Items.Add(new MenuItem
            {
                Header  = "New ScriptObject",
                Command = new RelayCommand(p =>
                {
                    editor.Document.BeginUpdate();
                    editor.Document.Insert(editor.CaretOffset, SOScript);
                    editor.Document.EndUpdate();
                })
            });
            editor.ContextMenu.Items.Add(new MenuItem
            {
                Header  = "Insert #include",
                Command = new RelayCommand(p =>
                {
                    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                    dlg.DefaultExt = "*";
                    dlg.Filter     = "All files (*.*)|*.*";
                    if (dlg.ShowDialog() == true)
                    {
                        editor.Document.BeginUpdate();
                        foreach (string incDir in IDEProject.inst().Settings.GetIncludeDirectories())
                        {
                            if (AngelscriptSource.isSubDir(incDir, dlg.FileName))
                            {
                                // Everything came from System.IO.Path, should be normal form
                                string strippedString = dlg.FileName.Replace(incDir + "\\", ""); //AngelscriptSource.MakeRelativePath(incDir, dlg.FileName);
                                editor.Document.Insert(editor.CaretOffset, string.Format("#include \"{0}\"", strippedString).Replace("\\", "/"));
                                editor.Document.EndUpdate();
                                return;
                            }
                        }
                        editor.Document.Insert(editor.CaretOffset, string.Format("#include \"{0}\"", dlg.FileName));
                        editor.Document.EndUpdate();
                    }
                })
            });
            editor.ContextMenu.Items.Add(new MenuItem
            {
                Header  = "Doxygen Comment",
                Command = new RelayCommand(p =>
                {
                    editor.Document.BeginUpdate();
                    editor.Document.Insert(editor.CaretOffset,
                                           @"/////////////////////////////////////////////////
/// DOCUMENT_HERE
/////////////////////////////////////////////////", AnchorMovementType.AfterInsertion);
                    editor.Document.EndUpdate();
                })
            });
            editor.ContextMenu.Items.Add(new MenuItem
            {
                Header  = "Property Comment",
                Command = new RelayCommand(p =>
                {
                    editor.Document.BeginUpdate();
                    editor.Document.Insert(editor.CaretOffset, "///< DOCUMENT", AnchorMovementType.AfterInsertion);
                    editor.Document.EndUpdate();
                })
            });
        }
Exemplo n.º 11
0
        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();
            }
        }
Exemplo n.º 12
0
 static void pi_OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     IDEProject.inst().CompilerOutput += e.Data + "\r\n";
 }
Exemplo n.º 13
0
        public static void Compile(string aToCompile)
        {
            string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

            dir += "\\bin\\ScriptCompiler.exe";

            //Thread thread = new Thread(delegate() {
            Process pi = new Process();

            pi.StartInfo.FileName               = dir;
            pi.StartInfo.Arguments              = aToCompile;
            pi.EnableRaisingEvents              = true;
            pi.StartInfo.UseShellExecute        = false;
            pi.StartInfo.CreateNoWindow         = true;
            pi.StartInfo.RedirectStandardOutput = true;
            pi.Start();
            pi.WaitForExit();

            string str = "";

            while ((str = pi.StandardOutput.ReadLine()) != null)
            {
                IDEProject.inst().CompilerOutput += str + "\r\n";

                if (str.Contains(','))
                {
                    int  firstColon = 0;
                    bool colonFond  = false;
                    for (; firstColon < str.Length; ++firstColon)
                    {
                        if (str[firstColon] == ':' && colonFond)
                        {
                            break;
                        }
                        else if (str[firstColon] == ':')
                        {
                            colonFond = true;
                        }
                    }
                    string fileName = str.Substring(0, firstColon);

                    string part   = "";
                    int    line   = -1;
                    int    column = -1;
                    //move to first number
                    ++firstColon;
                    for (; firstColon < str.Length; ++firstColon)
                    {
                        if (str[firstColon] == ',')
                        {
                            if (line == -1)
                            {
                                line = int.Parse(part);
                            }
                            else
                            {
                                column = int.Parse(part);
                            }
                        }
                        if (str[firstColon] == ' ')
                        {
                            break;
                        }
                        part += str[firstColon];
                    }
                    string       msg   = str.Substring(firstColon);
                    CompileError error = new CompileError {
                        File    = fileName,
                        Line    = line,
                        Message = msg
                    };
                    MainWindow.inst().Dispatcher.Invoke(delegate() {
                        IDEProject.inst().CompileErrors.Add(error);
                    });
                }
            }
            //});
            //thread.Start();
        }
Exemplo n.º 14
0
        public void EditorMouseHover(ICSharpCode.AvalonEdit.TextEditor editor, DepthScanner scanner, 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  = GetGlobals();
                    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)
                        {
                            BaseTypeInfo 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)
                                    {
                                        if (info is TypeInfo)
                                        {
                                            func = ((TypeInfo)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 && info is TypeInfo)
                                        {
                                            if (((TypeInfo)info).Properties.ContainsKey(words[i]))
                                            {
                                                info = ((TypeInfo)info).Properties[words[i]];
                                            }
                                        }
                                    }
                                }
                            }
                            else if (isFunc && words.Length == 1)
                            {
                                func = globs.GetFunction(words[0]);
                            }
                            else if (!isFunc && words.Length == 1)
                            {
                                info = reso.GetClassType(editor.Document, line, words[0]);
                                if (info == null)
                                {
                                    TypeInfo ty = globs.GetTypeInfo(words[0]);
                                    if (ty != null)
                                    {
                                        info = ty;
                                    }
                                }
                            }

                            string msg = "";
                            // Ask documentation for the information
                            if (info != null && func != null && info is TypeInfo)
                            { //member function
                                msg = func.ReturnType.Name + " " + func.Name;
                                string m = IDEProject.inst().DocDatabase.GetDocumentationFor(((TypeInfo)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 && info is TypeInfo)
                            { //global or member type
                                msg = ((TypeInfo)info).Name;
                                string m = IDEProject.inst().DocDatabase.GetDocumentationFor(((TypeInfo)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)
                {
                    //deliberately swallow any exceptions here
                }
            }
        }