mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-10 17:55:39 +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 {
|
public void testToggleFunctionWithTypedefReturntypeToHeader_399217() throws Exception {
|
||||||
assertRefactoringSuccess();
|
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.
|
* Rapperswil, University of applied sciences and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Emanuel Graf IFS - initial API and implementation
|
* Emanuel Graf IFS - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Thomas Corbat (IFS)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
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_CanNotSaveFiles;
|
||||||
public static String ToggleRefactoring_InvalidSelection;
|
public static String ToggleRefactoring_InvalidSelection;
|
||||||
public static String ToggleRefactoring_NoIndex;
|
public static String ToggleRefactoring_NoIndex;
|
||||||
|
public static String ToggleRefactoring_SyntaxError;
|
||||||
public static String ToggleRefactoring_WaitingForIndexer;
|
public static String ToggleRefactoring_WaitingForIndexer;
|
||||||
public static String ToggleRefactoringContext_MultipleDeclarations;
|
public static String ToggleRefactoringContext_MultipleDeclarations;
|
||||||
public static String ToggleRefactoringContext_MultipleDefinitions;
|
public static String ToggleRefactoringContext_MultipleDefinitions;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Martin Schwab & Thomas Kallenberg - initial API and implementation
|
# Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||||
# Sergey Prigogin (Google)
|
# Sergey Prigogin (Google)
|
||||||
|
# Thomas Corbat (IFS)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
DeclaratorFinder_NestedFunction=Nested function declarations not supported
|
DeclaratorFinder_NestedFunction=Nested function declarations not supported
|
||||||
DeclaratorFinder_NoDeclarator=Cannot work without declarator
|
DeclaratorFinder_NoDeclarator=Cannot work without declarator
|
||||||
|
@ -29,6 +30,7 @@ ToggleRefactoring_CalculateModifications=calculating required code modifications
|
||||||
ToggleRefactoring_CanNotSaveFiles=Cannot save files
|
ToggleRefactoring_CanNotSaveFiles=Cannot save files
|
||||||
ToggleRefactoring_InvalidSelection=Invalid selection
|
ToggleRefactoring_InvalidSelection=Invalid selection
|
||||||
ToggleRefactoring_NoIndex=Cannot work without the index
|
ToggleRefactoring_NoIndex=Cannot work without the index
|
||||||
|
ToggleRefactoring_SyntaxError=Source code contains syntax errors.
|
||||||
ToggleRefactoring_WaitingForIndexer=waiting for indexer
|
ToggleRefactoring_WaitingForIndexer=waiting for indexer
|
||||||
ToggleRefactoringContext_MultipleDeclarations=Multiple declarations would result in ambiguous results
|
ToggleRefactoringContext_MultipleDeclarations=Multiple declarations would result in ambiguous results
|
||||||
ToggleRefactoringContext_MultipleDefinitions=One-definition-rule broken
|
ToggleRefactoringContext_MultipleDefinitions=One-definition-rule broken
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
* Martin Schwab & Thomas Kallenberg - initial API and implementation
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
|
* Thomas Corbat (IFS)
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.togglefunction;
|
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.ltk.core.refactoring.RefactoringStatus;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.index.IIndexManager;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -53,6 +55,10 @@ public class ToggleRefactoring extends CRefactoring {
|
||||||
pm.subTask(Messages.ToggleRefactoring_AnalyseSelection);
|
pm.subTask(Messages.ToggleRefactoring_AnalyseSelection);
|
||||||
context = new ToggleRefactoringContext(refactoringContext, getIndex(), tu, selection);
|
context = new ToggleRefactoringContext(refactoringContext, getIndex(), tu, selection);
|
||||||
strategy = new ToggleStrategyFactory(context).getAppropriateStategy();
|
strategy = new ToggleStrategyFactory(context).getAppropriateStategy();
|
||||||
|
IASTTranslationUnit definitionAST = context.getDefinitionAST();
|
||||||
|
if (definitionAST != null && checkAST(definitionAST)) {
|
||||||
|
initStatus.addFatalError(Messages.ToggleRefactoring_SyntaxError);
|
||||||
|
}
|
||||||
} catch (NotSupportedException e) {
|
} catch (NotSupportedException e) {
|
||||||
initStatus.addFatalError(e.getMessage());
|
initStatus.addFatalError(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue