Post on 08-Jan-2016
description
© 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
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
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
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
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
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
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);
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
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
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);
}
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();}
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
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: roy@zend.com
Extending The PDT Project | Architecture and Extension Points | © 2008 by Roy Ganor; made available under the EPL v1.0
Questions?