14
© 2008 by Roy Ganor; made available under the EPL v1.0 | 19 th March 2008 Roy Ganor, Team Leader Zend Technologies, Ltd. March 19th 2008 EXTENDING THE ECLIPSE PHP DEVELOPMENT TOOLS PROJECT

EXTENDING THE ECLIPSE PHP DEVELOPMENT TOOLS PROJECT

Embed Size (px)

DESCRIPTION

EXTENDING THE ECLIPSE PHP DEVELOPMENT TOOLS PROJECT. Roy Ganor, Team Leader Zend Technologies, Ltd. March 19th 2008. PROJECT’S GOAL. Making Eclipse-PDT the de-facto standard for PHP development. Allowing extensibility due to the nature of PHP. WHY EXTEND?. - PowerPoint PPT Presentation

Citation preview

Page 1: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

© 2008 by Roy Ganor; made available under the EPL v1.0 | 19th March 2008

Roy Ganor, Team Leader Zend Technologies, Ltd.March 19th 2008

EXTENDING THE ECLIPSE PHP DEVELOPMENT TOOLS PROJECT

Page 2: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

Allowing extensibility

due to the nature of PHP

PROJECT’S GOAL

Making Eclipse-PDT the de-facto

standard for PHP development

Page 3: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

WHY EXTEND?

Integrate your extension or framework with PDT

Page 4: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

EXAMPLES

Zend Framework

TestingFramework

AdvancedCode Analysis

Run-time Analysis

Syntax Coloring

Extended SyntaxValidation

Adaptable Explorer

Page 5: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

ARCHITECTURE

EclipsePlatformPlatform

Web Tools

GEFGraphical Editing

EMF-XSD -SDOModeling Framework

Source EditingEditor Capabilities

CommonValidations

Web ServicesDevelopment

WTPAll the Rest

Other ToolsDLTK

Language Support

PDT

DTPData Tools Platform

UIView

CoreModeling

ServerConfiguration

DebugProtocol

HelpDocumentation

RelEngRelease Tools

TestJUnit Testing

Page 6: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

WORKSPACE MODELING

• Represents php projects in a tree structure, visualized by the “php Explorer" view

• Base class is org.eclipse.dltk.core.IModelElement

• Get model by ModelManager.getModelManager().getModel()

IScriptProject

IScriptFolder

IType

IField

IField

IMethod

IPackageFragment[]

BuiltinProjectFragment

IScriptModule

Page 7: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

CODE REPRESENTATION & MANIPULATION

• Based upon the Abstract Syntax Tree (AST)• Allows you to modify the tree and reflects

modifications in the php source code

// ... Create a Program AST instance ...

program.recordModifications();

// ... fetch the statement component ...

statements.add(ast.newEchoStatement (ast.newScalar("'Hello World!'")));

// .. More changes go here...

TextEdit edits = program.rewrite(document, null);

Page 8: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

SHARED AST PROVIDER

• Protected and shared AST (Rewriting is restricted)

SharedASTProvider.getAST(ISourceModule, WAIT_FLAG, IPM)

Mark occurrence feature is available by analyzing the shared AST

Page 9: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

PHP EDITOR

• Based upon wst.sse.ui.StructuredTextEditor

• Extend syntax coloring with: Setting your own source parser

internal.core.documentModel.parser.SourceParser Construct php regions

core.documentModel.parser.regions.IPhpScriptRegion

Set your coloring policy with ui.editor.highlighter.LineStyleProviderForPhp

Page 10: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

LISTEN TO ELEMENTS CHANGE

• Register by:DLTKCore.addElementChangedListener(IElementChangedListener)

• Unregister by:DLTKCore.removeElementChangedListener(IElementChangedListener)

/** * An element changed listener receives notification of changes to script * elements maintained by the script model. * <p>*/public interface IElementChangedListener {

public void elementChanged(ElementChangedEvent event);

}

/** * An element changed listener receives notification of changes to script * elements maintained by the script model. * <p>*/public interface IElementChangedListener {

public void elementChanged(ElementChangedEvent event);

}

Page 11: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

LAUNCH CONFIGURATION

• Based upon org.eclipse.debug

• Debug session listener should extend org.eclipse.php.debug.core.debugger.IDebugHandler

public interface IDebugHandler { public void sessionStarted(String fileName, String uri, String query, String options); public void sessionEnded(); public void connectionTimedout(); public void multipleBindOccured(); public void handleScriptEnded(); public void connectionEstablished(); public void connectionClosed(); public void newOutput(String output); public void newHeaderOutput(String output); public void parsingErrorOccured(DebugError debugError); public void wrongDebugServer(); public void ready(String fileName, int lineNumber); public void debugChanged(); public void debuggerErrorOccured(DebugError debugError); public IRemoteDebugger getRemoteDebugger(); public void setDebugTarget (PHPDebugTarget debugTarget); public PHPDebugTarget getDebugTarget();}

public interface IDebugHandler { public void sessionStarted(String fileName, String uri, String query, String options); public void sessionEnded(); public void connectionTimedout(); public void multipleBindOccured(); public void handleScriptEnded(); public void connectionEstablished(); public void connectionClosed(); public void newOutput(String output); public void newHeaderOutput(String output); public void parsingErrorOccured(DebugError debugError); public void wrongDebugServer(); public void ready(String fileName, int lineNumber); public void debugChanged(); public void debuggerErrorOccured(DebugError debugError); public IRemoteDebugger getRemoteDebugger(); public void setDebugTarget (PHPDebugTarget debugTarget); public PHPDebugTarget getDebugTarget();}

Page 12: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

KEY EXTENSION POINTS

• org.eclipse.php.core includePathVariable goalEvaluatorFactory phpBuilderExtensions phpModelExtensions

• org.eclipse.php.ui phpContentAssistProcessor

• org.eclipse.php.debug.core phpDebugHandlers phpDebugParametersInitializer

• More: http://wiki.eclipse.org/images/5/54/API_PDT.pdf

Page 13: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

CONTACT & REFERENCES

Wiki: http://wiki.eclipse.org/index.php/PDT

Mailing list https://dev.eclipse.org/mailman/listinfo/pdt-dev

Newsgrouphttp://www.eclipse.org/newsportal/thread.php?group=eclipse.tools.pdt

Email: [email protected]

Page 14: EXTENDING THE ECLIPSE  PHP DEVELOPMENT TOOLS PROJECT

Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0

Questions?