Architecture overview

pulse00 edited this page Jun 30, 2011 · 3 revisions

This is a brief overview for developers how the plugin works internally.

Core

Index

During the build phase the plugin parses all source files and indexes Symfony2 model elements:

  • Routes
  • Services
  • Bundles
  • Specific methods (for examples methods accepting a view path parameter like render($view, $params)

The Index is a simple H2 SQL database. For PHP ModelElements, the built-in DLTK Index is used. For model elements which are located in non php sourcefiles (xml/yaml), a custom H2 Database is used (org.eclipse.symfony.index).

The indexing consists of 2 different components:

SymfonyIndexingVisitorExtension

This class is a PDT extension and parses the PHP Abstract Syntax Tree (AST) to index model elements in the DLTK index. The index can be queried using various classes:

  • org.eclipse.dltk.core.index2.search.ModelAccess
  • org.eclipse.php.internal.core.model.PhpModelAccess
  • org.eclipse.symfony.core.model.SymfonyModelAccess

SymfonyBuilder

The SymfonyBuilder is a normal Eclipse project builder and parses xml and yaml files. It indexes the model elements like Routes and Services in a custom H2 database, which can be accessed via the following classes:

  • org.eclipse.symfony.core.model.SymfonyModelAccess
  • org.eclipse.symfony.index.SymfonyIndexer

Code Assist

Code assist works in 2 phases:

Context evaluation

The CodeAssist contexts evaluates if the cursor is inside a specific context when the user triggers codassist:

  • Are we inside a method parameter context like $this->render('| ?
  • Are we inside class method context like $request->| ?
  • etc.

Completion strategy

If the context isValid(), a corresponding completion strategy is applied, and reports keywords, methods and types.

Type inference

To help PDT to know what type a specific object is, goal evaluators are used, for example:

$session = $this->get('session');
$session->|

In this case PDT can't know which type the $session object is, and we help to evaluate the type using the services we previously indexed during the build phase.

User Interface

Highlighting

To highlight elements in the PHP editor which are domain specific, we can use Semantic Highlighting, ie AnnotationHighlighting.

Hyperlinks

To provide Hyperlinks for Symfony2 model elements, HyperlinkDetectors can be used.