mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Bug 389299 - Toggle Function: Internal error on syntax errors
Added check to initial condition, for syntax errors in definition AST. Change-Id: I6ffce441174252298e726a572862ebf65a8694ea Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
This commit is contained in:
parent
db8179004f
commit
3bd061e4ee
4 changed files with 21 additions and 1 deletions
|
@ -3263,4 +3263,14 @@ public class ToggleRefactoringTest extends RefactoringTestBase {
|
|||
public void testToggleFunctionWithTypedefReturntypeToHeader_399217() throws Exception {
|
||||
assertRefactoringSuccess();
|
||||
}
|
||||
|
||||
//A.c
|
||||
//int /*$*/main/*$$*/(void) {
|
||||
// if (x===3){}
|
||||
// return 0;
|
||||
//}
|
||||
//====================
|
||||
public void testToggleFunctionFailsOnSyntaxError_389299() throws Exception {
|
||||
assertRefactoringFailure();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011, 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Copyright (c) 2011, 2015 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:
|
||||
* Emanuel Graf IFS - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
|
@ -34,6 +35,7 @@ class Messages extends NLS {
|
|||
public static String ToggleRefactoring_CanNotSaveFiles;
|
||||
public static String ToggleRefactoring_InvalidSelection;
|
||||
public static String ToggleRefactoring_NoIndex;
|
||||
public static String ToggleRefactoring_SyntaxError;
|
||||
public static String ToggleRefactoring_WaitingForIndexer;
|
||||
public static String ToggleRefactoringContext_MultipleDeclarations;
|
||||
public static String ToggleRefactoringContext_MultipleDefinitions;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
# Contributors:
|
||||
# Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
# Sergey Prigogin (Google)
|
||||
# Thomas Corbat (IFS)
|
||||
###############################################################################
|
||||
DeclaratorFinder_NestedFunction=Nested function declarations not supported
|
||||
DeclaratorFinder_NoDeclarator=Cannot work without declarator
|
||||
|
@ -29,6 +30,7 @@ ToggleRefactoring_CalculateModifications=calculating required code modifications
|
|||
ToggleRefactoring_CanNotSaveFiles=Cannot save files
|
||||
ToggleRefactoring_InvalidSelection=Invalid selection
|
||||
ToggleRefactoring_NoIndex=Cannot work without the index
|
||||
ToggleRefactoring_SyntaxError=Source code contains syntax errors.
|
||||
ToggleRefactoring_WaitingForIndexer=waiting for indexer
|
||||
ToggleRefactoringContext_MultipleDeclarations=Multiple declarations would result in ambiguous results
|
||||
ToggleRefactoringContext_MultipleDefinitions=One-definition-rule broken
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
* Contributors:
|
||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
******************************************************************************/
|
||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
||||
|
||||
|
@ -20,6 +21,7 @@ import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
|
|||
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -53,6 +55,10 @@ public class ToggleRefactoring extends CRefactoring {
|
|||
pm.subTask(Messages.ToggleRefactoring_AnalyseSelection);
|
||||
context = new ToggleRefactoringContext(refactoringContext, getIndex(), tu, selection);
|
||||
strategy = new ToggleStrategyFactory(context).getAppropriateStategy();
|
||||
IASTTranslationUnit definitionAST = context.getDefinitionAST();
|
||||
if (definitionAST != null && checkAST(definitionAST)) {
|
||||
initStatus.addFatalError(Messages.ToggleRefactoring_SyntaxError);
|
||||
}
|
||||
} catch (NotSupportedException e) {
|
||||
initStatus.addFatalError(e.getMessage());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue