1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Adjusted method visibility.

This commit is contained in:
Sergey Prigogin 2014-12-17 14:16:23 -08:00
parent 5cd381dfe8
commit d26dc27212

View file

@ -31,27 +31,27 @@ import org.eclipse.cdt.internal.ui.refactoring.rename.TextSearchWrapper;
public class RenameTestBase extends RefactoringTests { public class RenameTestBase extends RefactoringTests {
private static final IProgressMonitor NPM = new NullProgressMonitor(); private static final IProgressMonitor NPM = new NullProgressMonitor();
public RenameTestBase(String name) { protected RenameTestBase(String name) {
super(name); super(name);
} }
public RenameTestBase() { protected RenameTestBase() {
} }
/** /**
* @param element the CElement to rename * @param element the CElement to rename
* @param newName the new name for the element * @param newName the new name for the element
* @return * @return the change produced by refactoring
* @throws Exception * @throws Exception
*/ */
public Change getRefactorChanges(IFile file, int offset, String newName) throws Exception { protected Change getRefactorChanges(IFile file, int offset, String newName) throws Exception {
CRenameRefactoring proc = createRefactoring(file, offset, newName); CRenameRefactoring refactoring = createRefactoring(file, offset, newName);
((CRenameProcessor) proc.getProcessor()).lockIndex(); ((CRenameProcessor) refactoring.getProcessor()).lockIndex();
try { try {
RefactoringStatus rs = checkConditions(proc); RefactoringStatus rs = checkConditions(refactoring);
if (!rs.hasError()) { if (!rs.hasError()) {
Change change = proc.createChange(new NullProgressMonitor()); Change change = refactoring.createChange(new NullProgressMonitor());
return change; return change;
} }
@ -62,27 +62,27 @@ public class RenameTestBase extends RefactoringTests {
// is shown. // is shown.
return null; return null;
} finally { } finally {
((CRenameProcessor) proc.getProcessor()).unlockIndex(); ((CRenameProcessor) refactoring.getProcessor()).unlockIndex();
} }
} }
private CRenameRefactoring createRefactoring(IFile file, int offset, String newName) { protected CRenameRefactoring createRefactoring(IFile file, int offset, String newName) {
CRefactoringArgument arg= new CRefactoringArgument(file, offset, 0); CRefactoringArgument arg= new CRefactoringArgument(file, offset, 0);
CRenameProcessor proc= new CRenameProcessor(CRefactory.getInstance(), arg); CRenameProcessor processor= new CRenameProcessor(CRefactory.getInstance(), arg);
proc.setReplacementText(newName); processor.setReplacementText(newName);
proc.setSelectedOptions(0xFFFF & ~CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH); processor.setSelectedOptions(0xFFFF & ~CRefactory.OPTION_EXHAUSTIVE_FILE_SEARCH);
proc.setExhaustiveSearchScope(TextSearchWrapper.SCOPE_WORKSPACE); processor.setExhaustiveSearchScope(TextSearchWrapper.SCOPE_WORKSPACE);
return new CRenameRefactoring(proc); return new CRenameRefactoring(processor);
} }
public String[] getRefactorMessages(IFile file, int offset, String newName) throws Exception { protected String[] getRefactorMessages(IFile file, int offset, String newName) throws Exception {
String[] result; String[] result;
CRenameRefactoring proc = createRefactoring(file, offset, newName); CRenameRefactoring refactoring = createRefactoring(file, offset, newName);
((CRenameProcessor) proc.getProcessor()).lockIndex(); ((CRenameProcessor) refactoring.getProcessor()).lockIndex();
try { try {
RefactoringStatus rs = checkConditions(proc); RefactoringStatus rs = checkConditions(refactoring);
if (!rs.hasWarning()) { if (!rs.hasWarning()) {
fail("Input check on "+ newName + " passed. There should have been warnings or errors."); fail("Input check on " + newName + " passed. There should have been warnings or errors.");
return null; return null;
} }
RefactoringStatusEntry[] rse = rs.getEntries(); RefactoringStatusEntry[] rse = rs.getEntries();
@ -94,36 +94,36 @@ public class RenameTestBase extends RefactoringTests {
} }
return result; return result;
} finally { } finally {
((CRenameProcessor) proc.getProcessor()).unlockIndex(); ((CRenameProcessor) refactoring.getProcessor()).unlockIndex();
} }
} }
public RefactoringStatus checkConditions(IFile file, int offset, String newName) throws Exception { protected RefactoringStatus checkConditions(IFile file, int offset, String newName) throws Exception {
CRenameRefactoring proc = createRefactoring(file, offset, newName); CRenameRefactoring refactoring = createRefactoring(file, offset, newName);
((CRenameProcessor) proc.getProcessor()).lockIndex(); ((CRenameProcessor) refactoring.getProcessor()).lockIndex();
try { try {
return checkConditions(proc); return checkConditions(refactoring);
} finally { } finally {
((CRenameProcessor) proc.getProcessor()).unlockIndex(); ((CRenameProcessor) refactoring.getProcessor()).unlockIndex();
} }
} }
private RefactoringStatus checkConditions(CRenameRefactoring proc) throws CoreException { private RefactoringStatus checkConditions(CRenameRefactoring refactoring) throws CoreException {
RefactoringStatus rs = proc.checkInitialConditions(new NullProgressMonitor()); RefactoringStatus rs = refactoring.checkInitialConditions(new NullProgressMonitor());
if (!rs.hasError()) { if (!rs.hasError()) {
rs= proc.checkFinalConditions(new NullProgressMonitor()); rs= refactoring.checkFinalConditions(new NullProgressMonitor());
} }
return rs; return rs;
} }
public int getRefactorSeverity(IFile file, int offset, String newName) throws Exception { protected int getRefactorSeverity(IFile file, int offset, String newName) throws Exception {
CRenameRefactoring proc = createRefactoring(file, offset, newName); CRenameRefactoring refactoring = createRefactoring(file, offset, newName);
((CRenameProcessor) proc.getProcessor()).lockIndex(); ((CRenameProcessor) refactoring.getProcessor()).lockIndex();
try { try {
RefactoringStatus rs = checkConditions(proc); RefactoringStatus rs = checkConditions(refactoring);
return rs.getSeverity(); return rs.getSeverity();
} finally { } finally {
((CRenameProcessor) proc.getProcessor()).unlockIndex(); ((CRenameProcessor) refactoring.getProcessor()).unlockIndex();
} }
} }