code intelligence in komodo

25
Code Intelligence in Komod Code Intelligence in Code Intelligence in Komodo Komodo Trent Mick [email protected] om

Upload: lizina

Post on 03-Feb-2016

35 views

Category:

Documents


0 download

DESCRIPTION

Code Intelligence in Komodo. Trent Mick [email protected]. “Code Intelligence” is. a Code Browser autocomplete and call tips. What in it for me?. See how an IDE Code Browser can be built Learn about some useful Python packages Couldn’t find Mitch Kapor and lunch isn’t served yet, so…. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Code Intelligence in Komodo

Code Intelligence in Komodo

Code Intelligence in Code Intelligence in KomodoKomodo

Trent Mick

[email protected]

Page 2: Code Intelligence in Komodo

Code Intelligence in Komodo

““Code Intelligence” isCode Intelligence” is

a Code Browser

autocomplete and call tips

Page 3: Code Intelligence in Komodo

Code Intelligence in Komodo

What in it for me?What in it for me?

See how an IDE Code Browser can be built

Learn about some useful Python packages

Couldn’t find Mitch Kapor and lunch isn’t served yet, so…

Page 4: Code Intelligence in Komodo

Code Intelligence in Komodo

Code Intelligence System Code Intelligence System OverviewOverview

Manager

CIDB

Scheduler

Komodo

Manager API

SQL

Python CILE

Perl CILE

PHP CILE

Tcl CILE

XSLT CILE

C/C++ CILE

COM CILE

Java CILE

CIX (XML)

Page 5: Code Intelligence in Komodo

Code Intelligence in Komodo

ApplicationApplication

Manager

CIDB

Scheduler

Komodo

Manager API

SQL

Python CILE

Perl CILE

PHP CILE

Tcl CILE

XSLT CILE

C/C++ CILE

COM CILE

Java CILE

CIX (XML)

Python CILE

Perl CILE

Page 6: Code Intelligence in Komodo

Code Intelligence in Komodo

What we’re going forWhat we’re going for

Code BrowserAutocomplete

Call tips

Page 7: Code Intelligence in Komodo

Code Intelligence in Komodo

DatabaseDatabase

Manager

CIDB

Scheduler

Komodo

Manager API

SQL

Python CILE

Perl CILE

PHP CILE

Tcl CILE

XSLT CILE

C/C++ CILE

COM CILE

Java CILE

CIX (XML)

Python CILE

Perl CILE

Page 8: Code Intelligence in Komodo

Code Intelligence in Komodo

DatabaseDatabase

SQLite for database Separate “Files” and

“Modules” for Perl and Tcl

Allow multiple scanners per file (e.g. Python, COM, and PyXPCOM)

Tip: include a “Meta” table

Meta

Files

Scans

Modules

Symbols

Page 9: Code Intelligence in Komodo

Code Intelligence in Komodo

XML description format XML description format (CIX)(CIX)

Manager

CIDB

Scheduler

Komodo

Manager API

Python CILE

Perl CILE

PHP CILE

Tcl CILE

XSLT CILE

C/C++ CILE

COM CILE

Java CILE

CIX (XML)

Python CILE

Perl CILE

Page 10: Code Intelligence in Komodo

Code Intelligence in Komodo

XML description format XML description format (CIX)(CIX)

language-agnostic storable and distributable

       <codeintel version="0.1">            <file path="foo.py" generator="Python"                  language="Python"                  md5="…">                ...            </file>        </codeintel>

Page 11: Code Intelligence in Komodo

Code Intelligence in Komodo

XML description format XML description format (CIX)(CIX)

<module>, <function>, <class>, <interface>, <argument>, <doc>, <variable>, etc. tags define structure of the code

       <codeintel version="0.1">            <file path="string.py" ...>                <module name="string">                    <function line="199" name="atof">                        <doc><![CDATA[atof(s) -> float ...]]></doc>                        <argument name="s"/>                    </function>                </module>            </file>        </codeintel>

Page 12: Code Intelligence in Komodo

Code Intelligence in Komodo

