Example #1
0
        private IList GetIntellisenseList()
        {
            IList list = null;

            // now intellisense
            if (IntellisenseScope == null)
            {
                return(list);
            }

            // we really want to get intellisense right away. No matter what
            // so, we first make it cache, then add to it

            var intellisense_type = Intellisense.GetType();
            var m = intellisense_type.GetMethod("GetModuleList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod);

            m.Invoke(Intellisense, null);

            var ex_m_autocomplete_modules = intellisense_type.GetField("m_autocomplete_modules",
                                                                       BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);

            if (ex_m_autocomplete_modules == null)
            {
                return(list);
            }
            return(ex_m_autocomplete_modules.GetValue(Intellisense) as IList);
        }
Example #2
0
        internal PythonEnvironment(GH_Component component, PythonScript script)
        {
            Component = component;
            Script    = script;

            if (script != null)
            {
                Type scriptType = script.GetType();

                var scopeField = scriptType.GetField("m_scope");
                if (scopeField != null)
                {
                    LocalScope = scopeField.GetValue(script);
                }

                var intellisenseField = scriptType.GetField("m_intellisense",
                                                            BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField);
                if (intellisenseField != null)
                {
                    Intellisense = intellisenseField.GetValue(script);
                    if (Intellisense != null)
                    {
                        var intellisenseType = Intellisense.GetType();
                        var scopeProperty    = intellisenseType.GetProperty("Scope");
                        IntellisenseScope = scopeProperty.GetValue(Intellisense, null);
                    }
                }

                var baseType = scriptType.BaseType;
                if (baseType != null && baseType != typeof(object))
                {
                    var hostType = baseType.Assembly.GetType("RhinoPython.Host");
                    if (hostType != null)
                    {
                        var engineInfo = hostType.GetProperty("Engine");
                        if (engineInfo != null)
                        {
                            Engine = engineInfo.GetValue(null, null);

                            if (Engine != null)
                            {
                                var runtimeInfo = Engine.GetType().GetProperty("Runtime");
                                Runtime = runtimeInfo.GetValue(Engine, null);
                            }
                        }

                        var scopeInfo = hostType.GetProperty("Scope", BindingFlags.NonPublic |
                                                             BindingFlags.GetProperty |
                                                             BindingFlags.Static);
                        if (scopeInfo != null)
                        {
                            ScriptScope = scopeInfo.GetValue(null, null);
                        }
                    }
                }
            }
        }
Example #3
0
        public ItemTemplate(Plugin plugin)
        {
            Name         = "";
            ID           = Guid.Empty;
            Intellisense = new Intellisense();

            AutoCompletionProvider = new IntellisenseProvider(Intellisense);
            Plugin = plugin;
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProgramEditor"/> class.
        /// </summary>
        public ProgramEditor()
        {
            syntaxChecker         = new SyntaxChecker();
            intellisense          = new Intellisense(TextArea);
            syntaxCheckVisualizer = new SyntaxCheckVisualizer(this);
            SyntaxCheckerMode     = SyntaxCheckerModeE.OnDemand;

            // Events
            Session.Instance.Highlighting.HighlightingChanged += LoadHighligtingDefinition;
            DataObject.AddPastingHandler(this, OnPaste);
        }
Example #5
0
        public virtual Completion[] GetModules(IGlyphService glyphService, string text)
        {
            var analysis = GetAnalysisEntry();
            var path     = text.Split('.');

            if (path.Length > 0)
            {
                // path = path[:-1]
                var newPath = new string[path.Length - 1];
                Array.Copy(path, newPath, path.Length - 1);
                path = newPath;
            }

            MemberResult[] modules = new MemberResult[0];
            if (path.Length == 0)
            {
                if (analysis != null)
                {
                    modules = analysis.ProjectState.GetModules(true);
                }

#if REPL
                var repl = Intellisense.GetRepl(_textBuffer);
                if (repl != null)
                {
                    modules = Intellisense.MergeMembers(modules, repl.GetModules());
                }
#endif
            }
            else
            {
                if (analysis != null)
                {
                    modules = analysis.ProjectState.GetModuleMembers(analysis.InterpreterContext, path);
                }
            }

            var sortedAndFiltered = NormalCompletionAnalysis.FilterCompletions(modules, text, (x, y) => x.StartsWith(y));
            Array.Sort(sortedAndFiltered, NormalCompletionAnalysis.ModuleSort);

            var result = new Completion[sortedAndFiltered.Length];
            for (int i = 0; i < sortedAndFiltered.Length; i++)
            {
                result[i] = PythonCompletion(glyphService, sortedAndFiltered[i]);
            }
            return(result);
        }
Example #6
0
 private List <string> GetContent(Intellisense intellisense, List <string> split, int level)
 {
     if (level == Level)
     {
         return(intellisense.Select(x => x.Name).ToList());
     }
     else
     {
         if (split.Count > level)
         {
             var intellisenseItem = intellisense.Where(x => x.Name == split[level]).FirstOrDefault();
             if (intellisenseItem != null)
             {
                 return(GetContent(intellisenseItem.Children, split, ++level));
             }
         }
         return(null);
     }
 }
Example #7
0
 private void UpdateIntellisenseContent()
 {
     if (Intellisense != null)
     {
         if (Level < 0)
         {
             ContentAssistSource = Intellisense.Select(x => x.Name).ToList();
         }
         else
         {
             var split    = CompleteWord.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries).ToList();
             var contents = GetContent(Intellisense, split, 0);
             if (contents != null)
             {
                 ContentAssistSource = contents;
             }
             else
             {
                 ContentAssistSource.Clear();
             }
         }
     }
 }
Example #8
0
 public void FeedDataForIntellisense(Intellisense intellisense)
 {
     Intellisense = intellisense;
     UpdateIntellisenseContent();
 }
Example #9
0
        public ViewModel()
        {
            var intellisense1 = new IntellisenseItem("Pakistan")
            {
                Children = new Intellisense()
                {
                    new IntellisenseItem("Punjab")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Lahore"),
                            new IntellisenseItem("Islamabad"),
                            new IntellisenseItem("Multan"),
                        }
                    },
                    new IntellisenseItem("Sindh")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Karachi"),
                            new IntellisenseItem("Hyderabad"),
                            new IntellisenseItem("Jamshoro"),
                            new IntellisenseItem("Jacobabad"),
                        }
                    },
                    new IntellisenseItem("KPK")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Peshawar"),
                            new IntellisenseItem("Abbottabad"),
                            new IntellisenseItem("Chitral"),
                            new IntellisenseItem("Swat"),
                        }
                    },
                    new IntellisenseItem("Balochistan")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Quetta"),
                            new IntellisenseItem("Gwadar"),
                            new IntellisenseItem("Chagai"),
                        }
                    }
                }
            };

            var intellisense2 = new IntellisenseItem("USA")
            {
                Children = new Intellisense()
                {
                    new IntellisenseItem("Alabama"),
                    new IntellisenseItem("California"),
                    new IntellisenseItem("Hawaii"),
                    new IntellisenseItem("Georgia")
                }
            };

            IntellisenseList = new Intellisense();
            IntellisenseList.Add(intellisense1);
            IntellisenseList.Add(intellisense2);
        }
 internal void AnalyzePackageJson(Intellisense.VsProjectAnalyzer analyzer) {
     analyzer.AddPackageJson(Url);
 }
