Bug 396365 - Extract Function incorrectly extracts the name of structure from an element access expression which is defined locally
Summary: Extract Function incorrectly extracts the name of structure from an element a...
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-refactoring (show other bugs)
Version: 8.1.1   Edit
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-11 21:11 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:25 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Farnaz Behrang CLA 2012-12-11 21:11:58 EST
In the following program...
==========
int main() {
 struct bar {
 int i;
 } b;
 b.i =0; // extract b
 return 0;
 }
==========

If you select 'b' (on line 5), and invoke the Extract Function refactoring, the program throws a ClassCastException.

Part of the trace:

[ERROR] java.lang.ClassCastException: org.eclipse.cdt.internal.core.dom.parser.c.CNodeFactory cannot be cast to org.eclipse.cdt.core.dom.ast.cpp.ICPPNodeFactory
at org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl.getName(DeclarationGeneratorImpl.java:332)
at org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl.getDeclSpecForBinding(DeclarationGeneratorImpl.java:324)
at org.eclipse.cdt.internal.core.dom.rewrite.DeclarationGeneratorImpl.createDeclSpecFromType(DeclarationGeneratorImpl.java:112)
at org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExpressionExtractor.determineReturnType(ExpressionExtractor.java:103)
at org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring.getReturnType(ExtractFunctionRefactoring.java:681)
…