1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-09 10:05:24 +02:00

Bug 414827 - ClassCastExceptions in ToggleNodeHelper using C file

Change-Id: Ia98176f3a532432a02758c23cc515566d83b3efd
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/15325
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2013-08-11 11:00:19 -04:00 committed by Marc-Andre Laperle
parent a2a965e83e
commit 3ed44ffc55
2 changed files with 27 additions and 8 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -9,6 +9,7 @@
* Contributors:
* Institute for Software - initial API and implementation
* Sergey Prigogin (Google)
* Marc-Andre Laperle (Ericsson)
*******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.togglefunction;
@ -2861,4 +2862,21 @@ public class ToggleRefactoringTest extends RefactoringTestBase {
public void testImplToHeaderTopCommentWithoutDeclaration() throws Exception {
assertRefactoringSuccess();
}
//A.c
//#include "A.h"
//
//void /*$*/test/*$$*/() {
//}
//====================
//#include "A.h"
//A.h
//void test();
//====================
//void test() {
//}
public void testToggleCFunction() throws Exception {
assertRefactoringSuccess();
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2011, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Martin Schwab & Thomas Kallenberg - initial API and implementation
* Marc-Andre Laperle (Ericsson)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
@ -180,11 +181,11 @@ public class ToggleNodeHelper extends NodeHelper {
static IASTFunctionDefinition createInClassDefinition(IASTFunctionDeclarator dec,
IASTFunctionDefinition def, IASTTranslationUnit insertionAst) {
IASTFunctionDeclarator declarator = dec.copy(CopyStyle.withLocations);
ICPPASTDeclSpecifier declSpec =
(ICPPASTDeclSpecifier) def.getDeclSpecifier().copy(CopyStyle.withLocations);
IASTDeclSpecifier declSpec =
def.getDeclSpecifier().copy(CopyStyle.withLocations);
declSpec.setInline(false);
if (ToggleNodeHelper.isVirtual(dec)) {
declSpec.setVirtual(true);
if (declSpec instanceof ICPPASTDeclSpecifier && ToggleNodeHelper.isVirtual(dec)) {
((ICPPASTDeclSpecifier) declSpec).setVirtual(true);
}
declSpec.setStorageClass(getStorageClass(dec));
@ -202,7 +203,7 @@ public class ToggleNodeHelper extends NodeHelper {
static int getStorageClass(IASTFunctionDeclarator fdec) {
if (fdec.getParent() instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration dec = (IASTSimpleDeclaration) fdec.getParent();
return ((ICPPASTDeclSpecifier) dec.getDeclSpecifier()).getStorageClass();
return dec.getDeclSpecifier().getStorageClass();
}
return -1;
}