SlideShare une entreprise Scribd logo
1  sur  46
Deepak Azad   JDT/UI Committer [email_address] Satyam Kandula   JDT/Core Committer [email_address] Extending JDT – Become a JDT tool smith
[object Object],[object Object],[object Object],[object Object],Outline
[object Object],[object Object],[object Object],[object Object],[object Object],Target Audience
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Overview – The 3 Pillars
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],The 3 Pillars – First Pillar: Java Model
The Java Model - Design Motivation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java Elements API ,[object Object],[object Object],[object Object],[object Object],[object Object],IProject IFolder IFile IJavaProject IPackageFragmentRoot IPackageFragment ICompilationUnit / IClassFile IType IMethod element.getParent() element.getChildren() IField IInitialzier javaElement.getResource() JavaCore.create(resource)
Java Element Handles ,[object Object],[object Object],[object Object],[object Object],[object Object],String handleId= javaElement. getHandleIdentifier (); IJavaElement elem= JavaCore. create (handleId);
Using the Java Model ,[object Object],[object Object],[object Object],[object Object],IJavaProject javaProject= JavaCore.create(project); javaProject. setRawClasspath (classPath, defaultOutputLocation, null); Set the Java build path IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); IProject project= root.getProject(projectName); project. create (null); project. open (null); Create a project IProjectDescription description = project.getDescription(); description. setNatureIds (new String[] { JavaCore.NATURE_ID }); project. setDescription (description, null); Set the Java nature
Java Classpath ,[object Object],[object Object]
Classpath – Source and Library Entries ,[object Object],[object Object],[object Object],[object Object],IPath srcPath= javaProject.getPath().append("src"); IPath[] excluded= new IPath[] { new Path("doc") }; IClasspathEntry srcEntry=  JavaCore.newSourceEntry (srcPath, excluded); ,[object Object],[object Object],[object Object]
Java Classpath: Container Entries ,[object Object],[object Object],[object Object],[object Object],[object Object],entry= JavaCore. newContainerEntry (new Path("containerId/containerArguments")); jreCPEntry= JavaCore. newContainerEntry (new Path(JavaRuntime.JRE_CONTAINER)); ,[object Object],[object Object],[object Object],[object Object]
Creating Java Elements IJavaProject javaProject= JavaCore.create(project); IClasspathEntry[] buildPath= { JavaCore.newSourceEntry(project.getFullPath().append("src")), JavaRuntime.getDefaultJREContainerEntry() };  javaProject. setRawClasspath (buildPath, project.getFullPath().append("bin"), null); IFolder folder= project. getFolder ("src"); folder. create (true, true, null); IPackageFragmentRoot srcFolder= javaProject. getPackageFragmentRoot (folder); Assert.assertTrue(srcFolder. exists ());  // resource exists and is on build path IPackageFragment fragment= srcFolder. createPackageFragment ("x.y", true, null); String str= "package x.y;"  + "" + "public class E  {"  + "" + "  String first;"  + "" +  "}"; ICompilationUnit cu= fragment. createCompilationUnit ("E.java", str, false, null); IType type= cu. getType ("E"); type. createField ("String name;", null, true, null);  Set the build path Create the source folder Create the package fragment Create the compilation unit, including a type Create a field
Java Project Settings ,[object Object],[object Object],[object Object],javaProject. setOption (JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5); ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Java Element Change Notifications ,[object Object],[object Object],[object Object],[object Object],[object Object],IJavaElementDelta: Description of changes of an element or its children JavaCore. addElementChangedListener (IElementChangedListener) F_ADDED_TO_CLASSPATH, F_SOURCEATTACHED, F_REORDER, F_PRIMARY_WORKING_COPY,… Deltas in children  IJavaElementDelta[] getAffectedChildren() F_CHILDREN Changed modifiers F_MODIFIERS Content has changed. If F_FINE_GRAINED is set: Analysis of structural changed has been performed F_CONTENT CHANGED Element has been removed REMOVED Element has been added ADDED Descriptions and additional flags Delta kind
Type Hierarchy - Design Motivation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Type Hierarchy ,[object Object],[object Object]
Type Hierarchy Create – on a type or on a region (= set of Java Elements) typeHierarchy= type.newTypeHierarchy(progressMonitor); typeHierarchy= project.newTypeHierarchy(region, progressMonitor); Supertype hierarchy – faster! typeHierarchy= type.newSupertypeHierarchy(progressMonitor); Get super and subtypes, interfaces and classes typeHierarchy.getSubtypes(type) Change listener – when changed, refresh is required typeHierarchy.addTypeHierarchyChangedListener(..); typeHierarchy.refresh(progressMonitor);
Code Resolve ,[object Object],[object Object],javaElements= compilationUnit.codeSelect(50, 10);
Code Resolve – an Example Resolving the reference to “String” in a compilation unit String content =  "public class X {"  + "" + "  String field;"  + "" + "}"; ICompilationUnit cu= fragment. createCompilationUnit (“X.java", content, false, null); int start = content.indexOf("String"); int length = "String".length(); IJavaElement[] declarations = cu. codeSelect (start, length); Contains a single IType: ‘java.lang.String’ Set up a compilation unit
More Java Model Features ,[object Object],IType type= javaProject.findType( " java.util.Vector " ); ,[object Object],compilationUnit.codeComplete(offset, resultRequestor); ,[object Object],ToolFactory.createCodeFormatter(options)   .format(kind, string, offset, length, indentationLevel, lineSeparator); ,[object Object],element= compilationUnit.getElementAt(position);
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Second Pillar: Search Engine
Search Engine – Design Motivation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Search Engine ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Search Engine – Using the APIs ,[object Object],[object Object],[object Object],[object Object],[object Object],SearchPattern.createPattern("foo*", IJavaSearchConstants.FIELD, IJavaSearchConstants.REFERENCES, SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE); SearchEngine.createWorkspaceScope(); SearchEngine.createJavaSearchScope(new IJavaElement[] { project }); SearchEngine.createHierarchyScope(type); SearchEngine.createStrictHierarchyScope( project, type, onlySubtypes, includeFocusType, progressMonitor);
Search Engine – an Example ,[object Object],SearchPattern pattern =  SearchPattern.createPattern (   "foo(*) int",    IJavaSearchConstants.METHOD,    IJavaSearchConstants.DECLARATIONS,  SearchPattern.R_PATTERN_MATCH); IJavaSearchScope scope = SearchEngine. createWorkspaceScope (); SearchRequestor requestor = new SearchRequestor() { public void acceptSearchMatch(SearchMatch match) { System.out.println(match.getElement()); } }; SearchEngine searchEngine = new SearchEngine(); searchEngine.search ( pattern,  new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant()},  scope,  requestor,  null   /*progress monitor*/); Search pattern Search scope Result collector Start search
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],The 3 Pillars – Third Pillar: AST
Abstract Syntax Tree - Design Motivation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Abstract Syntax Tree Source Code ASTParser#createAST(...) AST ReturnStatement InfixExpression MethodInvocation  SimpleName expression rightOperand leftOperand IMethodBinding resolveBinding
Abstract Syntax Tree cond’t ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creating an AST ,[object Object],[object Object],[object Object],[object Object],[object Object]
Creating an AST ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creating an AST ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource( cu ); parser.setResolveBindings(true); parser.setStatementsRecovery(true); ASTNode node= parser. createAST (null); Create AST on an element ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource( "System.out.println();" .toCharArray()); parser.setProject(javaProject); parser.setKind(ASTParser.K_STATEMENTS); parser.setStatementsRecovery(false); ASTNode node= parser. createAST (null); Create AST on source string
AST Browsing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],List allProperties= node. structuralPropertiesForType (); expression= node. getStructuralProperty (ConditionalExpression.EXPRESSION_PROPERTY); Will contain 3 elements of type ‘StructuralPropertyDescriptor’: ConditionalExpression.EXPRESSION_PROPERTY, ConditionalExpression.THEN_EXPRESSION_PROPERTY,  ConditionalExpression.ELSE_EXPRESSION_PROPERTY ,
ASTView Demo ASTView and JavaElement view: http://www.eclipse.org/jdt/ui/update-site
AST View ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Bindings ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Bindings cont’d ,[object Object],[object Object],[object Object],[object Object]
AST Visitor ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource(cu); parser.setResolveBindings(true); ASTNode root= parser.createAST(null); root.accept (new ASTVisitor() { public boolean  visit (CastExpression node) { fCastCount++ ; return true; } public boolean  visit (SimpleName node) { IBinding binding= node.resolveBinding(); if (binding instanceof IVariableBinding) { IVariableBinding varBinding= (IVariableBinding) binding; ITypeBinding declaringType= varBinding.getDeclaringClass(); if (varBinding.isField() && "java.lang.System".equals(declaringType.getQualifiedName())) { fAccessesToSystemFields++; } } return true; } Count the number of casts Count the number of references to a field of ‘java.lang.System’ (‘System.out’, ‘System.err’)
AST Rewriting ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
AST Rewrite cont’d ,[object Object],public void modify(MethodDeclaration decl) { AST ast= decl.getAST(); ASTRewrite astRewrite=  ASTRewrite.create (ast); SimpleName newName= ast.newSimpleName("newName"); astRewrite.set (decl, MethodDeclaration.NAME_PROPERTY,  newName, null); ListRewrite paramRewrite= astRewrite.getListRewrite (decl, MethodDeclaration.PARAMETERS_PROPERTY); SingleVariableDeclaration newParam= ast.newSingleVariableDeclaration(); newParam.setType(ast.newPrimitiveType(PrimitiveType.INT)); newParam.setName(ast.newSimpleName("p1")); paramRewrite.insertFirst (newParam, null); TextEdit edit= astRewrite. rewriteAST (document, null); edit. apply (document); } Change the method name Insert a new parameter as first parameter Create resulting edit script Create the rewriter Apply edit script to source buffer
Code Manipulation Toolkits  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Code Manipulation Toolkits  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Committers Participating in JDT Markus Keller Daniel Megert Olivier Thomann Walter Harley Deepak Azad Jayaprakash Arthanareeswaran Raksha Vasisht   Srikanth Sankaran Satyam Kandula Ayushman Jain Michael Rennie Curtis Windatt Stephan Herrmann
Legal Notice ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances (20)

Type Annotations in Java 8
Type Annotations in Java 8 Type Annotations in Java 8
Type Annotations in Java 8
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
JDT Fundamentals 2010
JDT Fundamentals 2010JDT Fundamentals 2010
JDT Fundamentals 2010
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Javatraining
JavatrainingJavatraining
Javatraining
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
 
Java basic
Java basicJava basic
Java basic
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
 
Java basic
Java basicJava basic
Java basic
 
Java beans
Java beansJava beans
Java beans
 
Java Reflection Concept and Working
Java Reflection Concept and WorkingJava Reflection Concept and Working
Java Reflection Concept and Working
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
.NET Reflection
.NET Reflection.NET Reflection
.NET Reflection
 
Core java
Core javaCore java
Core java
 

Similaire à Eclipse Day India 2011 - Extending JDT

Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Baruch Sadogursky
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answersKrishnaov
 
Unit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxUnit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxDrYogeshDeshmukh1
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate FrameworkRaveendra R
 
Introduction
IntroductionIntroduction
Introductionrichsoden
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial EnAnkur Dongre
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial EnAnkur Dongre
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffJAX London
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2wiradikusuma
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernatepatinijava
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)Khaled Anaqwa
 
EclipseCon 2010 - JDT Fundamentals
EclipseCon 2010 - JDT FundamentalsEclipseCon 2010 - JDT Fundamentals
EclipseCon 2010 - JDT Fundamentalsdeepakazad
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfacesDevaKumari Vijay
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011YoungSu Son
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 

Similaire à Eclipse Day India 2011 - Extending JDT (20)

Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
Persisting Your Objects In The Database World @ AlphaCSP Professional OSS Con...
 
Java interview questions and answers
Java interview questions and answersJava interview questions and answers
Java interview questions and answers
 
Unit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptxUnit No 5 Files and Database Connectivity.pptx
Unit No 5 Files and Database Connectivity.pptx
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
 
Introduction
IntroductionIntroduction
Introduction
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard WolffSpring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
 
Java platform
Java platformJava platform
Java platform
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernate
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
EclipseCon 2010 - JDT Fundamentals
EclipseCon 2010 - JDT FundamentalsEclipseCon 2010 - JDT Fundamentals
EclipseCon 2010 - JDT Fundamentals
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfaces
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 

Plus de deepakazad

Recommending development environment commands
Recommending development environment commandsRecommending development environment commands
Recommending development environment commandsdeepakazad
 
Skynet is coming!
Skynet is coming!Skynet is coming!
Skynet is coming!deepakazad
 
Eclipse Demo Camp Bangalore 2009 - JSDT
Eclipse Demo Camp Bangalore 2009 - JSDTEclipse Demo Camp Bangalore 2009 - JSDT
Eclipse Demo Camp Bangalore 2009 - JSDTdeepakazad
 
Eclipse and Academia
Eclipse and AcademiaEclipse and Academia
Eclipse and Academiadeepakazad
 
Eclipse Demo Camp 2010 - EGit
Eclipse Demo Camp 2010 - EGitEclipse Demo Camp 2010 - EGit
Eclipse Demo Camp 2010 - EGitdeepakazad
 
EclipseCon 2011 - What's new in JDT
EclipseCon 2011 - What's new in JDTEclipseCon 2011 - What's new in JDT
EclipseCon 2011 - What's new in JDTdeepakazad
 
EclipseCon 2010 - What's new in JDT
EclipseCon 2010 - What's new in JDTEclipseCon 2010 - What's new in JDT
EclipseCon 2010 - What's new in JDTdeepakazad
 
Eclipse Day India 2010 - UI Patterns in Eclipse
Eclipse Day India 2010 - UI Patterns in EclipseEclipse Day India 2010 - UI Patterns in Eclipse
Eclipse Day India 2010 - UI Patterns in Eclipsedeepakazad
 

Plus de deepakazad (8)

Recommending development environment commands
Recommending development environment commandsRecommending development environment commands
Recommending development environment commands
 
Skynet is coming!
Skynet is coming!Skynet is coming!
Skynet is coming!
 
Eclipse Demo Camp Bangalore 2009 - JSDT
Eclipse Demo Camp Bangalore 2009 - JSDTEclipse Demo Camp Bangalore 2009 - JSDT
Eclipse Demo Camp Bangalore 2009 - JSDT
 
Eclipse and Academia
Eclipse and AcademiaEclipse and Academia
Eclipse and Academia
 
Eclipse Demo Camp 2010 - EGit
Eclipse Demo Camp 2010 - EGitEclipse Demo Camp 2010 - EGit
Eclipse Demo Camp 2010 - EGit
 
EclipseCon 2011 - What's new in JDT
EclipseCon 2011 - What's new in JDTEclipseCon 2011 - What's new in JDT
EclipseCon 2011 - What's new in JDT
 
EclipseCon 2010 - What's new in JDT
EclipseCon 2010 - What's new in JDTEclipseCon 2010 - What's new in JDT
EclipseCon 2010 - What's new in JDT
 
Eclipse Day India 2010 - UI Patterns in Eclipse
Eclipse Day India 2010 - UI Patterns in EclipseEclipse Day India 2010 - UI Patterns in Eclipse
Eclipse Day India 2010 - UI Patterns in Eclipse
 

Dernier

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Dernier (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Eclipse Day India 2011 - Extending JDT

  • 1. Deepak Azad JDT/UI Committer [email_address] Satyam Kandula JDT/Core Committer [email_address] Extending JDT – Become a JDT tool smith
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. Creating Java Elements IJavaProject javaProject= JavaCore.create(project); IClasspathEntry[] buildPath= { JavaCore.newSourceEntry(project.getFullPath().append("src")), JavaRuntime.getDefaultJREContainerEntry() }; javaProject. setRawClasspath (buildPath, project.getFullPath().append("bin"), null); IFolder folder= project. getFolder ("src"); folder. create (true, true, null); IPackageFragmentRoot srcFolder= javaProject. getPackageFragmentRoot (folder); Assert.assertTrue(srcFolder. exists ()); // resource exists and is on build path IPackageFragment fragment= srcFolder. createPackageFragment ("x.y", true, null); String str= "package x.y;" + "" + "public class E {" + "" + " String first;" + "" + "}"; ICompilationUnit cu= fragment. createCompilationUnit ("E.java", str, false, null); IType type= cu. getType ("E"); type. createField ("String name;", null, true, null); Set the build path Create the source folder Create the package fragment Create the compilation unit, including a type Create a field
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. Type Hierarchy Create – on a type or on a region (= set of Java Elements) typeHierarchy= type.newTypeHierarchy(progressMonitor); typeHierarchy= project.newTypeHierarchy(region, progressMonitor); Supertype hierarchy – faster! typeHierarchy= type.newSupertypeHierarchy(progressMonitor); Get super and subtypes, interfaces and classes typeHierarchy.getSubtypes(type) Change listener – when changed, refresh is required typeHierarchy.addTypeHierarchyChangedListener(..); typeHierarchy.refresh(progressMonitor);
  • 19.
  • 20. Code Resolve – an Example Resolving the reference to “String” in a compilation unit String content = "public class X {" + "" + " String field;" + "" + "}"; ICompilationUnit cu= fragment. createCompilationUnit (“X.java", content, false, null); int start = content.indexOf("String"); int length = "String".length(); IJavaElement[] declarations = cu. codeSelect (start, length); Contains a single IType: ‘java.lang.String’ Set up a compilation unit
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. Abstract Syntax Tree Source Code ASTParser#createAST(...) AST ReturnStatement InfixExpression MethodInvocation SimpleName expression rightOperand leftOperand IMethodBinding resolveBinding
  • 30.
  • 31.
  • 32.
  • 33. Creating an AST ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource( cu ); parser.setResolveBindings(true); parser.setStatementsRecovery(true); ASTNode node= parser. createAST (null); Create AST on an element ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource( "System.out.println();" .toCharArray()); parser.setProject(javaProject); parser.setKind(ASTParser.K_STATEMENTS); parser.setStatementsRecovery(false); ASTNode node= parser. createAST (null); Create AST on source string
  • 34.
  • 35. ASTView Demo ASTView and JavaElement view: http://www.eclipse.org/jdt/ui/update-site
  • 36.
  • 37.
  • 38.
  • 39. AST Visitor ASTParser parser= ASTParser.newParser(AST.JLS3); parser.setSource(cu); parser.setResolveBindings(true); ASTNode root= parser.createAST(null); root.accept (new ASTVisitor() { public boolean visit (CastExpression node) { fCastCount++ ; return true; } public boolean visit (SimpleName node) { IBinding binding= node.resolveBinding(); if (binding instanceof IVariableBinding) { IVariableBinding varBinding= (IVariableBinding) binding; ITypeBinding declaringType= varBinding.getDeclaringClass(); if (varBinding.isField() && "java.lang.System".equals(declaringType.getQualifiedName())) { fAccessesToSystemFields++; } } return true; } Count the number of casts Count the number of references to a field of ‘java.lang.System’ (‘System.out’, ‘System.err’)
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45. Committers Participating in JDT Markus Keller Daniel Megert Olivier Thomann Walter Harley Deepak Azad Jayaprakash Arthanareeswaran Raksha Vasisht Srikanth Sankaran Satyam Kandula Ayushman Jain Michael Rennie Curtis Windatt Stephan Herrmann
  • 46.