diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index 19ab34ef842..e1a6f413e58 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -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,14 +125,14 @@ public class ASTManager { private HashSet 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) { + switch (n) { case 1: buf.append("st"); //$NON-NLS-1$ break; @@ -170,7 +169,7 @@ public class ASTManager { * @throws DOMException */ public static int isSameBinding(IBinding b1, IBinding b2) throws DOMException { - if (b1==null || b2==null) { + if (b1 == null || b2 == null) { return UNKNOWN; } if (b1.equals(b2)) { @@ -178,7 +177,7 @@ public class ASTManager { } String n1= b1.getName(); String n2= b2.getName(); - if (n1==null || n2==null) { + if (n1 == null || n2 == null) { return UNKNOWN; } if (!n1.equals(n2)) { @@ -212,8 +211,7 @@ public class ASTManager { if (!(b2 instanceof ICPPMethod)) { return FALSE; } - } - else { + } else { if (b2 instanceof ICPPMethod) { return FALSE; } @@ -232,7 +230,7 @@ public class ASTManager { if (r2 == FALSE) { return FALSE; } - if (r1!=r2) { + if (r1 != r2) { return UNKNOWN; } return r1; @@ -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; } @@ -304,20 +300,20 @@ public class ASTManager { } public static int isSameScope(IScope s1, IScope s2, boolean fileStatic) throws DOMException { - if (s1==s2) { + if (s1 == s2) { return TRUE; } IASTNode node1= ASTInternal.getPhysicalNodeOfScope(s1); IASTNode node2= ASTInternal.getPhysicalNodeOfScope(s2); // forward declarations do not have parent scopes. - if (s1==null) { + if (s1 == null) { if (!fileStatic && node2 instanceof IASTTranslationUnit) { return TRUE; } return UNKNOWN; } - if (s2==null) { + if (s2 == null) { if (!fileStatic && node1 instanceof IASTTranslationUnit) { return TRUE; } @@ -430,7 +426,7 @@ public class ASTManager { private static int isSameParameterList(IType[] p1, IType[] p2) throws DOMException { - if (p1==p2) { + if (p1 == p2) { return TRUE; } if (p1 == null || p2 == null) { @@ -455,7 +451,7 @@ public class ASTManager { private static int isSameParameterList(IParameter[] p1, IParameter[] p2) throws DOMException { - if (p1==p2) { + if (p1 == p2) { return TRUE; } if (p1 == null || p2 == null) { @@ -485,7 +481,7 @@ public class ASTManager { } t1= getRealType(t1); t2= getRealType(t2); - if (t1==t2) { + if (t1 == t2) { return TRUE; } if (t1 == null || t2 == null || t1 instanceof IProblemBinding || @@ -601,7 +597,7 @@ public class ASTManager { if (a2.isUnsigned()) { return false; } - switch(a2.getKind()) { + switch (a2.getKind()) { case eInt: case eUnspecified: return true; @@ -648,7 +644,7 @@ public class ASTManager { IASTFileLocation l1= node1.getNodeLocations()[0].asFileLocation(); IASTFileLocation l2= node2.getNodeLocations()[0].asFileLocation(); - if (l1==null || l2==null) { + if (l1 == null || l2 == null) { return UNKNOWN; } if (!l1.getFileName().equals(l2.getFileName())) { @@ -676,17 +672,17 @@ public class ASTManager { public static int isVirtualMethod(ICPPMethod method) throws DOMException { IASTDeclaration decl= null; - if( method instanceof CPPMethod ) - decl = ((CPPMethod)method).getPrimaryDeclaration(); - else if( method instanceof CPPImplicitMethod ) - decl = ((CPPImplicitMethod)method).getPrimaryDeclaration(); + if (method instanceof CPPMethod) { + decl = ((CPPMethod) method).getPrimaryDeclaration(); + } 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(); } @@ -703,7 +699,7 @@ public class ASTManager { ICPPClassType classType= classScope.getClassType(); ICPPBase[] bases= classType.getBases(); for (ICPPBase base : bases) { - if( !(base.getBaseClass() instanceof ICPPClassType) ) + if (!(base.getBaseClass() instanceof ICPPClassType)) continue; ICPPClassType baseType= (ICPPClassType) base.getBaseClass(); if (baseType != null) { @@ -713,8 +709,8 @@ public class ASTManager { for (IBinding binding : alternates) { if (binding instanceof CPPMethod) { CPPMethod alternateMethod = (CPPMethod) binding; - if (hasSameSignature(method, alternateMethod)!=FALSE) { - if (isVirtualMethod(alternateMethod)==TRUE) { + if (hasSameSignature(method, alternateMethod) != FALSE) { + if (isVirtualMethod(alternateMethod) == TRUE) { return TRUE; } } @@ -758,7 +754,7 @@ public class ASTManager { boolean removeGlobalsWhenClassScope) throws DOMException { IBinding[] result= null; result = scope.find(name); - if (result == null || result.length==0) { + if (result == null || result.length == 0) { return result; } @@ -772,8 +768,7 @@ public class ASTManager { IScope bscope= binding.getScope(); if (! (bscope instanceof ICPPClassScope || bscope instanceof ICCompositeTypeScope)) { result[i]= null; - } - else { + } else { count++; } } @@ -823,10 +818,10 @@ public class ASTManager { return; } - if( fArgument.getSourceFile() == null ) + 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); @@ -946,12 +941,11 @@ public class ASTManager { for (IFile file : files) { cc++; if (store.contains(file)) { - if ((now=System.currentTimeMillis()) > update) { + 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; + update= now + 1000; } boolean doParse= false; Collection fm= store.getMatchesForFile(file); @@ -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(); @@ -1130,7 +1119,7 @@ public class ASTManager { protected IPath addConflictingBindingForName(final RefactoringStatus status, IASTName name) { IASTNodeLocation[] locations= name.getNodeLocations(); IPath path= null; - if (locations != null && locations.length==1) { + if (locations != null && locations.length == 1) { IASTNodeLocation loc= locations[0]; IASTFileLocation floc= loc.asFileLocation(); if (floc != null) { @@ -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; } @@ -1217,7 +1204,7 @@ public class ASTManager { } fKnownBindings.put(binding, new Integer(cmp)); } - switch(cmp) { + switch (cmp) { case TRUE: match.setASTInformation(CRefactoringMatch.AST_REFERENCE); if (fRenameTo != null) { @@ -1251,30 +1238,24 @@ 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); } } } - @SuppressWarnings("unchecked") - protected void handleConflictingBindings(IASTTranslationUnit tu, - RefactoringStatus status) { + @SuppressWarnings("unchecked") + protected void handleConflictingBindings(IASTTranslationUnit tu, RefactoringStatus status) { if (fConflictingBinding.isEmpty()) { return; } @@ -1286,7 +1267,7 @@ public class ASTManager { boolean isContainer = false; boolean isMacro= false; - switch(argKind) { + switch (argKind) { case CRefactory.ARGUMENT_LOCAL_VAR: case CRefactory.ARGUMENT_PARAMETER: isLocalVarPar= true; @@ -1316,21 +1297,21 @@ public class ASTManager { break; } - Collection[] cflc= new Collection[] {new HashSet(), new ArrayList(), new ArrayList()}; + Collection[] cflc= + new Collection[] { new HashSet(), new ArrayList(), new ArrayList() }; String[] errs= null; if (isMacro) { - errs= new String[]{ - Messages.getString("CRenameLocalProcessor.error.conflict") //$NON-NLS-1$ - }; + errs= new String[] { + Messages.CRenameLocalProcessor_error_conflict }; cflc[0]= fConflictingBinding; - } - 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) cflc[0], (List)cflc[1], (List)cflc[2], status); + } else { + errs= new String[] { + Messages.CRenameLocalProcessor_error_shadow, + Messages.CRenameLocalProcessor_error_redeclare, + Messages.CRenameLocalProcessor_error_isShadowed, + Messages.CRenameLocalProcessor_error_overloads }; + classifyConflictingBindings(tu, (Set) cflc[0], (List) cflc[1], + (List) cflc[2], status); } for (int i = 0; i < 3; i++) { @@ -1342,50 +1323,44 @@ 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) { + 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) { + 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) { + if (i == 1) { IBinding r= fArgument.getBinding(); if (r instanceof ICPPMethod) { try { @@ -1398,22 +1373,21 @@ 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) { IASTName[] refs= fArgument.getTranslationUnit().getReferences(conflict); - if (refs==null || refs.length==0) { + if (refs == null || refs.length == 0) { ignore= true; } } if (!ignore) { IFunction conflictingFunction= (IFunction) conflict; - if (i==1 && conflict instanceof ICPPFunction) { + if (i == 1 && conflict instanceof ICPPFunction) { IBinding r= fArgument.getBinding(); if (r instanceof ICPPFunction) { try { @@ -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$ - if (argKind==CRefactory.ARGUMENT_NAMESPACE) { + 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); } } @@ -1507,7 +1474,7 @@ public class ASTManager { } } - if (newBindingsAboverOrEqual!=null && newBindingsAboverOrEqual.length>0) { + if (newBindingsAboverOrEqual != null && newBindingsAboverOrEqual.length>0) { break; } } @@ -1540,10 +1507,9 @@ public class ASTManager { IScope aboveScope; try { aboveScope = aboveBinding.getScope(); - if (isSameScope(aboveScope, oldBindingsScope, false)==TRUE) { + 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; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java index 881fc661d1d..de1e450c479 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatch.java @@ -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; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java index d76afaa39ad..bef3c0a3014 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java @@ -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); @@ -86,10 +84,9 @@ public class CRefactory { try { CRenameRefactoring r= new CRenameRefactoring(processor); RefactoringWizardOpenOperation op= - new RefactoringWizardOpenOperation(new CRenameRefactoringWizard(r)); - op.run(shell, Messages.getString("CRefactory.title.rename")); //$NON-NLS-1$ - } - finally { + new RefactoringWizardOpenOperation(new CRenameRefactoringWizard(r)); + 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()); @@ -116,8 +111,8 @@ public class CRefactory { try { CRenameRefactoring r= new CRenameRefactoring(processor); RefactoringWizardOpenOperation op= - new RefactoringWizardOpenOperation(new CRenameRefactoringWizard(r)); - op.run(shell, Messages.getString("CRefactory.title.rename")); //$NON-NLS-1$ + new RefactoringWizardOpenOperation(new CRenameRefactoringWizard(r)); + op.run(shell, Messages.CRefactory_title_rename); } finally { processor.unlockIndex(); } @@ -146,15 +141,13 @@ public class CRefactory { id.equals(CCorePlugin.CONTENT_TYPE_CSOURCE) || id.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) || id.equals(CCorePlugin.CONTENT_TYPE_CXXSOURCE)) { - useit= true; - } - else { + useit= true; + } 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)); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java index e05c2dddca9..8ce6f377b58 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameIncludeProcessor.java @@ -24,7 +24,6 @@ public class CRenameIncludeProcessor extends CRenameProcessorDelegate { setOptionsEnablingScope(-1); } - @Override protected int getAcceptedLocations(int selectedOptions) { return selectedOptions | CRefactory.OPTION_IN_INCLUDE_DIRECTIVE; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java index 5fbe1b01e44..60b064d340e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java @@ -52,7 +52,6 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate { @Override protected void analyzeTextMatches(ArrayList matches, IProgressMonitor monitor, RefactoringStatus status) { - super.analyzeTextMatches(matches, monitor, status); if (fScope != null) { CRefactoringArgument argument = getArgument(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java index 7786851c6d0..c7ce33b7c9b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMethodProcessor.java @@ -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)); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java index 635dfafdbf8..7c24fabb348 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessor.java @@ -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; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java index 95d9158f8ef..2df87eb865a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java @@ -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; @@ -50,18 +49,18 @@ public abstract class CRenameProcessorDelegate { private ArrayList fMatches= null; protected String fProcessorBaseName; private int fAvailableOptions= - CRefactory.OPTION_ASK_SCOPE | - CRefactory.OPTION_IN_CODE | - CRefactory.OPTION_IN_COMMENT | - CRefactory.OPTION_IN_MACRO_DEFINITION | - CRefactory.OPTION_IN_STRING_LITERAL; + CRefactory.OPTION_ASK_SCOPE | + CRefactory.OPTION_IN_CODE | + CRefactory.OPTION_IN_COMMENT | + CRefactory.OPTION_IN_MACRO_DEFINITION | + CRefactory.OPTION_IN_STRING_LITERAL; private int fOptionsForcingPreview= - CRefactory.OPTION_IN_CODE | - CRefactory.OPTION_IN_COMMENT | - CRefactory.OPTION_IN_MACRO_DEFINITION | - CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE | - CRefactory.OPTION_IN_STRING_LITERAL; + CRefactory.OPTION_IN_CODE | + CRefactory.OPTION_IN_COMMENT | + CRefactory.OPTION_IN_MACRO_DEFINITION | + CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE | + CRefactory.OPTION_IN_STRING_LITERAL; private int fOptionsEnablingScope= fOptionsForcingPreview; @@ -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; @@ -173,15 +179,14 @@ public abstract class CRenameProcessorDelegate { HashSet fileset= new HashSet(); int potentialMatchCount= 0; - int commentCount=0; + int commentCount= 0; for (Iterator iter = fMatches.iterator(); iter.hasNext();) { CRefactoringMatch tm = iter.next(); if (tm.isInComment()) { commentCount++; fileset.add(tm.getFile()); - } - else { - switch(tm.getAstInformation()) { + } else { + switch (tm.getAstInformation()) { case CRefactoringMatch.AST_REFERENCE_OTHER: iter.remove(); break; @@ -191,38 +196,32 @@ public abstract class CRenameProcessorDelegate { break; default: fileset.add(tm.getFile()); - break; + break; } } } 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); } IFile[] files= fileset.toArray(new IFile[fileset.size()]); if (context != null) { - ValidateEditChecker editChecker= - (ValidateEditChecker) context.getChecker(ValidateEditChecker.class); + ValidateEditChecker editChecker= + (ValidateEditChecker) context.getChecker(ValidateEditChecker.class); editChecker.addFiles(files); } monitor.done(); @@ -246,7 +245,7 @@ public abstract class CRenameProcessorDelegate { for (Iterator 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()); @@ -280,7 +279,7 @@ public abstract class CRenameProcessorDelegate { TextFileChange fileChange= null; MultiTextEdit fileEdit= null; for (CRefactoringMatch match : fMatches) { - switch(match.getAstInformation()) { + switch (match.getAstInformation()) { case CRefactoringMatch.AST_REFERENCE_OTHER: continue; case CRefactoringMatch.IN_COMMENT: @@ -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); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java index f024f5f2010..906c47e3b54 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java @@ -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)); - gd.horizontalSpan= 2; - group.setLayout(gl= new GridLayout(3, false)); - gl.marginHeight= 0; + fSingle.setText(Messages.CRenameRefactoringInputPage_button_singleProject); + fSingle.setLayoutData(gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING)); + gd.horizontalIndent= 8; + gd.horizontalSpan= 2; 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,48 +172,46 @@ 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(); readPreferences(); - onSelectOption(); // transfers the option to the refactoring/ enablement + onSelectOption(); // transfers the option to the refactoring / enablement 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); } @@ -488,7 +489,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { protected void updateEnablement() { boolean enable= fEnableScopeOptions==-1 || - (computeSelectedOptions() & fEnableScopeOptions) != 0; + (computeSelectedOptions() & fEnableScopeOptions) != 0; if (fWorkspace != null) { fWorkspace.setEnabled(enable); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.java index 63c3d6172ff..391e01e4f65 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.java @@ -1,31 +1,112 @@ /******************************************************************************* - * 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * 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 + '!'; - } - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.properties new file mode 100644 index 00000000000..cb2e29ff555 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/Messages.properties @@ -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 diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java index 9b93207ab81..2cf1e55a9c5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameCSourceFolderChange.java @@ -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,16 +37,12 @@ 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(); @@ -54,7 +50,6 @@ public class RenameCSourceFolderChange extends Change { 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 @@ -73,18 +68,16 @@ public class RenameCSourceFolderChange extends Change { @Override public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException, OperationCanceledException { - if(folder.exists()) { + 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$ - + } else { + 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); @@ -92,7 +85,7 @@ public class RenameCSourceFolderChange extends Change { private void changeEntryInAllCfgs(ICProjectDescription des) throws WriteAccessException, CoreException{ ICConfigurationDescription cfgs[] = des.getConfigurations(); - for(ICConfigurationDescription cfg : cfgs){ + for (ICConfigurationDescription cfg : cfgs){ ICSourceEntry[] entries = cfg.getSourceEntries(); entries = renameEntry(entries); cfg.setSourceEntries(entries); @@ -102,18 +95,18 @@ public class RenameCSourceFolderChange extends Change { private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){ Set set = new HashSet(); - for(ICSourceEntry se : entries){ + for (ICSourceEntry se : entries){ String seLocation = se.getName(); if(seLocation.equals(oldName.toPortableString())) { ICSourceEntry newSE = new CSourceEntry(newName, se.getExclusionPatterns(), se.getFlags()); set.add(newSE); - }else { + } else { Set exPatters = new HashSet(); for (IPath filter : se.getExclusionPatterns()) { IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() -1); - if(filter.equals(oldSegments)) { + if (filter.equals(oldSegments)) { exPatters.add(newName.removeFirstSegments(newName.segmentCount() -1)); - }else { + } else { exPatters.add(filter); } } @@ -123,5 +116,4 @@ public class RenameCSourceFolderChange extends Change { } return set.toArray(new ICSourceEntry[set.size()]); } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java index b8863dfe4a6..9d0b8828467 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSourceFolder.java @@ -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); @@ -50,14 +45,13 @@ public class RenameSourceFolder extends RenameParticipant { @Override public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException { IPath oldFolderPath = oldFolder.getFullPath(); - IPath newFolderPath = oldFolder.getFullPath().uptoSegment(oldFolder.getFullPath().segmentCount()-1).append(newName); - + 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; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java index 7729ab88ff8..c2f3b3d7015 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java @@ -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 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 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 locations= null; for (Iterator iter = matches.iterator(); iter.hasNext();) { @@ -288,6 +286,7 @@ public class TextSearchWrapper { return (o1)[0]-(o2)[0]; } }; + private int findLocation(CRefactoringMatch match, ArrayList 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) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties deleted file mode 100644 index 756a9d167f9..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/messages.properties +++ /dev/null @@ -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