@@ -39,7 +39,7 @@ internal PythonEnvironment(GH_Component component, PythonScript script)
3939 }
4040
4141 var baseType = scriptType . BaseType ;
42- if ( baseType != null && baseType != typeof ( object ) )
42+ if ( baseType != null && baseType != typeof ( object ) )
4343 {
4444 var hostType = baseType . Assembly . GetType ( "RhinoPython.Host" ) ;
4545 if ( hostType != null )
@@ -84,12 +84,38 @@ internal PythonEnvironment(GH_Component component, PythonScript script)
8484
8585 public Version Version { get { return Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version ; } }
8686
87+ public IGH_DataAccess DataAccessManager { get ; internal set ; }
88+
8789 public void LoadAssembly ( Assembly assembly )
8890 {
8991 FunctionalityLoad ( assembly ) ;
9092
93+ IList list = GetIntellisenseList ( ) ;
94+ if ( list == null ) return ;
95+
96+ foreach ( var namesp in GetToplevelNamespacesForAssembly ( assembly ) )
97+ {
98+ if ( ! list . Contains ( namesp ) )
99+ list . Add ( namesp ) ;
100+ }
101+ }
102+
103+ public void AddGhPythonPackage ( )
104+ {
105+ IList list = GetIntellisenseList ( ) ;
106+ if ( list == null ) return ;
107+
108+ // add gh_python package
109+ if ( ! list . Contains ( "gh_python" ) )
110+ list . Add ( "gh_python" ) ;
111+ }
112+
113+ private IList GetIntellisenseList ( )
114+ {
115+ IList list = null ;
116+
91117 // now intellisense
92- if ( IntellisenseScope == null ) return ;
118+ if ( IntellisenseScope == null ) return list ;
93119
94120 // we really want to get intellisense right away. No matter what
95121 // so, we first make it cache, then add to it
@@ -101,21 +127,8 @@ public void LoadAssembly(Assembly assembly)
101127 var ex_m_autocomplete_modules = intellisense_type . GetField ( "m_autocomplete_modules" ,
102128 BindingFlags . GetField | BindingFlags . NonPublic | BindingFlags . Instance ) ;
103129
104- if ( ex_m_autocomplete_modules == null ) return ;
105- var list = ex_m_autocomplete_modules . GetValue ( Intellisense ) as IList ;
106-
107- if ( list == null ) return ;
108-
109- // add ghpython package
110- if ( ! list . Contains ( "ghpython" ) )
111- list . Add ( "ghpython" ) ;
112-
113-
114- foreach ( var namesp in GetToplevelNamespacesForAssembly ( assembly ) )
115- {
116- if ( ! list . Contains ( namesp ) )
117- list . Add ( namesp ) ;
118- }
130+ if ( ex_m_autocomplete_modules == null ) return list ;
131+ return ex_m_autocomplete_modules . GetValue ( Intellisense ) as IList ;
119132 }
120133
121134 private void FunctionalityLoad ( Assembly assembly )
@@ -134,9 +147,9 @@ private static IEnumerable<string> GetToplevelNamespacesForAssembly(Assembly ass
134147 // http://stackoverflow.com/questions/1549198/finding-all-namespaces-in-an-assembly-using-reflection-dotnet
135148 static string GetTopLevelNamespace ( Type t )
136149 {
137- string ns = t . Namespace ?? "" ;
138- int firstDot = ns . IndexOf ( '.' ) ;
139- return firstDot == - 1 ? ns : ns . Substring ( 0 , firstDot ) ;
150+ string ns = t . Namespace ?? "" ;
151+ int firstDot = ns . IndexOf ( '.' ) ;
152+ return firstDot == - 1 ? ns : ns . Substring ( 0 , firstDot ) ;
140153 }
141154 }
142155}
0 commit comments