1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 09:15:38 +02:00

NLS-based messages.

This commit is contained in:
Sergey Prigogin 2010-06-20 04:27:26 +00:00
parent b5a9a032db
commit 4da85f4e4d
15 changed files with 449 additions and 432 deletions

View file

@ -29,8 +29,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
@ -126,12 +125,12 @@ public class ASTManager {
private HashSet<IBinding> fConflictingBinding;
public static String nth_of_m(int n, int m) {
StringBuffer nofm= new StringBuffer();
StringBuilder nofm= new StringBuilder();
append_nth_of_m(n, m, nofm);
return nofm.toString();
}
static void append_nth_of_m(int n, int m, StringBuffer buf) {
static void append_nth_of_m(int n, int m, StringBuilder buf) {
buf.append(n);
switch (n) {
case 1:
@ -212,8 +211,7 @@ public class ASTManager {
if (!(b2 instanceof ICPPMethod)) {
return FALSE;
}
}
else {
} else {
if (b2 instanceof ICPPMethod) {
return FALSE;
}
@ -250,13 +248,11 @@ public class ASTManager {
if (!(b2 instanceof IField)) {
return FALSE;
}
}
else if (b1 instanceof IParameter) {
} else if (b1 instanceof IParameter) {
if (!(b2 instanceof IParameter)) {
return FALSE;
}
}
else {
} else {
if (b2 instanceof IField || b2 instanceof IParameter) {
return FALSE;
}
@ -676,17 +672,17 @@ public class ASTManager {
public static int isVirtualMethod(ICPPMethod method) throws DOMException {
IASTDeclaration decl= null;
if( method instanceof CPPMethod )
if (method instanceof CPPMethod) {
decl = ((CPPMethod) method).getPrimaryDeclaration();
else if( method instanceof CPPImplicitMethod )
} else if (method instanceof CPPImplicitMethod) {
decl = ((CPPImplicitMethod) method).getPrimaryDeclaration();
}
IASTDeclSpecifier spec= null;
if (decl instanceof IASTFunctionDefinition) {
IASTFunctionDefinition def = (IASTFunctionDefinition) decl;
spec= def.getDeclSpecifier();
}
else if (decl instanceof IASTSimpleDeclaration) {
} else if (decl instanceof IASTSimpleDeclaration) {
IASTSimpleDeclaration sdecl = (IASTSimpleDeclaration) decl;
spec= sdecl.getDeclSpecifier();
}
@ -772,8 +768,7 @@ public class ASTManager {
IScope bscope= binding.getScope();
if (! (bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) {
result[i]= null;
}
else {
} else {
count++;
}
}
@ -826,7 +821,7 @@ public class ASTManager {
if (fArgument.getSourceFile() == null)
return;
pm.beginTask(Messages.getString("ASTManager.task.analyze"), 2); //$NON-NLS-1$
pm.beginTask(Messages.ASTManager_task_analyze, 2);
IASTTranslationUnit tu= getTranslationUnit(index, fArgument.getSourceFile(), true, status);
pm.worked(1);
if (tu != null) {
@ -935,7 +930,7 @@ public class ASTManager {
}
int count= store.getFileCount();
String taskName= Messages.getString("ASTManager.task.generateAst"); //$NON-NLS-1$
String taskName= Messages.ASTManager_task_generateAst;
monitor.beginTask(taskName, 2*count);
monitor.setTaskName(taskName);
@ -948,8 +943,7 @@ public class ASTManager {
if (store.contains(file)) {
if ((now = System.currentTimeMillis()) > update) {
String nofm= nth_of_m(cc, count);
String taskname= MessageFormat.format(Messages.getString("ASTManager.subtask.analyzing"), //$NON-NLS-1$
new Object[] {nofm});
String taskname= NLS.bind(Messages.ASTManager_subtask_analyzing, nofm);
monitor.subTask(taskname);
update= now + 1000;
}
@ -975,15 +969,13 @@ public class ASTManager {
return;
}
monitor.worked(1);
}
else {
} else {
monitor.worked(2);
}
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
}
else {
} else {
monitor.worked(2);
}
}
@ -1041,12 +1033,9 @@ public class ASTManager {
IASTName macroName= mdef.getName();
String macroNameStr= macroName.toString();
if (fRenameTo.equals(macroNameStr)) {
status.addFatalError(MessageFormat.format(
Messages.getString("ASTManager.error.macro.name.conflict"), //$NON-NLS-1$
new Object[] {fRenameTo}));
status.addFatalError(NLS.bind(Messages.ASTManager_error_macro_name_conflict, fRenameTo));
return;
}
else if (lookfor.equals(macroNameStr)) {
} else if (lookfor.equals(macroNameStr)) {
IPath path= analyzeAstMatch(macroName, store, false, status);
pathsVisited.add(path);
IBinding macroBinding= macroName.resolveBinding();
@ -1139,8 +1128,7 @@ public class ASTManager {
if (binding instanceof IProblemBinding) {
handleProblemBinding(name.getTranslationUnit(),
(IProblemBinding) binding, status);
}
else if (binding != null) {
} else if (binding != null) {
fConflictingBinding.add(binding);
}
}
@ -1208,8 +1196,7 @@ public class ASTManager {
if (cmp0 == TRUE) {
break;
}
}
catch (DOMException e) {
} catch (DOMException e) {
handleDOMException(name.getTranslationUnit(), e, status);
cmp= UNKNOWN;
}
@ -1251,21 +1238,16 @@ public class ASTManager {
if (fProblemUnits.add(fpath)) {
String msg= pb.getMessage();
if (msg != null && msg.length() > 0) {
msg= MessageFormat.format(Messages.getString("ASTManager.warning.parsingError.detailed"), new Object[]{msg}); //$NON-NLS-1$
}
else {
msg= Messages.getString("ASTManager.warning.parsingError"); //$NON-NLS-1$
msg= NLS.bind(Messages.ASTManager_warning_parsingError_detailed, msg);
} else {
msg= Messages.ASTManager_warning_parsingError;
}
int line= pb.getLineNumber();
if (line >= 1) {
msg= MessageFormat.format(
Messages.getString("ASTManager.warning.parsingError.withFileAndLine"), //$NON-NLS-1$
new Object[] {msg, fpath, new Integer(line)});
}
else {
msg= MessageFormat.format(
Messages.getString("ASTManager.warning.parsingError.withFile"), //$NON-NLS-1$
new Object[] {msg, fpath});
msg= NLS.bind(Messages.ASTManager_warning_parsingError_withFileAndLine,
new Object[] { msg, fpath, line });
} else {
msg= NLS.bind(Messages.ASTManager_warning_parsingError_withFile, msg, fpath);
}
status.addWarning(msg);
}
@ -1273,8 +1255,7 @@ public class ASTManager {
}
@SuppressWarnings("unchecked")
protected void handleConflictingBindings(IASTTranslationUnit tu,
RefactoringStatus status) {
protected void handleConflictingBindings(IASTTranslationUnit tu, RefactoringStatus status) {
if (fConflictingBinding.isEmpty()) {
return;
}
@ -1316,21 +1297,21 @@ public class ASTManager {
break;
}
Collection<IBinding>[] cflc= new Collection[] {new HashSet<IBinding>(), new ArrayList<IBinding>(), new ArrayList<IBinding>()};
Collection<IBinding>[] cflc=
new Collection[] { new HashSet<IBinding>(), new ArrayList<IBinding>(), new ArrayList<IBinding>() };
String[] errs= null;
if (isMacro) {
errs= new String[] {
Messages.getString("CRenameLocalProcessor.error.conflict") //$NON-NLS-1$
};
Messages.CRenameLocalProcessor_error_conflict };
cflc[0]= fConflictingBinding;
}
else {
} else {
errs= new String[] {
Messages.getString("CRenameLocalProcessor.error.shadow"), //$NON-NLS-1$
Messages.getString("CRenameLocalProcessor.error.redeclare"), //$NON-NLS-1$
Messages.getString("CRenameLocalProcessor.error.isShadowed"), //$NON-NLS-1$
Messages.getString("CRenameLocalProcessor.error.overloads")}; //$NON-NLS-1$
classifyConflictingBindings(tu, (Set<IBinding>) cflc[0], (List<IBinding>)cflc[1], (List<IBinding>)cflc[2], status);
Messages.CRenameLocalProcessor_error_shadow,
Messages.CRenameLocalProcessor_error_redeclare,
Messages.CRenameLocalProcessor_error_isShadowed,
Messages.CRenameLocalProcessor_error_overloads };
classifyConflictingBindings(tu, (Set<IBinding>) cflc[0], (List<IBinding>) cflc[1],
(List<IBinding>) cflc[2], status);
}
for (int i = 0; i < 3; i++) {
@ -1342,48 +1323,42 @@ public class ASTManager {
String what= null;
if (conflict instanceof IEnumerator) {
if (isVarParEnumerator || isFunction || isMacro) {
what= Messages.getString("CRenameLocalProcessor.enumerator"); //$NON-NLS-1$
what= Messages.CRenameLocalProcessor_enumerator;
}
}
else if (conflict instanceof ICPPField) {
} else if (conflict instanceof ICPPField) {
if (isVarParEnumerator || isFunction || isMacro) {
what= Messages.getString("CRenameLocalProcessor.field"); //$NON-NLS-1$
what= Messages.CRenameLocalProcessor_field;
}
}
else if (conflict instanceof IParameter) {
} else if (conflict instanceof IParameter) {
if (isVarParEnumerator || isFunction || isMacro) {
if (i == 1 && argKind == CRefactory.ARGUMENT_LOCAL_VAR) {
msg= errs[0];
}
what= Messages.getString("CRenameLocalProcessor.parameter"); //$NON-NLS-1$
what= Messages.CRenameLocalProcessor_parameter;
}
}
else if (conflict instanceof IVariable) {
} else if (conflict instanceof IVariable) {
if (isVarParEnumerator || isFunction || isMacro) {
IVariable conflictingVar= (IVariable) conflict;
what= Messages.getString("CRenameLocalProcessor.globalVariable"); //$NON-NLS-1$
what= Messages.CRenameLocalProcessor_globalVariable;
if (ASTManager.isLocalVariable(conflictingVar)) {
if (i == 1 && argKind == CRefactory.ARGUMENT_PARAMETER) {
msg= errs[2];
}
what= Messages.getString("CRenameLocalProcessor.localVariable"); //$NON-NLS-1$
}
else {
what= Messages.CRenameLocalProcessor_localVariable;
} else {
try {
if (conflictingVar.isStatic()) {
what= Messages.getString("CRenameProcessorDelegate.fileStaticVariable"); //$NON-NLS-1$
what= Messages.CRenameProcessorDelegate_fileStaticVariable;
}
} catch (DOMException e) {
}
}
}
}
else if (conflict instanceof ICPPConstructor) {
} else if (conflict instanceof ICPPConstructor) {
if (isVarParEnumerator || isFunction || isMacro) {
what= Messages.getString("CRenameLocalProcessor.constructor"); //$NON-NLS-1$
what= Messages.CRenameLocalProcessor_constructor;
}
}
else if (conflict instanceof ICPPMethod) {
} else if (conflict instanceof ICPPMethod) {
if (isVarParEnumerator || isFunction || isMacro) {
if (i == 1) {
IBinding r= fArgument.getBinding();
@ -1398,10 +1373,9 @@ public class ASTManager {
}
}
}
what= Messages.getString("CRenameLocalProcessor.method"); //$NON-NLS-1$
what= Messages.CRenameLocalProcessor_method;
}
}
else if (conflict instanceof IFunction) {
} else if (conflict instanceof IFunction) {
if (isVarParEnumerator || isFunction || isMacro) {
boolean ignore= false;
if (isLocalVarPar) {
@ -1433,37 +1407,31 @@ public class ASTManager {
} catch (DOMException e) {
}
if (isStatic) {
what= Messages.getString("CRenameProcessorDelegate.fileStaticFunction"); //$NON-NLS-1$
}
else {
what= Messages.getString("CRenameProcessorDelegate.globalFunction"); //$NON-NLS-1$
what= Messages.CRenameProcessorDelegate_fileStaticFunction;
} else {
what= Messages.CRenameProcessorDelegate_globalFunction;
}
}
}
}
else if (conflict instanceof ICompositeType ||
} else if (conflict instanceof ICompositeType ||
conflict instanceof IEnumeration ||
conflict instanceof ITypedef) {
if (isContainer || isMacro) {
what= Messages.getString("CRenameProcessorDelegate.type"); //$NON-NLS-1$
what= Messages.CRenameProcessorDelegate_type;
}
}
else if (conflict instanceof ICPPNamespace) {
} else if (conflict instanceof ICPPNamespace) {
if (isContainer || isMacro) {
what= Messages.getString("CRenameProcessorDelegate.namespace"); //$NON-NLS-1$
what= Messages.CRenameProcessorDelegate_namespace;
if (argKind == CRefactory.ARGUMENT_NAMESPACE) {
warn= true;
}
}
}
if (what != null) {
String message = Messages.getString("CRenameLocalProcessor.error.message"); //$NON-NLS-1$
String message1 = MessageFormat.format(Messages.getString("CRenameLocalProcessor.error.message1"), //$NON-NLS-1$
new Object[]{msg});
String message2 = MessageFormat.format(Messages.getString("CRenameLocalProcessor.error.message2"), //$NON-NLS-1$
new Object[]{conflict.getName()});
String message3 = MessageFormat.format(Messages.getString("CRenameLocalProcessor.error.message3"), //$NON-NLS-1$
new Object[]{what});
String message = Messages.CRenameLocalProcessor_error_message;
String message1 = NLS.bind(Messages.CRenameLocalProcessor_error_message1, msg);
String message2 = NLS.bind(Messages.CRenameLocalProcessor_error_message2, conflict.getName());
String message3 = NLS.bind(Messages.CRenameLocalProcessor_error_message3, what);
String space = " \n"; //$NON-NLS-1$
String formatted = message + space + message1 + space + message2 + space + message3;
RefactoringStatusEntry[] entries= status.getEntries();
@ -1476,8 +1444,7 @@ public class ASTManager {
if (formatted != null) {
if (warn) {
status.addWarning(formatted);
}
else {
} else {
status.addError(formatted);
}
}
@ -1542,8 +1509,7 @@ public class ASTManager {
aboveScope = aboveBinding.getScope();
if (isSameScope(aboveScope, oldBindingsScope, false) == TRUE) {
redecl.add(aboveBinding);
}
else {
} else {
shadows.add(aboveBinding);
}
} catch (DOMException e) {
@ -1559,5 +1525,4 @@ public class ASTManager {
public void setRenameTo(String renameTo) {
fRenameTo= renameTo;
}
}

View file

@ -25,11 +25,11 @@ public class CRefactoringMatch {
public static final int IN_COMMENT = 4;
private static String[] LABELS= {
Messages.getString("CRefactoringMatch.label.potentialOccurrence"), //$NON-NLS-1$
Messages.getString("CRefactoringMatch.label.occurrence"), //$NON-NLS-1$
Messages.CRefactoringMatch_label_potentialOccurrence,
Messages.CRefactoringMatch_label_occurrence,
"", //$NON-NLS-1$
Messages.getString("CRefactoringMatch.label.potentialOccurrence"), //$NON-NLS-1$
Messages.getString("CRefactoringMatch.label.comment")}; //$NON-NLS-1$
Messages.CRefactoringMatch_label_potentialOccurrence,
Messages.CRefactoringMatch_label_comment };
private IFile fFile;
private int fOffset;

View file

@ -74,9 +74,7 @@ public class CRefactory {
// runs the rename refactoring
public void rename(Shell shell, ICElement arg) {
if (!IDE.saveAllEditors(
new IResource[] {ResourcesPlugin.getWorkspace().getRoot()},
false)) {
if (!IDE.saveAllEditors(new IResource[] {ResourcesPlugin.getWorkspace().getRoot()}, false)) {
return;
}
CRefactoringArgument iarg= new CRefactoringArgument(arg);
@ -87,9 +85,8 @@ public class CRefactory {
CRenameRefactoring r= new CRenameRefactoring(processor);
RefactoringWizardOpenOperation op=
new RefactoringWizardOpenOperation(new CRenameRefactoringWizard(r));
op.run(shell, Messages.getString("CRefactory.title.rename")); //$NON-NLS-1$
}
finally {
op.run(shell, Messages.CRefactory_title_rename);
} finally {
processor.unlockIndex();
}
} catch (CoreException e) {
@ -104,9 +101,7 @@ public class CRefactory {
if (res instanceof IFile == false) {
return;
}
if (!IDE.saveAllEditors(
new IResource[] {ResourcesPlugin.getWorkspace().getRoot()},
false)) {
if (!IDE.saveAllEditors(new IResource[] {ResourcesPlugin.getWorkspace().getRoot()}, false)) {
return;
}
CRefactoringArgument iarg= new CRefactoringArgument((IFile) res, s.getOffset(), s.getLength());
@ -117,7 +112,7 @@ public class CRefactory {
CRenameRefactoring r= new CRenameRefactoring(processor);
RefactoringWizardOpenOperation op=
new RefactoringWizardOpenOperation(new CRenameRefactoringWizard(r));
op.run(shell, Messages.getString("CRefactory.title.rename")); //$NON-NLS-1$
op.run(shell, Messages.CRefactory_title_rename);
} finally {
processor.unlockIndex();
}
@ -147,14 +142,12 @@ public class CRefactory {
id.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) ||
id.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) {
useit= true;
}
else {
} else {
type= type.getBaseType();
}
}
if (useit) {
String exts[] =
type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
String exts[] = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
all.addAll(Arrays.asList(exts));
}
}

View file

@ -24,7 +24,6 @@ public class CRenameIncludeProcessor extends CRenameProcessorDelegate {
setOptionsEnablingScope(-1);
}
@Override
protected int getAcceptedLocations(int selectedOptions) {
return selectedOptions | CRefactory.OPTION_IN_INCLUDE_DIRECTIVE;

View file

@ -52,7 +52,6 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate {
@Override
protected void analyzeTextMatches(ArrayList<CRefactoringMatch> matches, IProgressMonitor monitor,
RefactoringStatus status) {
super.analyzeTextMatches(matches, monitor, status);
if (fScope != null) {
CRefactoringArgument argument = getArgument();

View file

@ -48,16 +48,16 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor {
CRefactoringArgument argument= getArgument();
IBinding binding= argument.getBinding();
if (binding instanceof ICPPConstructor) {
return RefactoringStatus.createFatalErrorStatus(Messages.getString("CRenameMethodProcessor.fatalError.renameConstructor")); //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.CRenameMethodProcessor_fatalError_renameConstructor);
}
String identifier= argument.getName();
if (identifier.startsWith("~")) { //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.getString("CRenameMethodProcessor.fatalError.renameDestructor")); //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.CRenameMethodProcessor_fatalError_renameDestructor);
}
if (identifier.startsWith("operator") && //$NON-NLS-1$
identifier.length() > 8 &&
!CRefactoringUtils.isIdentifierChar(identifier.charAt(8))) {
return RefactoringStatus.createFatalErrorStatus(Messages.getString("CRenameMethodProcessor.fatalError.renameOperator")); //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.CRenameMethodProcessor_fatalError_renameOperator);
}
return super.checkInitialConditions(pm);
}
@ -79,18 +79,18 @@ public class CRenameMethodProcessor extends CRenameGlobalProcessor {
IASTCompositeTypeSpecifier se= (IASTCompositeTypeSpecifier) node;
IASTName name= ASTManager.getSimpleName(se.getName());
if (getReplacementText().equals(name.toString())) {
return RefactoringStatus.createFatalErrorStatus(Messages.getString("CRenameMethodProcessor.fatalError.renameToConstructor")); //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.CRenameMethodProcessor_fatalError_renameToConstructor);
}
if (getReplacementText().startsWith("~")) { //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.getString("CRenameMethodProcessor.fatalError.renameToDestructor")); //$NON-NLS-1$);
return RefactoringStatus.createFatalErrorStatus(Messages.CRenameMethodProcessor_fatalError_renameToDestructor);
}
if (!CRefactoringUtils.checkIdentifier(getReplacementText())) {
result.merge(RefactoringStatus.createErrorStatus(Messages.getString("CRenameMethodProcessor.warning.illegalCharacters"))); //$NON-NLS-1$
result.merge(RefactoringStatus.createErrorStatus(Messages.CRenameMethodProcessor_warning_illegalCharacters));
}
}
}
if (argument.getArgumentKind() == CRefactory.ARGUMENT_VIRTUAL_METHOD && (getSelectedOptions() & CRefactory.OPTION_DO_VIRTUAL) == 0) {
result.merge(RefactoringStatus.createWarningStatus(Messages.getString("CRenameMethodProcessor.warning.renameVirtual"))); //$NON-NLS-1$
result.merge(RefactoringStatus.createWarningStatus(Messages.CRenameMethodProcessor_warning_renameVirtual));
}
result.merge(super.checkFinalConditions(monitor, context));

View file

@ -29,8 +29,7 @@ import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
import org.eclipse.ltk.core.refactoring.participants.RenameProcessor;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin;
@ -84,24 +83,21 @@ public class CRenameProcessor extends RenameProcessor {
if (result == null) {
String identifier= getArgument().getName();
if (identifier != null && identifier.length() > 0) {
result= MessageFormat.format(Messages.getString("CRenameTopProcessor.wizard.title"), //$NON-NLS-1$
new Object[] {identifier});
result= NLS.bind(Messages.CRenameTopProcessor_wizard_title, identifier);
}
}
if (result == null) {
result= Messages.getString("CRenameTopProcessor.wizard.backup.title"); //$NON-NLS-1$
result= Messages.CRenameTopProcessor_wizard_backup_title;
}
return result;
}
// overrider
@Override
public boolean isApplicable() throws CoreException {
return true;
}
// overrider
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
throws CoreException, OperationCanceledException {
@ -112,7 +108,7 @@ public class CRenameProcessor extends RenameProcessor {
identifier= fArgument.getName();
}
if (identifier == null || identifier.length() < 1) {
status.addFatalError(Messages.getString("CRenameTopProcessor.error.invalidTextSelection")); //$NON-NLS-1$
status.addFatalError(Messages.CRenameTopProcessor_error_invalidTextSelection);
return status;
}
IFile file= fArgument.getSourceFile();
@ -121,12 +117,12 @@ public class CRenameProcessor extends RenameProcessor {
path= file.getLocation();
}
if (path == null) {
return RefactoringStatus.createFatalErrorStatus(Messages.getString("CRenameTopProcessor.error.renameWithoutSourceFile")); //$NON-NLS-1$
return RefactoringStatus.createFatalErrorStatus(Messages.CRenameTopProcessor_error_renameWithoutSourceFile);
}
fDelegate= createDelegate();
if (fDelegate == null) {
status.addFatalError(Messages.getString("CRenameTopProcessor.error.invalidName")); //$NON-NLS-1$
status.addFatalError(Messages.CRenameTopProcessor_error_invalidName);
return status;
}
RefactoringStatus s1= fDelegate.checkInitialConditions(new NullProgressMonitor());
@ -138,48 +134,47 @@ public class CRenameProcessor extends RenameProcessor {
switch (fArgument.getArgumentKind()) {
case CRefactory.ARGUMENT_LOCAL_VAR:
return new CRenameLocalProcessor(this,
Messages.getString("CRenameTopProcessor.localVar"), //$NON-NLS-1$
Messages.CRenameTopProcessor_localVar,
fArgument.getScope());
case CRefactory.ARGUMENT_PARAMETER:
return new CRenameLocalProcessor(this,
Messages.getString("CRenameTopProcessor.parameter"), //$NON-NLS-1$
Messages.CRenameTopProcessor_parameter,
fArgument.getScope());
case CRefactory.ARGUMENT_FILE_LOCAL_VAR:
return new CRenameLocalProcessor(this,
Messages.getString("CRenameTopProcessor.filelocalVar"), //$NON-NLS-1$
Messages.CRenameTopProcessor_filelocalVar,
null);
case CRefactory.ARGUMENT_GLOBAL_VAR:
return new CRenameGlobalProcessor(this, Messages.getString("CRenameTopProcessor.globalVar")); //$NON-NLS-1$
return new CRenameGlobalProcessor(this, Messages.CRenameTopProcessor_globalVar);
case CRefactory.ARGUMENT_ENUMERATOR:
return new CRenameGlobalProcessor(this, Messages.getString("CRenameTopProcessor.enumerator")); //$NON-NLS-1$
return new CRenameGlobalProcessor(this, Messages.CRenameTopProcessor_enumerator);
case CRefactory.ARGUMENT_FIELD:
return new CRenameGlobalProcessor(this, Messages.getString("CRenameTopProcessor.field")); //$NON-NLS-1$
return new CRenameGlobalProcessor(this, Messages.CRenameTopProcessor_field);
case CRefactory.ARGUMENT_FILE_LOCAL_FUNCTION:
return new CRenameLocalProcessor(this,
Messages.getString("CRenameTopProcessor.filelocalFunction"), //$NON-NLS-1$
Messages.CRenameTopProcessor_filelocalFunction,
null);
case CRefactory.ARGUMENT_GLOBAL_FUNCTION:
return new CRenameGlobalProcessor(this, Messages.getString("CRenameTopProcessor.globalFunction")); //$NON-NLS-1$
return new CRenameGlobalProcessor(this, Messages.CRenameTopProcessor_globalFunction);
case CRefactory.ARGUMENT_VIRTUAL_METHOD:
return new CRenameMethodProcessor(this, Messages.getString("CRenameTopProcessor.virtualMethod"), true); //$NON-NLS-1$
return new CRenameMethodProcessor(this, Messages.CRenameTopProcessor_virtualMethod, true);
case CRefactory.ARGUMENT_NON_VIRTUAL_METHOD:
return new CRenameMethodProcessor(this, Messages.getString("CRenameTopProcessor.method"), false); //$NON-NLS-1$
return new CRenameMethodProcessor(this, Messages.CRenameTopProcessor_method, false);
case CRefactory.ARGUMENT_CLASS_TYPE:
return new CRenameClassProcessor(this, Messages.getString("CRenameTopProcessor.type")); //$NON-NLS-1$
return new CRenameClassProcessor(this, Messages.CRenameTopProcessor_type);
case CRefactory.ARGUMENT_NAMESPACE:
return new CRenameTypeProcessor(this, Messages.getString("CRenameTopProcessor.namespace")); //$NON-NLS-1$
return new CRenameTypeProcessor(this, Messages.CRenameTopProcessor_namespace);
case CRefactory.ARGUMENT_TYPE:
return new CRenameTypeProcessor(this, Messages.getString("CRenameTopProcessor.type")); //$NON-NLS-1$
return new CRenameTypeProcessor(this, Messages.CRenameTopProcessor_type);
case CRefactory.ARGUMENT_MACRO:
return new CRenameMacroProcessor(this, Messages.getString("CRenameTopProcessor.macro")); //$NON-NLS-1$
return new CRenameMacroProcessor(this, Messages.CRenameTopProcessor_macro);
case CRefactory.ARGUMENT_INCLUDE_DIRECTIVE:
return new CRenameIncludeProcessor(this, Messages.getString("CRenameIncludeProcessor.includeDirective")); //$NON-NLS-1$
return new CRenameIncludeProcessor(this, Messages.CRenameIncludeProcessor_includeDirective);
default:
return null;
}
}
// overrider
@Override
public RefactoringStatus checkFinalConditions(IProgressMonitor pm,
CheckConditionsContext context) throws CoreException,
@ -187,14 +182,12 @@ public class CRenameProcessor extends RenameProcessor {
return fDelegate.checkFinalConditions(pm, context);
}
// overrider
@Override
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException {
return fDelegate.createChange(pm);
}
// overrider
@Override
public RefactoringParticipant[] loadParticipants(RefactoringStatus status,
SharableParticipants sharedParticipants) throws CoreException {
@ -234,7 +227,6 @@ public class CRenameProcessor extends RenameProcessor {
return fDelegate.getOptionsEnablingScope();
}
// overrider
@Override
public String getIdentifier() {
return IDENTIFIER;
@ -243,30 +235,38 @@ public class CRenameProcessor extends RenameProcessor {
public int getScope() {
return fScope;
}
public void setScope(int scope) {
fScope = scope;
}
public int getSelectedOptions() {
return fSelectedOptions;
}
public void setSelectedOptions(int selectedOptions) {
fSelectedOptions = selectedOptions;
}
public String getWorkingSet() {
return fWorkingSet;
}
public void setWorkingSet(String workingSet) {
fWorkingSet = workingSet;
}
public String getReplacementText() {
return fReplacementText;
}
public void setReplacementText(String replacementText) {
fReplacementText = replacementText;
}
public CRefactory getManager() {
return fManager;
}
public ASTManager getAstManager() {
return fAstManager;
}

View file

@ -30,12 +30,11 @@ import org.eclipse.ltk.core.refactoring.TextEditChangeGroup;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.ValidateEditChecker;
import org.eclipse.osgi.util.NLS;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEditGroup;
import com.ibm.icu.text.MessageFormat;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.ui.refactoring.CTextFileChange;
@ -74,33 +73,39 @@ public abstract class CRenameProcessorDelegate {
final public CRefactoringArgument getArgument() {
return fTopProcessor.getArgument();
}
final public String getReplacementText() {
return fTopProcessor.getReplacementText();
}
final public int getSelectedScope() {
return fTopProcessor.getScope();
}
final public int getSelectedOptions() {
return fTopProcessor.getSelectedOptions();
}
final public String getSelectedWorkingSet() {
return fTopProcessor.getWorkingSet();
}
final public CRefactory getManager() {
return fTopProcessor.getManager();
}
final public ASTManager getAstManager() {
return fTopProcessor.getAstManager();
}
final public IIndex getIndex() {
return fTopProcessor.getIndex();
}
final public String getProcessorName() {
String identifier= getArgument().getName();
if (identifier != null) {
return MessageFormat.format(
Messages.getString("CRenameProcessorDelegate.wizard.title"), //$NON-NLS-1$
new Object[] {fProcessorBaseName, identifier});
return NLS.bind(Messages.CRenameProcessorDelegate_wizard_title, fProcessorBaseName, identifier);
}
return null;
}
@ -111,6 +116,7 @@ public abstract class CRenameProcessorDelegate {
public void setAvailableOptions(int options) {
fAvailableOptions= options;
}
final int getAvailableOptions() {
return fAvailableOptions;
}
@ -148,7 +154,7 @@ public abstract class CRenameProcessorDelegate {
public RefactoringStatus checkFinalConditions(IProgressMonitor monitor, CheckConditionsContext context) throws CoreException, OperationCanceledException {
RefactoringStatus result= new RefactoringStatus();
monitor.beginTask(Messages.getString("CRenameProcessorDelegate.task.checkFinalCondition"), 2); //$NON-NLS-1$
monitor.beginTask(Messages.CRenameProcessorDelegate_task_checkFinalCondition, 2);
IFile file= getArgument().getSourceFile();
//assert file!=null;
@ -179,8 +185,7 @@ public abstract class CRenameProcessorDelegate {
if (tm.isInComment()) {
commentCount++;
fileset.add(tm.getFile());
}
else {
} else {
switch (tm.getAstInformation()) {
case CRefactoringMatch.AST_REFERENCE_OTHER:
iter.remove();
@ -198,24 +203,18 @@ public abstract class CRenameProcessorDelegate {
if (potentialMatchCount != 0) {
String msg= null;
if (potentialMatchCount == 1) {
msg= Messages.getString("CRenameProcessorDelegate.warning.potentialMatch.singular"); //$NON-NLS-1$
}
else {
msg= MessageFormat.format(
Messages.getString("CRenameProcessorDelegate.warning.potentialMatch.plural"), //$NON-NLS-1$
new Object[]{new Integer(potentialMatchCount)});
msg= Messages.CRenameProcessorDelegate_warning_potentialMatch_singular;
} else {
msg= NLS.bind(Messages.CRenameProcessorDelegate_warning_potentialMatch_plural, potentialMatchCount);
}
result.addWarning(msg);
}
if (commentCount != 0) {
String msg= null;
if (commentCount == 1) {
msg= Messages.getString("CRenameProcessorDelegate.warning.commentMatch.singular"); //$NON-NLS-1$
}
else {
msg= MessageFormat.format(
Messages.getString("CRenameProcessorDelegate.warning.commentMatch.plural"), //$NON-NLS-1$
new Object[]{new Integer(commentCount)});
msg= Messages.CRenameProcessorDelegate_warning_commentMatch_singular;
} else {
msg= NLS.bind(Messages.CRenameProcessorDelegate_warning_commentMatch_plural, commentCount);
}
result.addWarning(msg);
}
@ -246,7 +245,7 @@ public abstract class CRenameProcessorDelegate {
for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
CRefactoringMatch match = iter.next();
int location= match.getLocation();
if (location != 0 && ((location & acceptTextLocation) == 0)) {
if (location != 0 && (location & acceptTextLocation) == 0) {
iter.remove();
}
}
@ -272,7 +271,7 @@ public abstract class CRenameProcessorDelegate {
return m1.getOffset() - m2.getOffset();
}});
pm.beginTask(Messages.getString("CRenameProcessorDelegate.task.createChange"), fMatches.size()); //$NON-NLS-1$
pm.beginTask(Messages.CRenameProcessorDelegate_task_createChange, fMatches.size());
final String identifier= getArgument().getName();
final String replacement= getReplacementText();
CompositeChange overallChange= new CompositeChange(getProcessorName());
@ -299,8 +298,7 @@ public abstract class CRenameProcessorDelegate {
overallChange.add(fileChange);
}
ReplaceEdit replaceEdit= new ReplaceEdit(match.getOffset(),
identifier.length(), replacement);
ReplaceEdit replaceEdit= new ReplaceEdit(match.getOffset(), identifier.length(), replacement);
fileEdit.addChild(replaceEdit);
TextEditGroup editGroup= new TextEditGroup(match.getLabel(), replaceEdit);
TextEditChangeGroup changeGroup= new TextEditChangeGroup(fileChange, editGroup);

View file

@ -36,7 +36,6 @@ import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
import org.eclipse.cdt.core.CConventions;
import org.eclipse.cdt.ui.CUIPlugin;
/**
* Input page added to the standard refactoring wizard.
*/
@ -108,10 +107,11 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
// new name
Composite group= top;
GridData gd; GridLayout gl;
GridData gd;
GridLayout gl;
Label l= new Label(group, SWT.NONE);
l.setText(Messages.getString("CRenameRefactoringInputPage.newIdentifier.label")); //$NON-NLS-1$
Label label= new Label(group, SWT.NONE);
label.setText(Messages.CRenameRefactoringInputPage_label_newName);
fNewName= new Text(group, SWT.BORDER);
fNewName.setText(fSearchString);
fNewName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
@ -119,47 +119,51 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
if (hasOption(CRefactory.OPTION_DO_VIRTUAL)) {
fDoVirtual= new Button(group, SWT.CHECK);
fDoVirtual.setText(Messages.getString("CRenameRefactoringInputPage.renameBaseAndDerivedMethods")); //$NON-NLS-1$
fDoVirtual.setText(Messages.CRenameRefactoringInputPage_renameBaseAndDerivedMethods);
fDoVirtual.setLayoutData(gd= new GridData());
gd.horizontalSpan= 2;
}
// specify the scope
if (hasOption(CRefactory.OPTION_ASK_SCOPE)) {
// Specify the scope.
skipLine(top);
new Label(top, SWT.NONE).setText(Messages.getString("CRenameRefactoringInputPage.label.scope")); //$NON-NLS-1$
label = new Label(top, SWT.NONE);
label.setText(Messages.CRenameRefactoringInputPage_label_scope);
label.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
gd.horizontalSpan= 2;
group= new Composite(top, SWT.NONE);
group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
gd.horizontalSpan= 2;
group.setLayout(gl= new GridLayout(3, false));
group.setLayout(gl= new GridLayout(4, false));
gl.marginHeight= 0;
gl.marginLeft = gl.marginWidth;
gl.marginWidth = 0;
fWorkspace= new Button(group, SWT.RADIO);
fWorkspace.setText(Messages.getString("CRenameRefactoringInputPage.button.scope.workspace")); //$NON-NLS-1$
fWorkspace.setText(Messages.CRenameRefactoringInputPage_button_workspace);
fWorkspace.setLayoutData(gd= new GridData());
fDependent= new Button(group, SWT.RADIO);
fDependent.setText(Messages.getString("CRenameRefactoringInputPage.button.scope.releatedprojects")); //$NON-NLS-1$
fDependent.setLayoutData(gd= new GridData());
fDependent.setText(Messages.CRenameRefactoringInputPage_button_relatedProjects);
fDependent.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
gd.horizontalIndent= 8;
fSingle= new Button(group, SWT.RADIO);
fSingle.setText(Messages.getString("CRenameRefactoringInputPage.button.singleProject")); //$NON-NLS-1$
fSingle.setLayoutData(gd= new GridData());
group= new Composite(top, SWT.NONE);
group.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
fSingle.setText(Messages.CRenameRefactoringInputPage_button_singleProject);
fSingle.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
gd.horizontalIndent= 8;
gd.horizontalSpan= 2;
group.setLayout(gl= new GridLayout(3, false));
gl.marginHeight= 0;
fWorkingSet= new Button(group, SWT.RADIO);
fWorkingSet.setText(Messages.getString("CRenameRefactoringInputPage.button.workingSet")); //$NON-NLS-1$
fWorkingSet.setText(Messages.CRenameRefactoringInputPage_button_workingSet);
fWorkingSetSpec= new Text(group, SWT.BORDER|SWT.READ_ONLY);
fWorkingSetSpec.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fWorkingSetSpec= new Text(group, SWT.SINGLE|SWT.BORDER|SWT.READ_ONLY);
fWorkingSetSpec.setLayoutData(gd= new GridData(GridData.FILL_HORIZONTAL));
gd.horizontalIndent= 8;
gd.horizontalSpan= 2;
fWorkingSetButton= new Button(group, SWT.PUSH);
fWorkingSetButton.setText(Messages.getString("CRenameRefactoringInputPage.button.chooseWorkingSet")); //$NON-NLS-1$
fWorkingSetButton.setText(Messages.CRenameRefactoringInputPage_button_chooseWorkingSet);
setButtonLayoutData(fWorkingSetButton);
}
@ -168,38 +172,37 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
if (hasOption(CRefactory.OPTION_IN_CODE)) {
group= createLabelAndGroup(group, skippedLine, top);
fReferences= new Button(group, SWT.CHECK);
fReferences.setText(Messages.getString("CRenameRefactoringInputPage.update.label")); //$NON-NLS-1$
fReferences.setText(Messages.CRenameRefactoringInputPage_button_sourceCode);
}
if (hasOption(CRefactory.OPTION_IN_INACTIVE_CODE)) {
group= createLabelAndGroup(group, skippedLine, top);
fInInactiveCode= new Button(group, SWT.CHECK);
fInInactiveCode.setText(Messages.getString("CRenameRefactoringInputPage.button.inactiveCode")); //$NON-NLS-1$
fInInactiveCode.setText(Messages.CRenameRefactoringInputPage_button_inactiveCode);
}
if (hasOption(CRefactory.OPTION_IN_COMMENT)) {
group= createLabelAndGroup(group, skippedLine, top);
fInComment= new Button(group, SWT.CHECK);
fInComment.setText(Messages.getString("CRenameRefactoringInputPage.button.comments")); //$NON-NLS-1$
fInComment.setText(Messages.CRenameRefactoringInputPage_button_comments);
}
if (hasOption(CRefactory.OPTION_IN_STRING_LITERAL)) {
group= createLabelAndGroup(group, skippedLine, top);
fInString= new Button(group, SWT.CHECK);
fInString.setText(Messages.getString("CRenameRefactoringInputPage.button.strings")); //$NON-NLS-1$
fInString.setText(Messages.CRenameRefactoringInputPage_button_strings);
}
if (hasOption(CRefactory.OPTION_IN_MACRO_DEFINITION)) {
group= createLabelAndGroup(group, skippedLine, top);
fInMacro= new Button(group, SWT.CHECK);
fInMacro.setText(Messages.getString("CRenameRefactoringInputPage.button.macrodefinitions")); //$NON-NLS-1$
fInMacro.setText(Messages.CRenameRefactoringInputPage_button_macroDefinitions);
}
if (hasOption(CRefactory.OPTION_IN_INCLUDE_DIRECTIVE)) {
group= createLabelAndGroup(group, skippedLine, top);
fInInclude= new Button(group, SWT.CHECK);
fInInclude.setText(Messages.getString("CRenameRefactoringInputPage.button.includes")); //$NON-NLS-1$
fInInclude.setText(Messages.CRenameRefactoringInputPage_button_includes);
}
if (hasOption(CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE)) {
group= createLabelAndGroup(group, skippedLine, top);
fInPreprocessor= new Button(group, SWT.CHECK);
fInPreprocessor.setText(Messages.getString("CRenameRefactoringInputPage.button.preprocessor")); //$NON-NLS-1$
fInPreprocessor.setText(Messages.CRenameRefactoringInputPage_button_preprocessor);
}
Dialog.applyDialogFont(top);
hookSelectionListeners();
@ -208,8 +211,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
updatePageComplete();
}
private Composite createLabelAndGroup(Composite group, boolean skippedLine,
Composite top) {
private Composite createLabelAndGroup(Composite group, boolean skippedLine, Composite top) {
if (group != null) {
return group;
}
@ -217,7 +219,10 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
skipLine(top);
}
GridData gd;
new Label(top, SWT.NONE).setText(Messages.getString("CRenameRefactoringInputPage.label.updateWithin")); //$NON-NLS-1$
Label label = new Label(top, SWT.NONE);
label.setText(Messages.CRenameRefactoringInputPage_label_updateWithin);
label.setLayoutData(gd= new GridData());
gd.horizontalSpan= 2;
group= new Composite(top, SWT.NONE);
group.setLayoutData(gd= new GridData());
gd.horizontalSpan= 2;
@ -403,11 +408,9 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
int choice= TextSearchWrapper.SCOPE_RELATED_PROJECTS;
if (fWorkspace.getSelection()) {
choice= TextSearchWrapper.SCOPE_WORKSPACE;
}
else if (fSingle.getSelection()) {
} else if (fSingle.getSelection()) {
choice= TextSearchWrapper.SCOPE_SINGLE_PROJECT;
}
else if (fWorkingSet.getSelection()) {
} else if (fWorkingSet.getSelection()) {
choice= TextSearchWrapper.SCOPE_WORKING_SET;
}
fDialogSettings.put(KEY_SCOPE, choice);
@ -475,12 +478,10 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage {
if (txt.length() == 0 || txt.equals(fSearchString)) {
setErrorMessage(null);
setPageComplete(false);
}
else if (!CConventions.isValidIdentifier(txt)) {
setErrorMessage(NLS.bind(Messages.getString("CRenameRefactoringInputPage.errorInvalidIdentifier"), txt)); //$NON-NLS-1$
} else if (!CConventions.isValidIdentifier(txt)) {
setErrorMessage(NLS.bind(Messages.CRenameRefactoringInputPage_errorInvalidIdentifier, txt));
setPageComplete(false);
}
else {
} else {
setErrorMessage(null);
setPageComplete(true);
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2008 Wind River Systems, Inc.
* Copyright (c) 2004, 2010 Wind River Systems, Inc.
* 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
@ -7,25 +7,106 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.osgi.util.NLS;
public class Messages {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.refactoring.rename.messages";//$NON-NLS-1$
public class Messages extends NLS {
public static String ASTManager_error_macro_name_conflict;
public static String ASTManager_subtask_analyzing;
public static String ASTManager_task_analyze;
public static String ASTManager_task_generateAst;
public static String ASTManager_warning_parsingError_detailed;
public static String ASTManager_warning_parsingError_withFile;
public static String ASTManager_warning_parsingError_withFileAndLine;
public static String ASTManager_warning_parsingError;
public static String CRefactoringMatch_label_comment;
public static String CRefactoringMatch_label_occurrence;
public static String CRefactoringMatch_label_potentialOccurrence;
public static String CRefactory_title_rename;
public static String CRenameIncludeProcessor_includeDirective;
public static String CRenameLocalProcessor_constructor;
public static String CRenameLocalProcessor_enumerator;
public static String CRenameLocalProcessor_error_conflict;
public static String CRenameLocalProcessor_error_isShadowed;
public static String CRenameLocalProcessor_error_message;
public static String CRenameLocalProcessor_error_message1;
public static String CRenameLocalProcessor_error_message2;
public static String CRenameLocalProcessor_error_message3;
public static String CRenameLocalProcessor_error_overloads;
public static String CRenameLocalProcessor_error_redeclare;
public static String CRenameLocalProcessor_error_shadow;
public static String CRenameLocalProcessor_field;
public static String CRenameLocalProcessor_globalVariable;
public static String CRenameLocalProcessor_localVariable;
public static String CRenameLocalProcessor_method;
public static String CRenameLocalProcessor_parameter;
public static String CRenameMethodProcessor_fatalError_renameConstructor;
public static String CRenameMethodProcessor_fatalError_renameDestructor;
public static String CRenameMethodProcessor_fatalError_renameOperator;
public static String CRenameMethodProcessor_fatalError_renameToConstructor;
public static String CRenameMethodProcessor_fatalError_renameToDestructor;
public static String CRenameMethodProcessor_warning_illegalCharacters;
public static String CRenameMethodProcessor_warning_renameVirtual;
public static String CRenameProcessorDelegate_fileStaticFunction;
public static String CRenameProcessorDelegate_fileStaticVariable;
public static String CRenameProcessorDelegate_globalFunction;
public static String CRenameProcessorDelegate_namespace;
public static String CRenameProcessorDelegate_task_checkFinalCondition;
public static String CRenameProcessorDelegate_task_createChange;
public static String CRenameProcessorDelegate_type;
public static String CRenameProcessorDelegate_warning_commentMatch_plural;
public static String CRenameProcessorDelegate_warning_commentMatch_singular;
public static String CRenameProcessorDelegate_warning_potentialMatch_plural;
public static String CRenameProcessorDelegate_warning_potentialMatch_singular;
public static String CRenameProcessorDelegate_wizard_title;
public static String CRenameRefactoringInputPage_button_chooseWorkingSet;
public static String CRenameRefactoringInputPage_button_comments;
public static String CRenameRefactoringInputPage_button_sourceCode;
public static String CRenameRefactoringInputPage_button_inactiveCode;
public static String CRenameRefactoringInputPage_button_includes;
public static String CRenameRefactoringInputPage_button_macroDefinitions;
public static String CRenameRefactoringInputPage_button_preprocessor;
public static String CRenameRefactoringInputPage_button_singleProject;
public static String CRenameRefactoringInputPage_button_relatedProjects;
public static String CRenameRefactoringInputPage_button_workspace;
public static String CRenameRefactoringInputPage_button_strings;
public static String CRenameRefactoringInputPage_button_workingSet;
public static String CRenameRefactoringInputPage_errorInvalidIdentifier;
public static String CRenameRefactoringInputPage_label_newName;
public static String CRenameRefactoringInputPage_label_scope;
public static String CRenameRefactoringInputPage_label_updateWithin;
public static String CRenameRefactoringInputPage_renameBaseAndDerivedMethods;
public static String CRenameTopProcessor_enumerator;
public static String CRenameTopProcessor_error_invalidName;
public static String CRenameTopProcessor_error_invalidTextSelection;
public static String CRenameTopProcessor_error_renameWithoutSourceFile;
public static String CRenameTopProcessor_field;
public static String CRenameTopProcessor_filelocalFunction;
public static String CRenameTopProcessor_filelocalVar;
public static String CRenameTopProcessor_globalFunction;
public static String CRenameTopProcessor_globalVar;
public static String CRenameTopProcessor_localVar;
public static String CRenameTopProcessor_macro;
public static String CRenameTopProcessor_method;
public static String CRenameTopProcessor_namespace;
public static String CRenameTopProcessor_parameter;
public static String CRenameTopProcessor_type;
public static String CRenameTopProcessor_virtualMethod;
public static String CRenameTopProcessor_wizard_backup_title;
public static String CRenameTopProcessor_wizard_title;
public static String RenameCSourceFolderChange_ErroMsg;
public static String RenameCSourceFolderChange_Name0;
public static String RenameSourceFolder_0;
public static String TextSearch_monitor_categorizeMatches;
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
static {
// Initialize resource bundle.
NLS.initializeMessages(Messages.class.getName(), Messages.class);
}
private Messages() {
}
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}

View file

@ -0,0 +1,99 @@
###############################################################################
# Copyright (c) 2005, 2009 IBM Corporation 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:
# IBM Corporation - initial API and implementation
# Markus Schorn, Wind River Systems Inc.
# Sergey Prigogin (Google)
###############################################################################
ASTManager_error_macro_name_conflict=''{0}'' conflicts with the name of an existing macro!
ASTManager_subtask_analyzing=Analyzing {0} files
ASTManager_task_analyze=Analyzing source code
ASTManager_task_generateAst=Generating AST
ASTManager_warning_parsingError_detailed=Parsing error - {0} -
ASTManager_warning_parsingError_withFile={0} in file ''{1}''
ASTManager_warning_parsingError_withFileAndLine={0} in file ''{1}'' at line ''{2}''
ASTManager_warning_parsingError=Parsing error
CRefactoringMatch_label_comment=Rename in comment
CRefactoringMatch_label_occurrence=Rename occurrence
CRefactoringMatch_label_potentialOccurrence=Rename potential occurrence
CRefactory_title_rename=Rename
CRenameIncludeProcessor_includeDirective=include directive
CRenameLocalProcessor_constructor=Constructor
CRenameLocalProcessor_enumerator=Enumerator
CRenameLocalProcessor_error_conflict=Name conflict
CRenameLocalProcessor_error_isShadowed=Shadowing
CRenameLocalProcessor_error_message=A conflict was encountered during refactoring.
CRenameLocalProcessor_error_message1=Type of problem: {0}
CRenameLocalProcessor_error_message2=New element: {0}
CRenameLocalProcessor_error_message3=Conflicting element type: {0}
CRenameLocalProcessor_error_overloads=Overloading
CRenameLocalProcessor_error_redeclare=Redeclaration
CRenameLocalProcessor_error_shadow=Shadowing
CRenameLocalProcessor_field=Field
CRenameLocalProcessor_globalVariable=Global variable
CRenameLocalProcessor_localVariable=Local variable
CRenameLocalProcessor_method=Method
CRenameLocalProcessor_parameter=Parameter
CRenameMethodProcessor_fatalError_renameConstructor=Constructor cannot be renamed.
CRenameMethodProcessor_fatalError_renameDestructor=Destructor cannot be renamed.
CRenameMethodProcessor_fatalError_renameOperator=Operators cannot be renamed.
CRenameMethodProcessor_fatalError_renameToConstructor=Cannot rename method to constructor.
CRenameMethodProcessor_fatalError_renameToDestructor=Cannot rename method to destructor.
CRenameMethodProcessor_warning_illegalCharacters=Name contains illegal characters.
CRenameMethodProcessor_warning_renameVirtual=Renaming a virtual method. Consider renaming the base and derived class methods (if any).
CRenameProcessorDelegate_fileStaticFunction=File static function
CRenameProcessorDelegate_fileStaticVariable=File static variable
CRenameProcessorDelegate_globalFunction=Global function
CRenameProcessorDelegate_namespace=Namespace
CRenameProcessorDelegate_task_checkFinalCondition=Checking final conditions
CRenameProcessorDelegate_task_createChange=creating changes
CRenameProcessorDelegate_type=Type
CRenameProcessorDelegate_warning_commentMatch_plural=Refactoring contains {0} matches within comments.
CRenameProcessorDelegate_warning_commentMatch_singular=Refactoring contains 1 match within a comment.
CRenameProcessorDelegate_warning_potentialMatch_plural=Refactoring contains {0} potential matches.
CRenameProcessorDelegate_warning_potentialMatch_singular=Refactoring contains 1 potential match.
CRenameProcessorDelegate_wizard_title=Rename {0} ''{1}''
CRenameRefactoringInputPage_button_chooseWorkingSet=Choose...
CRenameRefactoringInputPage_button_comments=comments
CRenameRefactoringInputPage_button_sourceCode=source code
CRenameRefactoringInputPage_button_inactiveCode=inactive conditional compilation code branches
CRenameRefactoringInputPage_button_includes=include directives
CRenameRefactoringInputPage_button_macroDefinitions=macro definitions
CRenameRefactoringInputPage_button_preprocessor=other preprocessor directives
CRenameRefactoringInputPage_button_singleProject=project
CRenameRefactoringInputPage_button_relatedProjects=related projects
CRenameRefactoringInputPage_button_workspace=all projects
CRenameRefactoringInputPage_button_strings=string literals
CRenameRefactoringInputPage_button_workingSet=working set:
CRenameRefactoringInputPage_errorInvalidIdentifier=''{0}'' is not a valid identifier
CRenameRefactoringInputPage_label_newName=New Name:
CRenameRefactoringInputPage_label_scope=Scope of Rename:
CRenameRefactoringInputPage_label_updateWithin=Update within:
CRenameRefactoringInputPage_renameBaseAndDerivedMethods=Rename virtual methods in base and derived classes, also (if any).
CRenameTopProcessor_enumerator=enumerator
CRenameTopProcessor_error_invalidName=The selected name cannot be renamed.
CRenameTopProcessor_error_invalidTextSelection=The selected name could not be analyzed.
CRenameTopProcessor_error_renameWithoutSourceFile=No source
CRenameTopProcessor_field=field
CRenameTopProcessor_filelocalFunction=file local function
CRenameTopProcessor_filelocalVar=file-local variable
CRenameTopProcessor_globalFunction=global function
CRenameTopProcessor_globalVar=global variable
CRenameTopProcessor_localVar=local variable
CRenameTopProcessor_macro=macro
CRenameTopProcessor_method=method
CRenameTopProcessor_namespace=namespace
CRenameTopProcessor_parameter=parameter
CRenameTopProcessor_type=type
CRenameTopProcessor_virtualMethod=virtual method
CRenameTopProcessor_wizard_backup_title=Rename
CRenameTopProcessor_wizard_title=Rename ''{0}''
RenameCSourceFolderChange_ErrorMsg=Folder {0} does not exist
RenameCSourceFolderChange_Name0=Rename source Folder {0} to {1}
RenameSourceFolder_0=Rename CDT Source Folder
TextSearch_monitor_categorizeMatches=categorizing matches

View file

@ -11,7 +11,6 @@
******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename;
import java.text.MessageFormat;
import java.util.HashSet;
import java.util.Set;
@ -26,6 +25,7 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.settings.model.CSourceEntry;
@ -37,24 +37,19 @@ import org.eclipse.cdt.ui.CUIPlugin;
/**
* @author Emanuel Graf IFS
*
*/
public class RenameCSourceFolderChange extends Change {
private IPath oldName;
private IPath newName;
private IProject project;
private IFolder folder;
public RenameCSourceFolderChange(IPath oldFolderPath, IPath newFolderPath, IProject project, IFolder oldFolder) {
super();
this.oldName = oldFolderPath;
this.newName = newFolderPath;
this.project = project;
folder = oldFolder;
}
@Override
@ -64,7 +59,7 @@ public class RenameCSourceFolderChange extends Change {
@Override
public String getName() {
return MessageFormat.format(Messages.getString("RenameCSourceFolderChange.Name0"), oldName.lastSegment(), newName.lastSegment()); //$NON-NLS-1$
return NLS.bind(Messages.RenameCSourceFolderChange_Name0, oldName.lastSegment(), newName.lastSegment());
}
@Override
@ -76,15 +71,13 @@ public class RenameCSourceFolderChange extends Change {
if (folder.exists()) {
return RefactoringStatus.create(Status.OK_STATUS);
} else {
return RefactoringStatus.create(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, MessageFormat.format(Messages.getString("RenameCSourceFolderChange.ErroMsg"), folder.getName()))); //$NON-NLS-1$
return RefactoringStatus.create(new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID,
NLS.bind(Messages.RenameCSourceFolderChange_ErroMsg, folder.getName())));
}
}
@Override
public Change perform(IProgressMonitor pm) throws CoreException {
changeEntryInAllCfgs(CCorePlugin.getDefault().getProjectDescription(project, true));
IFolder folder2 = project.getFolder(newName.lastSegment());
return new RenameCSourceFolderChange(newName, oldName, project, folder2);
@ -123,5 +116,4 @@ public class RenameCSourceFolderChange extends Change {
}
return set.toArray(new ICSourceEntry[set.size()]);
}
}

View file

@ -25,23 +25,18 @@ import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
/**
* @author Emanuel Graf IFS
*
*/
public class RenameSourceFolder extends RenameParticipant {
private IFolder oldFolder;
private String newName;
/**
*
*/
public RenameSourceFolder() {
}
@Override
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
throws OperationCanceledException {
RenameArguments arg = getArguments();
newName = arg.getNewName();
return RefactoringStatus.create(Status.OK_STATUS);
@ -51,13 +46,12 @@ public class RenameSourceFolder extends RenameParticipant {
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
IPath oldFolderPath = oldFolder.getFullPath();
IPath newFolderPath = oldFolder.getFullPath().uptoSegment(oldFolder.getFullPath().segmentCount() - 1).append(newName);
return new RenameCSourceFolderChange(oldFolderPath, newFolderPath, oldFolder.getProject(), oldFolder);
}
@Override
public String getName() {
return Messages.getString("RenameSourceFolder.0"); //$NON-NLS-1$
return Messages.RenameSourceFolder_0;
}
@Override
@ -65,9 +59,7 @@ public class RenameSourceFolder extends RenameParticipant {
if (element instanceof IFolder) {
oldFolder = (IFolder) element;
return true;
}
return false;
}
}

View file

@ -50,8 +50,6 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.formatter.scanner.SimpleScanner;
import org.eclipse.cdt.internal.formatter.scanner.Token;
/**
* Wraps the platform text search and uses a scanner to categorize the text-matches
* by location (comments, string-literals, etc.).
@ -121,7 +119,7 @@ public class TextSearchWrapper {
}
private String filePatternToRegex(String filePattern) {
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
for (int i = 0; i < filePattern.length(); i++) {
char c = filePattern.charAt(i);
switch(c) {
@ -236,7 +234,7 @@ public class TextSearchWrapper {
String word, IProgressMonitor monitor, final List<CRefactoringMatch> target) {
int startPos= target.size();
TextSearchEngine engine= TextSearchEngine.create();
StringBuffer searchPattern= new StringBuffer(word.length()+ 8);
StringBuilder searchPattern= new StringBuilder(word.length() + 8);
searchPattern.append("\\b"); //$NON-NLS-1$
searchPattern.append("\\Q"); //$NON-NLS-1$
searchPattern.append(word);
@ -267,7 +265,7 @@ public class TextSearchWrapper {
}
public void categorizeMatches(List<CRefactoringMatch> matches, IProgressMonitor monitor) {
monitor.beginTask(Messages.getString("TextSearch.monitor.categorizeMatches"), matches.size()); //$NON-NLS-1$
monitor.beginTask(Messages.TextSearch_monitor_categorizeMatches, matches.size());
IFile file= null;
ArrayList<int[]> locations= null;
for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) {
@ -288,6 +286,7 @@ public class TextSearchWrapper {
return (o1)[0]-(o2)[0];
}
};
private int findLocation(CRefactoringMatch match, ArrayList<int[]> states) {
int pos= Collections.binarySearch(states, new int[] {match.getOffset()}, COMPARE_FIRST_INTEGER);
if (pos<0) {
@ -352,8 +351,7 @@ public class TextSearchWrapper {
lastState= state;
}
}
}
finally {
} finally {
try {
reader.close();
} catch (IOException e1) {

View file

@ -1,100 +0,0 @@
###############################################################################
# Copyright (c) 2005, 2009 IBM Corporation 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:
# IBM Corporation - initial API and implementation
# Markus Schorn, Wind River Systems Inc.
###############################################################################
CRenameProcessorDelegate.wizard.title=Rename {0} ''{1}''
CRenameProcessorDelegate.globalFunction=Global function
CRenameProcessorDelegate.fileStaticFunction=File static function
CRenameProcessorDelegate.type=Type
CRenameProcessorDelegate.namespace=Namespace
CRenameLocalProcessor.parameter=Parameter
CRenameTopProcessor.wizard.title=Rename ''{0}''
CRenameTopProcessor.localVar=local variable
CRenameLocalProcessor.method=Method
CRenameTopProcessor.parameter=parameter
CRenameTopProcessor.filelocalVar=file-local variable
CRenameLocalProcessor.enumerator=Enumerator
CRenameTopProcessor.globalVar=global variable
CRenameTopProcessor.field=field
CRenameTopProcessor.enumerator=enumerator
CRenameTopProcessor.globalFunction=global function
CRenameLocalProcessor.error.shadow=Shadowing
CRenameLocalProcessor.error.conflict=Name conflict
CRenameLocalProcessor.localVariable=Local variable
CRefactoringMatch.label.occurrence=Rename occurrence
CRefactoringMatch.label.comment=Rename in comment
CRenameTopProcessor.virtualMethod=virtual method
CRenameLocalProcessor.constructor=Constructor
CRenameTopProcessor.method=method
CRenameLocalProcessor.field=Field
CRenameTopProcessor.type=type
CRenameTopProcessor.namespace=namespace
CRenameTopProcessor.macro=macro
CRefactory.title.rename=Rename
CRenameProcessorDelegate.task.createChange=creating changes
CRenameProcessorDelegate.fileStaticVariable=File static variable
CRenameLocalProcessor.error.isShadowed=Shadowing
CRenameLocalProcessor.error.overloads=Overloading
CRenameProcessorDelegate.task.checkFinalCondition=Checking final conditions
CRenameProcessorDelegate.warning.potentialMatch.singular=Refactoring contains 1 potential match.
CRenameProcessorDelegate.warning.potentialMatch.plural=Refactoring contains {0} potential matches.
CRenameProcessorDelegate.warning.commentMatch.singular=Refactoring contains 1 match within a comment.
CRenameProcessorDelegate.warning.commentMatch.plural=Refactoring contains {0} matches within comments.
CRenameTopProcessor.wizard.backup.title=Rename
CRenameTopProcessor.filelocalFunction=file local function
CRenameLocalProcessor.error.redeclare=Redeclaration
CRenameLocalProcessor.globalVariable=Global variable
CRenameIncludeProcessor.includeDirective=include directive
CRenameTopProcessor.error.renameWithoutSourceFile=No source
CRenameTopProcessor.error.invalidTextSelection=The selected name could not be analyzed.
CRenameTopProcessor.error.invalidName=The selected name cannot be renamed.
TextSearch.monitor.categorizeMatches=categorizing matches
CRenameRefactoringInputPage.newIdentifier.label=Rename to:
CRenameRefactoringInputPage.button.scope.workspace=all projects
CRenameRefactoringInputPage.errorInvalidIdentifier=''{0}'' is not a valid identifier
CRenameMethodProcessor.fatalError.renameDestructor=Destructor cannot be renamed!
CRenameRefactoringInputPage.button.scope.releatedprojects=related projects
CRenameRefactoringInputPage.button.singleProject=project
CRenameMethodProcessor.fatalError.renameOperator=Operators cannot be renamed!
CRenameMethodProcessor.warning.illegalCharacters=Name contains illegal characters!
CRenameRefactoringInputPage.button.workingSet=working set:
CRenameRefactoringInputPage.button.chooseWorkingSet=Choose...
CRenameRefactoringInputPage.update.label=source code
CRenameRefactoringInputPage.label.scope=Scope of refactoring:
CRenameRefactoringInputPage.button.inactiveCode=inactive conditional compilation code branches
CRenameRefactoringInputPage.button.comments=comments
CRenameRefactoringInputPage.button.strings=string literals
#140078
CRenameLocalProcessor.error.message=A conflict was encountered during refactoring.
CRenameLocalProcessor.error.message1=Type of problem: {0}
CRenameLocalProcessor.error.message2=New element: {0}
CRenameLocalProcessor.error.message3=Conflicting element type: {0}
#140078
CRenameRefactoringInputPage.button.macrodefinitions=macro definitions
CRenameMethodProcessor.fatalError.renameConstructor=Constructor cannot be renamed!
CRenameMethodProcessor.fatalError.renameToConstructor=Cannot rename method to constructor!
CRenameMethodProcessor.fatalError.renameToDestructor=Cannot rename method to destructor!
CRenameRefactoringInputPage.button.includes=include directives
CRefactoringMatch.label.potentialOccurrence=Rename potential occurrence
CRenameMethodProcessor.warning.renameVirtual=Renaming a virtual method. Consider renaming the base and derived class methods (if any).
CRenameRefactoringInputPage.button.preprocessor=other preprocessor directives
CRenameRefactoringInputPage.label.updateWithin=Update within:
CRenameRefactoringInputPage.renameBaseAndDerivedMethods=Rename virtual methods in base and derived classes, also (if any).
ASTManager.task.analyze=Analyzing source code
ASTManager.task.generateAst=Generating AST
ASTManager.subtask.analyzing=Analyzing {0} files
ASTManager.warning.parsingError=Parsing error
ASTManager.warning.parsingError.detailed=Parsing error - {0} -
ASTManager.warning.parsingError.withFile={0} in file ''{1}''
ASTManager.warning.parsingError.withFileAndLine={0} in file ''{1}'' at line ''{2}''
ASTManager.error.macro.name.conflict=''{0}'' conflicts with the name of an existing macro!
RenameCSourceFolderChange.ErroMsg=Folder {0} does not exist
RenameCSourceFolderChange.Name0=Rename source Folder {0} to {1}
RenameSourceFolder.0=Rename CDT Source Folder