Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » How to use toggle comment API in JDT(i can't find any JDT API related to comment, uncomment, toggle comment)
icon8.gif  How to use toggle comment API in JDT [message #1323014] Wed, 30 April 2014 04:13 Go to next message
May Yang is currently offline May YangFriend
Messages: 1
Registered: April 2014
Junior Member
Extremely frustrating. My purpose is to create a eclipse plugin that can commment or uncomment source code that is embraced by a leading keyword and a trailing keyword, such as:
//#ifdef keyword
source code 1
source code 2

if keyword does not exist in configuration file, i would like to comment "source code 1" and "source code 2":
//#ifdef keyword
//source code 1
//source code 2

Of cos i am able to do it using FileReader to find the keyword and using FileWriter to add // to the souce code lines in between and write new contents to the source file. But i wonder since eclipse IDE provides "Source" menu inside which, there are actions: "comment", "uncomment", "toggle comment", is it possible that such comment manipulation APIs are provided in JDT as well so that we can use the API to achieve my above goals?

Unfortunately, i have been searching in JDT API reference, and google all over, and came up with no such thing.

Help please?
Re: How to use toggle comment API in JDT [message #1366676 is a reply to message #1323014] Mon, 19 May 2014 12:22 Go to previous message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 58
Registered: December 2012
See org.eclipse.jdt.internal.ui.javaeditor.ToggleCommentAction for the JDT implementation of the Source > Toggle Comment action.
The APIs from org.eclipse.jface.text.ITextOperationTarget are used for the text modification.
Previous Topic:Eclipse not updating build (even with auto-build and cleaning project)
Next Topic:lambda expression template
Goto Forum:

Current Time: Wed May 22 01:02:59 GMT 2024

Powered by FUDForum. Page generated in 0.02937 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top