Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=4798429
By: vbeloborodov

How to PyDev + IronPython + code completion for Common Language Runtime.

1) Install IronPython (1.1.1), PyDev (1.3.13) and standart python library 
(tested
library from FePy).
2) Make backup copy of directory PySrc (located in
%ECLIPSEHOME%/plugins/org.python.pydev_1.3.13).
3) Apply path to directory PySrc (see below).
4) Setup IronPython interpreter for PyDev and add namespaces from CLR (eg: 
System,
System.Data, System.Windows.Forms,...) to "Forced builtin libs".
5) Done! You have limited code completion for CLR objects.

Limitations: Working only if [Imported Namespace] = [Assembly Name] (but you
can add reference to any Assembly in importsTipper.py)

=================== Path-Start =====================

--- importsTipper.py    Mon Feb 04 14:07:22 2008
+++ importsTipper.py    Mon Feb 25 02:07:16 2008
@@ -16,9 +16,22 @@
 
 TYPE_BUILTIN_AS_STR = '4'
 
+if sys.platform == "cli":
+    import clr
+    def _clr_imp(name):
+        try:
+            return __import__(name)
+        except:
+            clr.AddReference( name )
+            return __import__( name )
+               
+       
 def _imp(name):
     try:
-        return __import__(name)
+        if sys.platform == "cli":
+            return _clr_imp( name )
+        else:
+            return __import__(name)
     except:
         if '.' in name:
             sub = name[0:name.rfind('.')]
@@ -30,12 +43,15 @@
 def GetFile(mod):
     f = None
     try:
-        f = inspect.getsourcefile(mod) or inspect.getfile(mod)
+        if sys.platform != "cli":
+            f = inspect.getsourcefile(mod) or inspect.getfile(mod)
     except:
+        pass
+    if f is None:
         if hasattr(mod,'__file__'):
-            f = mod.__file__
-            if f.lower(f[-4:]) in ['.pyc', '.pyo']:
-                filename = f[:-4] + '.py'
+            filename = str(mod.__file__)
+            if filename[-4:].lower() in ['.pyc', '.pyo']:
+                filename = filename[:-4] + '.py'
                 if os.path.exists(filename):
                     f = filename
             
@@ -155,7 +171,7 @@
     ret = []
     
     dirComps = dir( mod )
-    if hasattr(mod, '__dict__'):
+    if hasattr(mod, '__dict__') and sys.platform != "cli": 
         dirComps.append('__dict__')
         
     getCompleteInfo = True
@@ -283,7 +299,7 @@
                     retType = TYPE_ATTR
                 #ok, no complete info, let's try to do this as fast and clean
as possible
                 #so, no docs for this kind of information, only the signatures
-                ret.append(   (d, '', args, retType)   )
+                ret.append(   (d, '', args, str(retType))   )
             
     return ret
 
--- pycompletionserver.py       Mon Feb 04 14:07:22 2008
+++ pycompletionserver.py       Mon Feb 25 02:57:22 2008
@@ -3,6 +3,8 @@
 @author Fabio Zadrozny 
 '''
 
+import sys
+
 try:
     import java.lang
     True = 1
@@ -25,18 +27,34 @@
         
     IS_JYTHON = False
     SERVER_NAME = 'pycompletionserver'
-    from threading import Thread
     import importsTipper
-    try:
-        import refactoring
-    except:
+    if sys.platform == "cli":
+        import System, System.Threading
+
+        class Thread:
+            def __init__(self):
+                self._thread = None
+            def run(self):
+                pass
+            def start(self):
+                self._thread = System.Threading.Thread(
System.Threading.ThreadStart( self.run) )
+                self._thread.Start()
+
         class RefactoringWrapper:
             def HandleRefactorMessage(*args, **kwargs):
                 return ''
         refactoring = RefactoringWrapper()
+    else:
+        from threading import Thread
+        try:
+            import refactoring
+        except:
+            class RefactoringWrapper:
+                def HandleRefactorMessage(*args, **kwargs):
+                    return ''
+            refactoring = RefactoringWrapper()
 
 
-import sys
 #initial sys.path
 _sys_path = []
 for p in sys.path:
@@ -315,6 +333,7 @@
                                 
                             else:
                                 returnMsg = MSG_INVALID_REQUEST
+
                     except :
                         dbg( SERVER_NAME+' exception ocurred', ERROR )
                         s = StringIO.StringIO()
====================== Path-End ===========================

==
Vadim


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit: 
https://sourceforge.net/forum/unmonitor.php?forum_id=293649

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pydev-users mailing list
Pydev-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pydev-users

Reply via email to