Example #11
0
 public IntellisenseItem(string name)
 {
     Name     = name;
     Children = new Intellisense();
 }
Example #12
0
        public ViewModel()
        {
            var intellisense1 = new IntellisenseItem("Pakistan")
            {
                Children = new Intellisense()
                {
                    new IntellisenseItem("Punjab")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Lahore"),
                            new IntellisenseItem("Islamabad"),
                            new IntellisenseItem("Multan"),
                        }
                    },
                    new IntellisenseItem("Sindh")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Karachi"),
                            new IntellisenseItem("Hyderabad"),
                            new IntellisenseItem("Jamshoro"),
                            new IntellisenseItem("Jacobabad"),
                        }
                    },
                    new IntellisenseItem("KPK")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Peshawar"),
                            new IntellisenseItem("Abbottabad"),
                            new IntellisenseItem("Chitral"),
                            new IntellisenseItem("Swat"),
                        }
                    },
                    new IntellisenseItem("Balochistan")
                    {
                        Children = new Intellisense()
                        {
                            new IntellisenseItem("Quetta"),
                            new IntellisenseItem("Gwadar"),
                            new IntellisenseItem("Chagai"),
                        }
                    }
                }
            };

            var intellisense2 = new IntellisenseItem("USA")
            {
                Children = new Intellisense()
                {
                    new IntellisenseItem("Alabama"),                   
                    new IntellisenseItem("California"),
                    new IntellisenseItem("Hawaii"),
                    new IntellisenseItem("Georgia")
                }
            };

            IntellisenseList = new Intellisense();
            IntellisenseList.Add(intellisense1);
            IntellisenseList.Add(intellisense2);
        }
 public void FeedDataForIntellisense(Intellisense intellisense)
 {
     Intellisense = intellisense;
     UpdateIntellisenseContent();
 }
 private List<string> GetContent(Intellisense intellisense, List<string> split, int level)
 {
     if (level == Level)
     {
         return intellisense.Select(x => x.Name).ToList();
     }
     else
     {
         if (split.Count > level)
         {
             var intellisenseItem = intellisense.Where(x => x.Name == split[level]).FirstOrDefault();
             if (intellisenseItem != null)
             {
                 return GetContent(intellisenseItem.Children, split, ++level);
             }
         }
         return null;
     }
 }
 public IntellisenseProvider(Intellisense intellisense)
 {
     _intellisense = intellisense;
 }