Code intelligence in komodo
This presentation is the property of its rightful owner.
Sponsored Links
1 / 25

Code Intelligence in Komodo PowerPoint PPT Presentation


  • 85 Views
  • Uploaded on
  • Presentation posted in: General

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….

Download Presentation

Code Intelligence in Komodo

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Code intelligence in komodo

Code Intelligence in Komodo

Trent Mick

[email protected]


Code intelligence is

“Code Intelligence” is

  • a Code Browser

  • autocomplete and call tips


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…


Code intelligence system overview

Code Intelligence System Overview

Komodo

Python CILE

Perl CILE

Manager API

PHP CILE

Scheduler

Tcl CILE

Manager

XSLT CILE

SQL

C/C++ CILE

CIDB

COM CILE

CIX (XML)

Java CILE


Application

Application

Komodo

Python CILE

Python CILE

Perl CILE

Perl CILE

Manager API

PHP CILE

Scheduler

Tcl CILE

Manager

XSLT CILE

SQL

C/C++ CILE

CIDB

COM CILE

CIX (XML)

Java CILE


What we re going for

What we’re going for

Code Browser

Autocomplete

Call tips


Database

Database

Komodo

Python CILE

Python CILE

Perl CILE

Perl CILE

Manager API

PHP CILE

Scheduler

Tcl CILE

Manager

XSLT CILE

SQL

C/C++ CILE

CIDB

COM CILE

CIX (XML)

Java CILE


Database1

Database

Meta

  • 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

Files

Scans

Modules

Symbols


Xml description format cix

XML description format (CIX)

Komodo

Python CILE

Python CILE

Perl CILE

Perl CILE

Manager API

PHP CILE

Scheduler

Tcl CILE

Manager

XSLT CILE

C/C++ CILE

CIDB

COM CILE

CIX (XML)

Java CILE


Xml description format cix1

XML description format (CIX)

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

  • language-agnostic

  • storable and distributable


Xml description format cix2

XML description format (CIX)

      <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>

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


Language engines ciles

Language Engines (CILEs)

Komodo

Python CILE

Python CILE

Perl CILE

Perl CILE

Manager API

PHP CILE

Scheduler

Tcl CILE

Manager

XSLT CILE

SQL

C/C++ CILE

CIDB

COM CILE

CIX (XML)

Java CILE


Python language engine

Python Language Engine

Python Source Code

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

AST from compiler

Function('atof', ['s'], [], 0, 'atof(s) -> float...',

Stmt([

Return(

CallFunc(Name('_float'), [Name('s')], …)]))

CIX

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


Code intelligence in komodo

demo


Php language engine

PHP Language Engine

PHP Source Code

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

parse with regular expressions

CIX

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


Code intelligence in komodo

demo


Perl tcl xslt language engines

Perl, Tcl, XSLT Language Engines

  • 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


Scheduler

Scheduler

Komodo

Python CILE

Python CILE

Perl CILE

Perl CILE

Manager API

PHP CILE

Scheduler

Tcl CILE

Manager

XSLT CILE

SQL

C/C++ CILE

CIDB

COM CILE

CIX (XML)

Java CILE


Scheduler1

Scheduler

  • 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.


Code intelligence in komodo

demo


Tip import queue

Tip: 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.

Manager

Scheduler

s = Scheduler()

s.queue.put("scan string.py")

s.queue.put("scan string.php")

while 1:

request = self.queue.get()

# process request...


Tip import queue1

Tip: import Queue

  • This is a Priority Queue:

class PriorityQueue(Queue.Queue):

def _put(self, item):

bisect.insort(self.queue, item)


Autocomplete calltips

Autocomplete/Calltips

  • Type inferencing

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

  • Automatic triggering (language dependent):

    • Python: foo.

    • Perl:$foo->

    • PHP: pri


Possibilities

Possibilities

  • Other language engines:

    • C/C++, Java, COM, XML/XHTML

  • Distributing CIX files for binary packages

  • Custom user data in the database:

    • method frequency tracking


Thank you

Thank you

Questions?

Trent Mick ([email protected])


  • Login