Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Extract Function refactoring stops with an exception
Extract Function refactoring stops with an exception [message #236010] Thu, 16 July 2009 10:55 Go to next message
Eclipse UserFriend
Hi

i just wanted to perform an extract function refactoring on my Eclipse
Galileo CDT version. The code has no errors and is compileable. This code
is very simple. It does not have any return value and any variables to be
passed. It is simply an initialisation function for my member variables.

It would be nice getting an error message showing what's going wrong there.

Following exceptions are thrown:

!ENTRY org.eclipse.ltk.ui.refactoring 4 10000 2009-07-16 16:31:27.238
!MESSAGE Internal Error
!STACK 0
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:421)
at
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:507)
at
org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.r un(ProgressMonitorJobsDialog.java:275)
at
org.eclipse.ui.internal.progress.ProgressManager$4.run(Progr essManager.java:966)
at
org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at
org.eclipse.ui.internal.progress.ProgressManager.busyCursorW hile(ProgressManager.java:1001)
at
org.eclipse.ui.internal.progress.ProgressManager.busyCursorW hile(ProgressManager.java:976)
at
org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperatio n.checkInitialConditions(RefactoringWizardOpenOperation.java :167)
at
org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperatio n.access$0(RefactoringWizardOpenOperation.java:163)
at
org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperatio n$1.run(RefactoringWizardOpenOperation.java:126)
at
org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at
org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperatio n.run(RefactoringWizardOpenOperation.java:155)
at
org.eclipse.cdt.internal.ui.refactoring.extractfunction.Extr actFunctionRefactoringRunner.run(ExtractFunctionRefactoringR unner.java:41)
at
org.eclipse.cdt.ui.refactoring.actions.ExtractFunctionAction .run(ExtractFunctionAction.java:48)
at
org.eclipse.cdt.ui.refactoring.actions.RefactoringAction.run (RefactoringAction.java:69)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498 )
at
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:584)
at
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:501)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1176)
at
org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3493)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3112)
at
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at
org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)

And:

aused by: java.lang.NullPointerException
at
org.eclipse.cdt.internal.ui.refactoring.NodeContainer$NameIn formation.isDeclarationInScope(NodeContainer.java:210)
at
org.eclipse.cdt.internal.ui.refactoring.NodeContainer.getAll DeclaredInScope(NodeContainer.java:424)
at
org.eclipse.cdt.internal.ui.refactoring.extractfunction.Extr actFunctionRefactoring.checkInitialConditions(ExtractFunctio nRefactoring.java:177)
at
org.eclipse.ltk.core.refactoring.CheckConditionsOperation.ru n(CheckConditionsOperation.java:83)
at
org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1800)
at
org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAda pter.run(WorkbenchRunnableAdapter.java:87)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:121)
Root exception:
java.lang.NullPointerException
at
org.eclipse.cdt.internal.ui.refactoring.NodeContainer$NameIn formation.isDeclarationInScope(NodeContainer.java:210)
at
org.eclipse.cdt.internal.ui.refactoring.NodeContainer.getAll DeclaredInScope(NodeContainer.java:424)
at
org.eclipse.cdt.internal.ui.refactoring.extractfunction.Extr actFunctionRefactoring.checkInitialConditions(ExtractFunctio nRefactoring.java:177)
at
org.eclipse.ltk.core.refactoring.CheckConditionsOperation.ru n(CheckConditionsOperation.java:83)
at
org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1800)
at
org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAda pter.run(WorkbenchRunnableAdapter.java:87)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:121)

Thx a lot


Christian
Re: Extract Function refactoring stops with an exception [message #522129 is a reply to message #236010] Sat, 20 March 2010 06:30 Go to previous messageGo to next message
Eclipse UserFriend
I can confirm that bug, running Eclipse Galileo CDT (Build id: 20100218-1602).

(It seems that very simple function-extractions work, bur bigger ones still stop with an exception...)

Have you found a solution for that problem in the meanwhile?

Thanks, Gerardo

PS: I ran into that problem trying to extract the following code (namespace fs = boost::filesystem):

if( !fs::is_symlink( itr->status() )) {
    if(fs::is_directory( itr->status() )) {
        Directory sub( itr->path().string().c_str() );
        size += sub.getSize();
    } else {
        size += file_size( itr->path() );
    }
}

Re: Extract Function refactoring stops with an exception [message #1819088 is a reply to message #522129] Tue, 07 January 2020 11:35 Go to previous messageGo to next message
Eclipse UserFriend
The problem still exists on Exlipse Mars and even on Eclipse CDT 2019-12!

It would be great if someone could provide some information at least about the workarounds.

Thank you in forward!
Re: Extract Function refactoring stops with an exception [message #1819107 is a reply to message #1819088] Tue, 07 January 2020 23:59 Go to previous message
Eclipse UserFriend
Works for me in 2019-09.
Though I had to define variable itr and class Directory and still needs some edits.

#include <boost/filesystem.hpp>
namespace fs= boost::filesystem;

class Directory  {
public:
	Directory(unsigned char * name)  : dirname(name) {}
	size_t getSize() { return 0; }
        string dirname;
};

int main() {
	fs::directory_iterator itr;
	size_t & size;
	if (!fs::is_symlink(itr->status())) {
		if (fs::is_directory(itr->status())) {
			Directory sub(itr->path().string().c_str());
			size += sub.getSize();
		} else {
			size += file_size(itr->path());
		}
	}
    :
    :
}


Generated:
void DirSize(const fs::directory_iterator &itr, size_t &size) {
	if (!fs::is_symlink(itr->status())) {
		if (fs::is_directory(itr->status())) {
			Directory sub(itr->path().string().c_str());
			size += sub.getSize();
		} else {
			size += file_size(itr->path());
		}
	}
}
Previous Topic:Eclipse for Linux. Build not configured correctly
Next Topic:Adding Breakpoints programatically
Goto Forum:
  


Current Time: Mon Jun 16 15:58:25 EDT 2025

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

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

Back to the top