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

Type Annotations in Java 8
Type Annotations in Java 8 Type Annotations in Java 8
Type Annotations in Java 8
FinLingua, Inc.
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
Jussi Pohjolainen
 
JDT Fundamentals 2010
JDT Fundamentals 2010JDT Fundamentals 2010
JDT Fundamentals 2010
Olivier Thomann
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
Tarunsingh198
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
Hitesh-Java
 
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
ecosio GmbH
 
Java tutorials
Java tutorialsJava tutorials
Javatraining
JavatrainingJavatraining
Javatraining
ducat1989
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
Madishetty Prathibha
 
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...
Sagar Verma
 
Introduction to java
Introduction to  javaIntroduction to  java
Introduction to java
Kalai Selvi
 
Java basic
Java basicJava basic
Java basic
Pooja Thakur
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
Kalai Selvi
 
Java basic
Java basicJava basic
Java basic
Arati Gadgil
 
Java beans
Java beansJava beans
Java beans
Ravi Kant Sahu
 
Java Reflection Concept and Working
Java Reflection Concept and WorkingJava Reflection Concept and Working
Java Reflection Concept and Working
Software Productivity Strategists, Inc
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
SARJERAO Sarju
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Singsys Pte Ltd
 
.NET Reflection
.NET Reflection.NET Reflection
.NET Reflection
Robert MacLean
 
Core java
Core javaCore java
Core java
Shivaraj R
 

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 answers
Krishnaov
 
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
DrYogeshDeshmukh1
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
Collaboration Technologies
 
Introduction to Hibernate Framework
Introduction to Hibernate FrameworkIntroduction to Hibernate Framework
Introduction to Hibernate Framework
Raveendra R
 
Introduction
IntroductionIntroduction
Introduction
richsoden
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
Ankur Dongre
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
Ankur 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 Wolff
JAX London
 
Java platform
Java platformJava platform
Java platform
BG Java EE Course
 
Scala and Spring
Scala and SpringScala and Spring
Scala and Spring
Eberhard Wolff
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
wiradikusuma
 
Real World MVC
Real World MVCReal World MVC
Real World MVC
James Johnson
 
Patni Hibernate
Patni   HibernatePatni   Hibernate
Patni Hibernate
patinijava
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
Khaled Anaqwa
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Subramanyan Murali
 
EclipseCon 2010 - JDT Fundamentals
EclipseCon 2010 - JDT FundamentalsEclipseCon 2010 - JDT Fundamentals
EclipseCon 2010 - JDT Fundamentals
deepakazad
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfaces
DevaKumari Vijay
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
YoungSu Son
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg 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 commands
deepakazad
 
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 - JSDT
deepakazad
 
Eclipse and Academia
Eclipse and AcademiaEclipse and Academia
Eclipse and Academia
deepakazad
 
Eclipse Demo Camp 2010 - EGit
Eclipse Demo Camp 2010 - EGitEclipse Demo Camp 2010 - EGit
Eclipse Demo Camp 2010 - EGit
deepakazad
 
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
deepakazad
 
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
deepakazad
 
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
deepakazad
 

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

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
Zilliz
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
Zilliz
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 

Recently uploaded (20)

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Infrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI modelsInfrastructure Challenges in Scaling RAG with Custom AI models
Infrastructure Challenges in Scaling RAG with Custom AI models
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Building Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and MilvusBuilding Production Ready Search Pipelines with Spark and Milvus
Building Production Ready Search Pipelines with Spark and Milvus
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 

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.