Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318130

Summary: Exception when extracting a function
Product: [Tools] CDT Reporter: Sebastian Bauer <mail>
Component: cdt-refactoringAssignee: Emanuel Graf <emanuel>
Status: RESOLVED FIXED QA Contact: Emanuel Graf <emanuel>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: 7.0.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
The exception log without breaked lines. none

Description Sebastian Bauer CLA 2010-06-27 13:27:07 EDT
Build Identifier: I20100608-0911

I'm using Cygwin and have installed boost manually (version 1.42.0). The include file are all correctly found by CDT, i.e., no indexer marker is put before the include statement and I can jump into declared types.

If I want to extract a function (see following minimal example) I get following exception:


java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:275)
at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:960)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:995)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:970)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.checkInitialConditions(RefactoringWizardOpenOperation.java:205)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.access$0(RefactoringWizardOpenOperation.java:200)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation$1.run(RefactoringWizardOpenOperation.java:163)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:192)
at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run(RefactoringWizardOpenOperation.java:115)
at org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoringRunner.run(ExtractFunctionRefactoringRunner.java:43)
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.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
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(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
Caused by: java.lang.NullPointerException
at org.eclipse.cdt.internal.ui.refactoring.NodeContainer$NameInformation.isDeclarationInScope(NodeContainer.java:220)
at org.eclipse.cdt.internal.ui.refactoring.NodeContainer.getAllDeclaredInScope(NodeContainer.java:447)
at org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring.checkInitialConditions(ExtractFunctionRefactoring.java:191)
at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.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$NameInformation.isDeclarationInScope(NodeContainer.java:220)
at org.eclipse.cdt.internal.ui.refactoring.NodeContainer.getAllDeclaredInScope(NodeContainer.java:447)
at org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring.checkInitialConditions(ExtractFunctionRefactoring.java:191)
at org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:83)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)


Reproducible: Always

Steps to Reproduce:
Enter following code in a new C++ project file.

#include <iostream>
#include <boost/filesystem.hpp>

int main(void)
{
	boost::filesystem::directory_iterator test("D:\\");
	test->status();
	return 0;
}

Instruct CDT to extract the lines
	boost::filesystem::directory_iterator test("D:\\");
	test->status();
as a function/method.
Comment 1 Sebastian Bauer CLA 2010-06-27 13:28:44 EDT
Created attachment 172857 [details]
The exception log without breaked lines.
Comment 2 Sebastian Bauer CLA 2010-06-27 14:25:55 EDT
It seems that the real cause for this, is a problem with the indexer/parser. The "->status" cannot be resolved. For instance, completion for test-> doesn't work and pressing F3 for "status" doesn't work as well. So it might be the case, that the indexer isn't able to deal with the overloading of the operator -> which is done by the directory_iterator. Please let me know whether I should file a separate bug report about this.

(Still, the Refactoring shouldn't fail with an exception here, but issue a warning or something like that)
Comment 3 Emanuel Graf CLA 2010-07-06 08:06:23 EDT
fixed in HEAD and 7.0 > 20100706