SlideShare a Scribd company logo
1 of 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]

More Related Content

What's hot (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
 

Similar to 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
 

Similar to 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
 

More from 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
 

More from 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
 

Recently uploaded

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

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.