eclipse-jdt

How to create an AST with a CAPTURE binding?

余生颓废 提交于 2019-12-08 21:08:05
问题 I am interested in using the Eclipse JDT to create a CAPTURE binding. I've read several capture conversion tutorials, but when I copy-paste sample code snippets, I can never find a capture conversion binding in the Abstract Syntax Tree (using the plugin ASTView for visualizing the AST). How can this be accomplished? 回答1: Example provided by Deepak Azad @ Eclipse Forums: interface Box<T> { public T get(); public void put( T element); } class CaptureTest { public void rebox( Box<?> box) { box

Using Eclipse's JDT, how does one get an IType from a class name?

◇◆丶佛笑我妖孽 提交于 2019-12-08 19:26:36
问题 Is there a simple, straightforward way to get an IType from a class name? I think there must be some static method somewhere. Basically, I'd like to do something like: IType objectType = Somewhere.getType("java.lang.Object") Does anybody know of something like this? I have been searching in vain. 回答1: Given an IProject, one can use the IJavaProject#findType methods, e.g. IType objectType = project.findType("java.lang.Object"); 回答2: Look at org.eclipse.jdt.core.search.SearchEngine . I haven't

Eclipse autocomplete broken

喜欢而已 提交于 2019-12-08 17:14:07
问题 Eclipse autocomplete is not working and is always telling me merely "No Default Proposals". This is true whether I try to autocomplete for code under java.util or in my own project. I'm running Eclipse 3.5.2 on Lucid Lynx using java-6-openjdk. Any ideas? 回答1: Window > Preferences > Java > Editor > Content Assist > Advanced All the Java options were turned off. Don't know how this happened or why it's not always on :o/ 回答2: Open eclipse and go to the following: Window > Preferences > Java >

Getting startPosition and length of a method invocation using JDT

Deadly 提交于 2019-12-08 08:24:39
问题 Let's say I have this Java source code. How can I get the startPosition and length of "extractedMethod(amount)" invocation? package smcho; public class Extract { String _name = ""; public int extractedMethod(int amount) { .... } public int getValue(int amount) { if (amount > 10) { int z = extractedMethod(amount); return z; } .... } I could use hexa viewers to find the start position is 0x1FA and the length is len("extracted(method)") == 17, but I'd like to do it programmatically using JDT.

java.lang.NoSuchMethodError: java.lang.NoSuchMethodError

风流意气都作罢 提交于 2019-12-08 07:08:51
问题 Running Tomcat 7 through eclipse The error reported is: javax.servlet.ServletException: java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.CompilationResult.getProblems()[Lorg/eclipse/jdt/core/compiler/IProblem; at org.apache.jasper.compiler.JDTCompiler$2.acceptResult(JDTCompiler.java:341) I have tried both jasper-jdt-6.0.13.jar and tomcat-6.0.16-jasper-jdt.jar and both report the same error. In a way I shouldn't be surprised because I ran: jar tf tomcat-6.0.16-jasper-jdt.jar and

How can I set the region (=set of java Elements) parameter in JDT TypeHierarchy?

蓝咒 提交于 2019-12-08 06:44:54
问题 http://www.google.com/url?sa=t&rct=j&q=jdt_fundamentals&source=web&cd=1&ved=0CDIQFjAA&url=http%3A%2F%2Fwww.eclipsecon.org%2F2008%2Fsub%2Fattachments%2FJDT_fundamentals.ppt">JDT Tutorial an example code to get the type hierarchy using JDT. How can I set the region (=set of java Elements) parameter? When I have code A that has SubClass B, and SuperClass C. How can I set the region? 回答1: After reading the IRegion Javadocs and Using Eclipse's JDT, how does one get an IType from a class name?, I

Eclipse JDT AST Parser does not resolve type in Java lambda Expression

落爺英雄遲暮 提交于 2019-12-08 05:34:28
问题 I am using the Eclipse JDT AST Parser (3.10.0) to parse various source code Files. This is how i initalize the parser: ASTParser parser = ASTParser.newParser(AST.JLS8); parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setBindingsRecovery(true); parser.setResolveBindings(true); parser.setStatementsRecovery(true); parser.setSource(source.toCharArray()); parser.setUnitName(filename); parser.setEnvironment(classPath.toArray(new String[classPath.size()]), sources, new String[]{"UTF-8"}, true);

How to use ASTRewrite to replace a particular SimpleType with a PrimitiveType?

核能气质少年 提交于 2019-12-08 03:30:52
问题 I need to preprocess some code before compiling for a java based language - Processing. In this language, all instances of type color, need to be replaced with int. For ex, here's a code snippet: color red = 0xffaabbcc; color[][] primary = new color[10][10]; After preprocessing, the above code should look like: int red = 0xffaabbcc; int[][] primary = new int[10][10]; I'm working in a non eclipse environment. I'm using Eclipse JDT ASTParser to do this. I've implemented my ASTVisitor which

How to access JDT “static” icon from an eclipse plugin?

陌路散爱 提交于 2019-12-08 02:56:37
问题 I found out how to access some icons: ISharedImages images = JavaUI.getSharedImages(); Image image = images.getImage(ISharedImages.IMG_WHATEVER); However, in ISharedImages are constants modifier icons like IMG_FIELD_PUBLIC and IMG_OBJS_PRIVATE etc., but I cannot find any for e.g. the static modifier. I believe all of the icons in this list should somehow be accessible, but how? http://pic.dhe.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-156.htm

extract interface that a class implementing using AST parser

半城伤御伤魂 提交于 2019-12-08 01:56:49
问题 I am compiling a project source using AST parser. In what way i can extract class hierarchy infromation, that is whether it is implementing any interface or extends from another class? 回答1: You can visit the TypeDeclaration node and get the type binding from it. ITypeBinding typeBind = typDec.resolveBinding(); You can then get the super class and implemented interfaces as follows: public boolean visit(TypeDeclaration typeDeclaration) { ITypeBinding typeBind = typeDeclaration.resolveBinding();