From db2ef6ceaa06d94ab5fd120a898a433dbd9e53a1 Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Tue, 12 Apr 2011 16:49:26 +0000 Subject: [PATCH] Bug 342519 - Toggle refactoring: misleading error message --- .../refactoring/togglefunction/DeclaratorFinder.java | 4 ++++ .../ui/refactoring/togglefunction/Messages.java | 1 + .../refactoring/togglefunction/messages.properties | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java index 639461576bb..fe09c6a4f00 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/DeclaratorFinder.java @@ -89,6 +89,10 @@ ITextSelection selection, } if (node instanceof IASTSimpleDeclaration) { IASTDeclarator[] declarators = ((IASTSimpleDeclaration) node).getDeclarators(); + if (declarators.length > 1) { + throw new NotSupportedException(Messages.DeclaratorFinder_MultipleDeclarators); + } + if (declarators.length == 1 && declarators[0] instanceof IASTFunctionDeclarator) return (IASTFunctionDeclarator) declarators[0]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java index e96a5ad0eab..4b277bcd6be 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/Messages.java @@ -17,6 +17,7 @@ public class Messages extends NLS { private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.refactoring.togglefunction.messages"; //$NON-NLS-1$ public static String DeclaratorFinder_NestedFunction; public static String DeclaratorFinder_NoDeclarator; + public static String DeclaratorFinder_MultipleDeclarators; public static String RefactoringJob_UndoName; public static String ToggleFileCreator_andMove; public static String ToggleFileCreator_CanNotCreateNewFile; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/messages.properties index c3af94a0c27..e7df79b214e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/messages.properties @@ -1,5 +1,17 @@ +############################################################################### +# Copyright (c) 2011 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 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Martin Schwab & Thomas Kallenberg - initial API and implementation +############################################################################### DeclaratorFinder_NestedFunction=Nested function declarations not supported DeclaratorFinder_NoDeclarator=cannot work without declarator +DeclaratorFinder_MultipleDeclarators=cannot work with multiple declarators RefactoringJob_UndoName=toggle function definition ToggleFileCreator_andMove=\ and move ToggleFileCreator_CanNotCreateNewFile=Cannot create new filechange