140 likes | 271 Views
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?.
E N D
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? Integrate your extension or framework with PDT
EXAMPLES Zend Framework Testing Framework Advanced Code Analysis Syntax Coloring Extended Syntax Validation Run-time Analysis Adaptable Explorer
ARCHITECTURE Help Documentation Server Configuration UI View Test JUnit Testing Debug Protocol RelEng Release Tools Core Modeling PDT DLTK Language Support DTP Data Tools Platform Other Tools Source Editing Editor Capabilities Common Validations Web Services Development WTP All the Rest Web Tools EMF-XSD -SDO Modeling Framework GEF Graphical Editing Eclipse Platform Platform
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 IScriptModule IType IField IField IMethod IPackageFragment[] BuiltinProjectFragment
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);
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
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 withui.editor.highlighter.LineStyleProviderForPhp
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> */ publicinterface IElementChangedListener { publicvoid elementChanged(ElementChangedEvent event); }
LAUNCH CONFIGURATION • Based upon org.eclipse.debug • Debug session listener should extend org.eclipse.php.debug.core.debugger.IDebugHandler publicinterface IDebugHandler { publicvoid sessionStarted(String fileName, String uri, String query, String options); publicvoid sessionEnded(); publicvoid connectionTimedout(); publicvoid multipleBindOccured(); publicvoid handleScriptEnded(); publicvoid connectionEstablished(); publicvoid connectionClosed(); publicvoid newOutput(String output); publicvoid newHeaderOutput(String output); publicvoid parsingErrorOccured(DebugError debugError); publicvoid wrongDebugServer(); publicvoid ready(String fileName, int lineNumber); publicvoid debugChanged(); publicvoid debuggerErrorOccured(DebugError debugError); public IRemoteDebugger getRemoteDebugger(); publicvoid setDebugTarget (PHPDebugTarget debugTarget); public PHPDebugTarget getDebugTarget(); }
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
CONTACT & REFERENCES Wiki: http://wiki.eclipse.org/index.php/PDT Mailing listhttps://dev.eclipse.org/mailman/listinfo/pdt-dev Newsgroup http://www.eclipse.org/newsportal/thread.php?group=eclipse.tools.pdt Email: roy@zend.com