Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] CDT Refactoring Question

Hi Tom, thanks for the reply. A couple follow up questions.

To start, I am only interested in using the Change result from the rename refactoring. I found the code to invoke the CDT renaming, but its all internal. I'm using the following (which was taken from one of the tests)

CRefactoringArgument iarg = ...
CRenameProcessor processor = new CRenameProcessor(CRefactory.getInstance(), iarg);
processor.setReplacementText(getArguments().getNewName());
processor.setSelectedOptions(-1); // ? - not sure what this does
processor.setScope(TextSearchWrapper.SCOPE_RELATED_PROJECTS);
CRenameRefactoring refactor = new CRenameRefactoring(processor);
RefactoringStatus stat = refactor.checkAllConditions(pm);
if (!stat.hasErrors()) {
cdtChange = refactor.createChange(pm);
}

Everything from CDT is internal though.

My two questions are as follows:
1) Is there a public way for me to invoke the refactoring? (and get the Change object)
2) Is there a better way of invoking the refactoring on multiple elements than calling the above code in a loop for each element?
- I would assume it would be done by having the CRefactoringArgument specify the different elements, but I don't see a way to chain CRefactoringArgument elements together or to specify more than one location....

Thanks,

Adam Neal

Inactive hide details for Tom Ball <tball@xxxxxxxxxx>Tom Ball <tball@xxxxxxxxxx>


          Tom Ball <tball@xxxxxxxxxx>
          Sent by: cdt-dev-bounces@xxxxxxxxxxx

          12/18/2008 07:36 PM

          Please respond to
          "CDT General developers list." <cdt-dev@xxxxxxxxxxx>

To

"CDT General developers list." <cdt-dev@xxxxxxxxxxx>

cc


Subject

Re: [cdt-dev] CDT Refactoring Question

On Thu, Dec 18, 2008 at 3:58 AM, Adam Neal <Adam_Neal@xxxxxxxxxx> wrote:
    Hi, I tried asking this on the newsgroup, but to no avail.

    I would like to reuse the CDT refactor engine to implement a feature I am working on (in non CDT source). A few quick questions while I am investigating:
    1) Is it possible for me to invoke the refactor engine programmatically rather than just through the UI?

Yes, check out org.eclipse.cdt.ui.tests.refactoring.RefactoringTest and its subclasses.
    2) Can we provide multiple elements to refactor rather than one at a time? (e.g. a pair of method's)

That's up to the refactoring you write. Rename, for example, may appear to only change one element, but it has a ripple effect as it changes the dependencies to that element.
    3) Can we suppress the UI during the refactor if we want?

Again, that's up to your refactoring. User feedback is an important part of any good refactoring tool's design, however.
    4) Where is a good starting point in the source for me to accomplish this?

Look at the simpler refactorings, such as ExtractConstant, to get your feet wet. If that's too complicated for your needs, consider using LTK instead. LTK is the common refactoring support which JDT, CDT, and other language support modules extend.

Tom _______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-dev

GIF image

GIF image

GIF image


Back to the top