Bug 396366 - Extract Function incorrectly extracts the expression containing an enum
Summary: Extract Function incorrectly extracts the expression containing an enum
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:16 EST by Farnaz Behrang CLA
Modified: 2020-09-04 15:17 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:16:31 EST
In the following program...
==========
int main(){
  enum {
    EN1 = 0,
    EN2,
  } enum_var;
  enum_var = -1; //select statement without ;
  return 0;
}
==========

If you select enum_var = -1 (on line 5), and invoke the Extract Function refactoring, CDT throws the ClassCast Exception.

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)
at org.eclipse.cdt.internal.ui.refactoring.extractfunction.ExtractFunctionRefactoring.addMethod(ExtractFunctionRefactoring.java:603)
...
...