Language Engines Language Engines (CILEs)(CILEs)

Manager

CIDB

Scheduler

Komodo

Manager API

SQL

Python CILE

Perl CILE

PHP CILE

Tcl CILE

XSLT CILE

C/C++ CILE

COM CILE

Java CILE

CIX (XML)

Python CILE

Perl CILE

Page 13: Code Intelligence in Komodo

Code Intelligence in Komodo

Python Language Python Language EngineEngine

 198    # Convert string to float  199    def atof(s):  200        """atof(s) -> float  201      202        Return the floating point …  203      204        """  205        return _float(s)

Function('atof', ['s'], [], 0, 'atof(s) -> float...', Stmt([ Return( CallFunc(Name('_float'), [Name('s')], …)]))

<module name="string">      <function line="199" name="atof">           <doc><![CDATA[atof(s) -> float ...]]></doc>

          <argument name="s"/>      </function> </module>

Python Source Code

AST from compiler

CIX

Page 14: Code Intelligence in Komodo

Code Intelligence in Komodo

demo

Page 15: Code Intelligence in Komodo

Code Intelligence in Komodo

PHP Language EnginePHP Language Engine

   2    <?php    3    # atof(s) -> float    4    # ...    5    function atof($s) {    6        return _float($s);    7    }    8    ?>

<module name="string.php">      <function line="199" name="atof">           <doc><![CDATA[atof(s) -> float ...]]></doc>

          <argument name="s"/>      </function> </module>

PHP Source Code

parse with regular expressions

CIX

Page 16: Code Intelligence in Komodo

Code Intelligence in Komodo

demo

Page 17: Code Intelligence in Komodo

Code Intelligence in Komodo

Perl, Tcl, XSLT Language Perl, Tcl, XSLT Language EnginesEngines

The only thing that can parse Perl is Perl (but scintilla comes close)

Tcl can parse Tcl

Tclwrap can make an executable from Tcl

libxml can parse XSLT

Page 18: Code Intelligence in Komodo

Code Intelligence in Komodo

SchedulerScheduler

Manager

CIDB

Scheduler

Komodo

Manager API

SQL

Python CILE

Perl CILE

PHP CILE

Tcl CILE

XSLT CILE

C/C++ CILE

COM CILE

Java CILE

CIX (XML)

Python CILE

Perl CILE

Page 19: Code Intelligence in Komodo

Code Intelligence in Komodo

SchedulerScheduler

Info must update dynamically as the user types, but not interfere with editing: i.e. asynchronous

“Scheduler” is a thread that manages a small pool of “Scan Runner” threads to scan file content.

Page 20: Code Intelligence in Komodo

Code Intelligence in Komodo

demo

Page 21: Code Intelligence in Komodo

Code Intelligence in Komodo

Tip: import QueueTip: import Queue

From the Python Library Reference:

The Queue module implements a multi-producer, multi-consumer FIFO queue. It is especially useful in threads programming when information must be exchanged safely between multiple threads.

s = Scheduler()s.queue.put("scan string.py")s.queue.put("scan string.php")

while 1: request = self.queue.get() # process request...

Manager Scheduler

Page 22: Code Intelligence in Komodo

Code Intelligence in Komodo

Tip: import QueueTip: import Queue

This is a Priority Queue:

class PriorityQueue(Queue.Queue): def _put(self, item): bisect.insort(self.queue, item)

Page 23: Code Intelligence in Komodo

Code Intelligence in Komodo

Autocomplete/CalltipsAutocomplete/Calltips

Type inferencing c.f. Mike Salib’s “Starkiller” talk tomorrow

Automatic triggering (language dependent): Python: foo.

Perl: $foo->

PHP: pri

Page 24: Code Intelligence in Komodo

Code Intelligence in Komodo

PossibilitiesPossibilities

Other language engines: C/C++, Java, COM, XML/XHTML

Distributing CIX files for binary packages

Custom user data in the database: method frequency tracking

Page 25: Code Intelligence in Komodo

Code Intelligence in Komodo

Thank youThank you

Questions?

Trent Mick ([email protected])