eclipse-jdt

Check if MethodDeclaration similar to an IMethod

徘徊边缘 提交于 2019-12-10 20:26:34
问题 Is there any way by which i can compare a MethodDeclaration object and IMethod object and check whether they are similar? Or is there any way by whcih a MethodDeclaration object can be converted to an IMethod object (IMethod provides a isSimilar function)? Update : Similarily i would like to know if a FieldDeclaration can be converted to a IField. 回答1: MethodDeclaration is an ASTNode, and IMethod is a JavaElement. The definitive way to check if these two objects correspond to the same method

Eclipse JDT ASTParser - Issue with MethodVisitor

拟墨画扇 提交于 2019-12-10 20:01:59
问题 I am writing some code to parse java source code. I am experimenting with Eclipse JDT AST Parser. My code is given below. (Parsing code). I am testing the parser against a Mailer application that I wrote in Java (second code snippet). My parser is visiting all methods except the generateEmail() and the debug() methods. I have looked all over the place but I am not able to understand for the life of me why its happening. Can anyone tell me what I am doing wrong? Is it a memory issue? I am not

FieldDeclaration to IField - Getting IBinding from FieldDeclaration

梦想与她 提交于 2019-12-10 17:10:25
问题 How can a FieldDeclaration (type: ASTNode) be converted to an IField (type: JavaElement). Is it possible to get the binding from the FieldDeclaration ASTNode, just like node.resolveBinding() as for MethodDeclaration node. Need : I am visiting a FieldDeclaration node in a Class having public constants, and want to search references for that field in the project. I am using JDT's SearchEngine for same. For this I want to create a search pattern as follows : SearchPattern.createPattern(iField,

In Eclipse, how to set JavaDoc URL on a classpath entry programmatically?

╄→гoц情女王★ 提交于 2019-12-10 15:49:19
问题 I have an Eclipse plugin, that among other things, can create a project and give it several classpath entries. This in and of itself works fine. These jars do not have source included in the, however there is a URL that can be used for Javadoc. I want to set this up programmatically for these classpath entries that the plug-in creates. This is what I'm doing: IClasspathEntry cpEntry; File[] jarFile = installFilePath.listFiles(); IPath jarFilePath; for (int fileCount = 0; fileCount < jarFile

Weird JavaCore IType cache problem

六眼飞鱼酱① 提交于 2019-12-10 13:59:58
问题 I'm developing a plugin that takes all enums in workspace that implements certain interface (IDomain) parses the code (Using AST) does some modification over the enum and marks it as processed with an annotation (@IDomainInfo). For example, it takes someting like this: public enum SomeEnum implements IDomain { // ... } And generates something like this: public @IDomainInfo(domainId = 1) enum SomeEnum implements IDomain { // Some changes here... } The idea behind of the @IDomainInfo is that

Eclipse JDT: Call 'correct indentation' programmatically?

我的梦境 提交于 2019-12-10 13:56:50
问题 I am working on an Eclipse plugin that modifies Java code in a user's project. Basically the result of this plugin is that Java annotations are added to some methods, so void foo() { ... } becomes @MyAnnotation void foo() { ... } Except that it doesn't quite look like that; the indentation on the newly inserted annotation is wack (specifically, the new annotation is all the way to the left-hand side of the line). I'd like to make all my changes to the file, and then programmatically call

JUnit test for jdt.core Java Models

大城市里の小女人 提交于 2019-12-10 10:36:24
问题 I am trying to make some JUnit tests for my code. But the problem is, I make use of the Java Models like ICompilationUnit, IPackageFragment, ITypes and etc. I did not get how to create some ICompilationUnit and then test. I searched google and stackoverflow for information but did not find something. My question is, how can I make Junit test with classes of the jdt.core...can somebody give me may be some code examples. Thanks Here is a Method I coded: private void updateLists() { if(

Executing Eclipse plugin (jdt/ast) outside eclipse IDE environment

给你一囗甜甜゛ 提交于 2019-12-10 10:19:01
问题 Can I execute Eclipse Java development tools as a standalone process? I need to get Java program's AST structure using Eclipse JDT from another program, and to do that, I need to execute eclipse plugin as a stand-alone process behind the scene. Is that possible? If so, how one can do that? 回答1: Eclipse/jdt and eclipse/ast is nothing more than a jar file, so one can use them to build standalone java application. Example I googled to find ASTExplorer as an example to make eclipse/ast plugin as

Is it possible to have CDT and Java IDE together in Eclipse?

穿精又带淫゛_ 提交于 2019-12-09 05:09:02
问题 I have an Eclipse CDT environment up and running and customised just the way I like it. I'm also going to be heavily dealing with Java. I don't want to install a separate version of Eclipse just to get the Java features, as I'll be switching between C -> C++ -> ADA -> Java quite often. Because of this I'd like the one IDE to support all the languages. At the moment I've got C/C++ and Ada working together (CDT + GNAT workbench). How can I get the Eclipse Java support installed with out

eclipse shortcut for enabling / disabling JAVA breakpoints

和自甴很熟 提交于 2019-12-09 02:41:52
问题 I'm looking for a shortcut to completely enable / disable all JAVA breakpoints (analogue of pushing the "Skip all breakpoints" button in Debug view ), not to enable / disable them on a row-by-row basis. 回答1: You have to assign your own keyboard shortcut to the Skip All Breakpoints command. Use Preferences>General>Keys preference page to do it. PW 回答2: Ctrl Shft B use Ctrl Shft L to open key assist for all possible keyword combinations. 回答3: In Eclipse, in debug perspective, you have a blue