eclipse-jdt

Potential null pointer access

别来无恙 提交于 2019-12-07 18:04:43
问题 I encounter a strange situation that is currently not that clear to me: When having the potential null pointer access warning enabled in Eclipse, I get warnings like in the following (the warnings are stick to the line preceding the corresponding comment): protected Item findItemByName(String itemName, Items items) { boolean isItemNameMissing = null == itemName || itemName.isEmpty(); boolean isItemsMissing = null == items || null == items.getItems() || items.getItems().isEmpty(); if

In Eclipse JDT Java parser, is it possible to traverse the AST node by node without the using of visitors?

╄→尐↘猪︶ㄣ 提交于 2019-12-07 14:21:19
问题 The standard way to access information on Nodes through the Eclipse JDT API is with Visitor's pattern. For example: unit.accept(new MyVisitorAdapter<Object>() { @Override public void visit(MethodCallExpr node, Object arg) { System.out.println("found method call: " + node.toString()); } }, null); In this case, to visit a node I need to specify what type of node I'm interested ( MethodCallExpr for this case). But, to proceed to access node information in a generic way, I should override all the

Eclipse “Open Type” dialog restricted to a particular interface

天大地大妈咪最大 提交于 2019-12-07 13:46:33
I'm trying to create a JavaUI.createTypeDialog() which restricts the user to selecting only types belonging to a particular interface. How could I do this? Rich Seller This answer shows how to obtain the type hierarchy for a particular type. You could use similar processing to obtain the TypeHierarchy for the interface, then populate the list with the resultant types. IProject project; //currently selected project //get the java project and locate the interface type JavaProject javaProject = JavaCore.create(project); IType myInterface = javaProject.findType("MyInterface","name.seller.rich"); /

eclipse ASTNode to source code line number

帅比萌擦擦* 提交于 2019-12-07 08:23:42
问题 Given an ASTNode in eclipse, is there any way to get the corresponding source code line number? 回答1: You can get the line number of an ASTNode using the below code int lineNumber = compilationUnit.getLineNumber(node.getStartPosition()) - 1; the compilation unit can be obtained from the ASTParser using the below code ASTParser parser = ASTParser.newParser(AST.JLS3); // Parse the class as a compilation unit. parser.setKind(ASTParser.K_COMPILATION_UNIT); parser.setSource(source); // give your

Oracle JDK and Eclipse JDT compilers disagree! Which is compiling this incorrectly? Unusual generics and inferrence

萝らか妹 提交于 2019-12-07 07:13:33
问题 I have a piece of code which is compiling inconsistently between Oracle JDK 7 and Eclipse JDT 7, but since I'm not sure about which compiler is making the mistake(s) I thought I should ask for opinions here before submitting any bug reports. This is the simplest test I could come up with to demonstrate the inconsistency: interface Foo<S extends Foo<S, T>, T> { // should this compile? public <X extends Foo<S, Y>, Y> Y method1(); // what about this? public <X extends Foo<? extends S, Y>, Y> Y

Use JDT to get full method name

蹲街弑〆低调 提交于 2019-12-07 04:46:47
问题 I am new to eclipse plugin development and I am trying to convert a IMethod to a string representation of the full method name. I.E. my.full.package.ClassName.methodName(int param, String string) so far I have had to hand roll my own solution. Is there a better way? private static String getMethodFullName(IMethod iMethod) { String packageString = "[Default Package]"; try { IPackageDeclaration[] declarations = iMethod.getCompilationUnit().getPackageDeclarations(); if(declarations.length > 0) {

What does “Computing additional info” mean?

a 夏天 提交于 2019-12-07 01:16:41
问题 Eclipse Helios periodically starts running a job which displays "Computing additional info". During this time, Eclipse is very sluggish, bordering on unusable. What does this job do? Can I shut it off? I just hope that someone in the JDT team comes to sense and gets rid of it, make it go faster, or at the very least change it to something meaningful. 回答1: Maybe this bug is related: Bug 293856 - [Browser] "Computing additional info" lag during content assist executions Other than that: Disable

JDT without Eclipse?

谁说我不能喝 提交于 2019-12-06 22:06:06
问题 Some time ago I wrote an Eclipse plugin which makes use of JDT to do some parsing. Now I am thinking of making a command-line version of this app. Naturally, I hope to reuse the parsing code, so I need to get JDT to work outside Eclipse. Is there any way I can accomplish this (maybe build some wrappers, etc)? Are there any ports of the JDT library that provide the same API / functionality but work independently of Eclipse? Any help will be greatly appreciated. Thanks. 回答1: The JDT is divided

Eclipse Helios ignores breakpoints

*爱你&永不变心* 提交于 2019-12-06 19:34:35
问题 Eclipse is driving me nuts right now. It's probably something trivial but I just don't get it. Whenever I like to add a breakpoint, the regular icons are crossed out in the editor and breakpoints view. As you might have guessed, this isn't strictly a graphical problem ;) The breakpoints are simply ignored while debugging. The breakpoint's properties aren't helpful either. Any hint is very well appreciated! EDIT: I've tested different JDKs without success. I've successfully debugged projects

How to specifically suppress “Comparing identical expressions” in Eclipse-Helios JDT

拜拜、爱过 提交于 2019-12-06 17:27:26
问题 I tried annotating the enclosing method with @SuppressWarnings("compareIdentical") but this does not work (worse yet, the annotation results in its own Unsupported @SuppressWarnings("compareIdentical") warning!) I know that I can always use @SuppressWarnings("all") but that'd be more warning-suppression than I want. FWIW, I got the "compareIdentical" string from the "Warning Options" table in http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm (a