eclipse-jdt

How to programmatically rename a method using JDT

你。 提交于 2019-11-30 20:37:52
My aim is to programmatically call the Refactor >> Rename Eclipse command for a method inside a Java Source File. Renaming a method as such should also apply the change to all the instances where this method is being used/referred. I believe that JDT has a Refactoring API, but not able to find any documents or tutorials for the same. Can somebody point me in the right direction. Edit: The change is not needed at runtime. I think your most promising approach is to go to the eclipse source code. Download the release you want, with source code. In particular, you want the source for the JDT

Formatting Source Code programmatically with JDT

吃可爱长大的小学妹 提交于 2019-11-30 20:02:14
I am generating some classes with JDT. Afterwards I would like to format the whole ICompilationUnit, just as if I pressed Ctrl+Shift+F (Source > Format) in an open Editor without a selection. Any pointers for the API in JDT to format the source code programmatically is highly appreciated. Addition: I tried it like this, but the code isn't changed. What am I mssing? private void formatUnitSourceCode(ICompilationUnit targetUnit, IProgressMonitor monitor) throws JavaModelException { CodeFormatter formatter = ToolFactory.createCodeFormatter(null); TextEdit formatEdit = formatter.format

How do I browse JDT source code in eclipse?

旧街凉风 提交于 2019-11-30 19:20:16
My current attempt to browse the JDT source code in eclipse: installing Eclipse Helios RCP version. importing all plugins from installation as binary files into my workspace It does not work. Install the "Eclipse SDK" feature from the Eclipse Project Updates update site: You can follow Vogella's " Eclipse Source Code - Tutorial ", especially the section " Import Plugins " how you can import Eclipse plugins from your Eclipse installation to review the code. The Eclipse distribution contains the source code for the core Eclipse projects, e.g. JDT. For other Eclipse projects you usually find a

How to get “active editor” in Eclipse plugin?

允我心安 提交于 2019-11-30 18:21:57
In my Eclipse plugin, I need to know when the editor that is visible on the screen has changed. I am currently getting the active editor as follows: PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() This works for most cases except for when the green Continue button is pressed: If I use the F8 shortcut then the active editor is updated as expected. It seems that the active editor property is not updated until the editor tab gets focus (which doesn't happen when the Continue button is pressed). Is there any other route that I can take to get the "visible

Eclipse find references for method

混江龙づ霸主 提交于 2019-11-30 17:53:37
I wanted to find all the callers of the the method "get" for the following class: package com.zzz.zzz.zzz.services; public final class EMF { private static final EntityManagerFactory emfInstance = Persistence.createEntityManagerFactory("obamaCareIsGood4U"); private EMF() {} public static EntityManagerFactory get() { return emfInstance; } } So I highlited the text "get" and right-clicked References - project. But it returned references to every method called "get", rather than just references to com.zzz.zzz.zzz.services.EMF.get(). Is this an eclipse bug? How do I get Eclipse to show references

How to install jdt.core in eclipse locally?

人走茶凉 提交于 2019-11-30 17:47:36
问题 I'm needing to install the eclipse JDT.Core plugin locally (eg download the file with site.xml etc), as opposed to installing it remotely due to the horrible firewall at work. Can anyone suggest where to download it so i can do the local install? Thanks 回答1: I am not sure I ever saw an installation of jdt.core, since it is included in most of the eclipse distros (either Eclipse 3.5 Galileo or Eclipse 3.6 Helios) That being said, the jdt core update site is part of the global Eclipse update

Children of org.eclipse.jdt.core.dom.ASTNode

醉酒当歌 提交于 2019-11-30 15:04:23
Using Eclise JDT, I need to retrieve the children of any ASTNode. Is there a utility method somewhere that I could use ? The only way I can think of right now is to subclass ASTVisitor and treat each kind of node manually to find its children. But it's a lot of work to study every node type. I would start by looking at source of ASTView Plugin , since that also does the same thing. Based on the code in org.eclipse.jdt.astview.views.ASTViewContentProvider.getNodeChildren(ASTNode) org.eclipse.jdt.astview.views.NodeProperty.getChildren() the required code should look something like this public

Java refactoring tools [duplicate]

倾然丶 夕夏残阳落幕 提交于 2019-11-30 09:44:27
Possible Duplicate: A tool like ReSharper, but for Java? I make very heavy use of the Java code refactoring tools provided by Eclipse (extract interface, rename method, etc.). Does anyone knows of other similar tools (preferably Eclipse plugins) that can perform Java code refactorings that are not available in Eclipse by default, or that can perform the same refactorings better? I'm aware of various Eclipse plugins that can identify code in need of refactoring (e.g. FindBugs, UCDetector), but I'm looking for tools that can actually do the refactoring. RefactorIT... Is available as standalone

Programming Java 8 in Eclipse

独自空忆成欢 提交于 2019-11-30 04:54:44
The development of Eclipse support for Java 8 is ongoing in a branch ( http://wiki.eclipse.org/JDT_Core/Java8 ). To try out the current Eclipse support for Java 8, I did the following: I installed a build of JDK 8 (This step is optional). I checked out branch BETA_JAVA8 of git://git.eclipse.org/gitroot/jdt/eclipse.jdt.core.git . I imported the checked out projects in an instance of Eclipse Juno SR1 (Build ID: 20120920-0800). I ran a new instance of Eclipse from my running Eclipse. To use the new syntax available in Java 8, Eclipse said that I have to set the compliance level of my code to 1.8.

How to programmatically rename a method using JDT

落花浮王杯 提交于 2019-11-30 04:23:20
问题 My aim is to programmatically call the Refactor >> Rename Eclipse command for a method inside a Java Source File. Renaming a method as such should also apply the change to all the instances where this method is being used/referred. I believe that JDT has a Refactoring API, but not able to find any documents or tutorials for the same. Can somebody point me in the right direction. Edit: The change is not needed at runtime. 回答1: I think your most promising approach is to go to the eclipse source