From 10f7e547a12358c7892dcbc939df99cc03e051d5 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 24 Apr 2012 17:31:36 -0700 Subject: [PATCH] Cosmetics. --- .../cdt/internal/core/model/CElement.java | 76 ++++++++----------- .../org/eclipse/cdt/core/index/IIndex.java | 9 +-- .../internal/core/index/CPPTypedefClone.java | 2 +- .../core/pdom/dom/cpp/PDOMCPPLinkage.java | 23 +++--- .../pdom/dom/cpp/PDOMCPPUsingDeclaration.java | 5 +- ...PDOMCPPUsingDeclarationSpecialization.java | 5 +- .../refactoring/rename/RefactoringTests.java | 4 +- .../rename/RenameFunctionTests.java | 6 +- .../refactoring/rename/RenameMacroTests.java | 7 +- .../rename/RenameTemplatesTests.java | 6 +- .../tests/refactoring/rename/RenameTests.java | 8 +- .../refactoring/rename/RenameTypeTests.java | 6 +- .../rename/RenameVariableTests.java | 5 +- .../rename/TestRenameParticipant.java | 25 +++--- .../refactoring/rename/CRefactoringMatch.java | 4 +- .../rename/CRenameClassProcessor.java | 3 +- .../rename/CRenameTypeProcessor.java | 2 +- 17 files changed, 90 insertions(+), 106 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java index 7a1f3f31d24..6f83bf1a5a3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CElement.java @@ -10,7 +10,6 @@ * Markus Schorn (Wind River Systems) * Anton Leherbauer (Wind River Systems) *******************************************************************************/ - package org.eclipse.cdt.internal.core.model; import java.net.URI; @@ -41,7 +40,6 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.PlatformObject; public abstract class CElement extends PlatformObject implements ICElement { - public static final char CEM_ESCAPE = '\\'; public static final char CEM_CPROJECT = '='; public static final char CEM_SOURCEROOT = '/'; @@ -51,11 +49,10 @@ public abstract class CElement extends PlatformObject implements ICElement { public static final char CEM_PARAMETER = '('; public static final char CEM_ELEMENTTYPE = '#'; - protected static final CElement[] NO_ELEMENTS = new CElement[0]; + protected static final CElement[] NO_ELEMENTS = {}; + protected int fType; - protected ICElement fParent; - protected String fName; protected CElement(ICElement parent, String name, int type) { @@ -80,7 +77,6 @@ public abstract class CElement extends PlatformObject implements ICElement { return super.getAdapter(adapter); } - // setters public void setElementType (int type) { @@ -123,14 +119,7 @@ public abstract class CElement extends PlatformObject implements ICElement { @Override public URI getLocationURI() { IResource res = getUnderlyingResource(); - - if(res != null) { - return res.getLocationURI(); - } - - else { - return null; - } + return res == null ? null : res.getLocationURI(); } @Override @@ -138,8 +127,7 @@ public abstract class CElement extends PlatformObject implements ICElement { try { return getElementInfo() != null; } catch (CModelException e) { - // Do not log it, it will fil the .log alarming the user. - //CCorePlugin.log(e); + // Do not log it, otherwise it would fill the .log alarming the user. return false; } } @@ -153,7 +141,7 @@ public abstract class CElement extends PlatformObject implements ICElement { */ protected ICElement getSourceElementAtOffset(int offset) throws CModelException { if (this instanceof ISourceReference && this instanceof Parent) { - ICElement[] children = ((Parent)this).getChildren(); + ICElement[] children = ((Parent) this).getChildren(); for (ICElement aChild : children) { if (aChild instanceof ISourceReference) { ISourceReference child = (ISourceReference) aChild; @@ -162,9 +150,9 @@ public abstract class CElement extends PlatformObject implements ICElement { int endPos = startPos + range.getLength(); if (offset < endPos && offset >= startPos) { if (child instanceof Parent) { - return ((Parent)child).getSourceElementAtOffset(offset); + return ((Parent) child).getSourceElementAtOffset(offset); } - return (ICElement)child; + return (ICElement) child; } } } @@ -185,7 +173,7 @@ public abstract class CElement extends PlatformObject implements ICElement { protected ICElement[] getSourceElementsAtOffset(int offset) throws CModelException { if (this instanceof ISourceReference && this instanceof Parent) { ArrayList list = new ArrayList(); - ICElement[] children = ((Parent)this).getChildren(); + ICElement[] children = ((Parent) this).getChildren(); for (ICElement aChild : children) { if (aChild instanceof ISourceReference) { ISourceReference child = (ISourceReference) aChild; @@ -194,7 +182,7 @@ public abstract class CElement extends PlatformObject implements ICElement { int endPos = startPos + range.getLength(); if (offset < endPos && offset >= startPos) { if (child instanceof Parent) { - ICElement[] elements = ((Parent)child).getSourceElementsAtOffset(offset); + ICElement[] elements = ((Parent) child).getSourceElementsAtOffset(offset); list.addAll(Arrays.asList(elements)); } list.add(child); @@ -238,7 +226,8 @@ public abstract class CElement extends PlatformObject implements ICElement { public ICProject getCProject() { ICElement current = this; do { - if (current instanceof ICProject) return (ICProject) current; + if (current instanceof ICProject) + return (ICProject) current; } while ((current = current.getParent()) != null); return null; } @@ -285,7 +274,7 @@ public abstract class CElement extends PlatformObject implements ICElement { } String lhsName= lhs.getElementName(); String rhsName= rhs.getElementName(); - if( lhsName == null || rhsName == null || lhsName.length() != rhsName.length() || + if (lhsName == null || rhsName == null || lhsName.length() != rhsName.length() || !lhsName.equals(rhsName)) { return false; } @@ -311,7 +300,7 @@ public abstract class CElement extends PlatformObject implements ICElement { public CElementInfo getElementInfo (IProgressMonitor monitor) throws CModelException { CModelManager manager = CModelManager.getDefault(); - CElementInfo info = (CElementInfo)manager.getInfo(this); + CElementInfo info = (CElementInfo) manager.getInfo(this); if (info != null) { return info; } @@ -326,7 +315,7 @@ public abstract class CElement extends PlatformObject implements ICElement { } public String toDebugString() { - return getElementName() + " " + getTypeString(); //$NON-NLS-1$ + return getElementName() + " " + getTypeString(); //$NON-NLS-1$ } // util @@ -367,11 +356,11 @@ public abstract class CElement extends PlatformObject implements ICElement { case C_FIELD: return "C_FIELD"; //$NON-NLS-1$ case C_METHOD: - return "C_METHOD"; //$NON-NLS-1$ + return "C_METHOD"; //$NON-NLS-1$ case C_NAMESPACE: - return "C_NAMESPACE"; //$NON-NLS-1$ + return "C_NAMESPACE"; //$NON-NLS-1$ case C_USING: - return "C_USING"; //$NON-NLS-1$ + return "C_USING"; //$NON-NLS-1$ case C_VCONTAINER: return "C_CONTAINER"; //$NON-NLS-1$ case C_BINARY: @@ -411,7 +400,7 @@ public abstract class CElement extends PlatformObject implements ICElement { */ public IOpenable getOpenableParent() { if (fParent instanceof IOpenable) { - return (IOpenable)fParent; + return (IOpenable) fParent; } return null; } @@ -426,7 +415,8 @@ public abstract class CElement extends PlatformObject implements ICElement { * if successful, or false if an error is encountered while determining * the structure of this element. */ - protected abstract void generateInfos(CElementInfo info, Map newElements, IProgressMonitor monitor) throws CModelException; + protected abstract void generateInfos(CElementInfo info, Map newElements, + IProgressMonitor monitor) throws CModelException; /** * Open a IOpenable that is known to be closed (no check for @@ -441,13 +431,14 @@ public abstract class CElement extends PlatformObject implements ICElement { if (info == null) { info = newElements.get(this); } - if (info == null) { // a source ref element could not be opened - // close any buffer that was opened for the openable parent + if (info == null) { + // A source ref element could not be opened. + // Close any buffer that was opened for the openable parent. Iterator iterator = newElements.keySet().iterator(); while (iterator.hasNext()) { ICElement element = iterator.next(); if (element instanceof Openable) { - ((Openable)element).closeBuffer(); + ((Openable) element).closeBuffer(); } } throw newNotPresentException(); @@ -455,7 +446,6 @@ public abstract class CElement extends PlatformObject implements ICElement { if (!hadTemporaryCache) { manager.putInfos(this, newElements); } - } finally { if (!hadTemporaryCache) { manager.resetTemporaryCache(); @@ -463,7 +453,6 @@ public abstract class CElement extends PlatformObject implements ICElement { } } - /** * @see ICElement */ @@ -519,17 +508,14 @@ public abstract class CElement extends PlatformObject implements ICElement { return Util.combineHashCodes(elem.getElementName().hashCode(), parent.hashCode()); } - /* - * Test to see if two objects are identical + /** + * Checks if two objects are identical * Subclasses should override accordingly */ public boolean isIdentical(CElement otherElement){ return this.equals(otherElement); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.model.ICElement#accept(org.eclipse.cdt.core.model.ICElementVisitor) - */ @Override public void accept(ICElementVisitor visitor) throws CoreException { // Visit me, return right away if the visitor doesn't want to visit my children @@ -538,15 +524,13 @@ public abstract class CElement extends PlatformObject implements ICElement { // If I am a Parent, visit my children if (this instanceof IParent) { - ICElement [] children = ((IParent)this).getChildren(); - for (int i = 0; i < children.length; ++i) + ICElement [] children = ((IParent) this).getChildren(); + for (int i = 0; i < children.length; ++i) { children[i].accept(visitor); + } } } - /* - * @see org.eclipse.cdt.core.model.ICElement#getHandleIdentifier() - */ @Override public String getHandleIdentifier() { return getHandleMemento(); @@ -569,7 +553,7 @@ public abstract class CElement extends PlatformObject implements ICElement { * @param buff the buffer building the memento string */ public void getHandleMemento(StringBuilder buff) { - ((CElement)getParent()).getHandleMemento(buff); + ((CElement) getParent()).getHandleMemento(buff); buff.append(getHandleMementoDelimiter()); escapeMementoName(buff, getElementName()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java index 283652b41fe..87a8b947dd6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/index/IIndex.java @@ -82,8 +82,7 @@ public interface IIndex { * index.acquireReadLock(); * try { * .... - * } - * finally { + * } finally { * index.releaseReadLock(); * } * @@ -113,8 +112,7 @@ public interface IIndex { * try { * timestamp= index.getLastWriteAccess(); * binding= index.findBinding(...); - * } - * finally { + * } finally { * index.releaseReadLock(); * } * ... @@ -126,8 +124,7 @@ public interface IIndex { * } * String name= binding.getName(); * ... - * } - * finally { + * } finally { * index.releaseReadLock(); * } */ diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java index 47d06d5b46a..4f3428d02ba 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/CPPTypedefClone.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bryan Wilkinson (QNX) - Initial API and implementation + * Bryan Wilkinson (QNX) - Initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.index; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index 0ca965e8261..03e07663c86 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -336,7 +336,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return null; if (binding instanceof ICPPSpecialization) { - IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding(); + IBinding specialized = ((ICPPSpecialization) binding).getSpecializedBinding(); PDOMBinding pdomSpecialized= addBinding(specialized, null); if (pdomSpecialized == null) return null; @@ -371,11 +371,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } else if (binding instanceof ICPPConstructor) { if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) { - pdomBinding = new PDOMCPPConstructor(this, parent, (ICPPConstructor)binding); + pdomBinding = new PDOMCPPConstructor(this, parent, (ICPPConstructor) binding); } } else if (binding instanceof ICPPMethod) { if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) { - pdomBinding = new PDOMCPPMethod(this, parent, (ICPPMethod)binding); + pdomBinding = new PDOMCPPMethod(this, parent, (ICPPMethod) binding); } } else if (binding instanceof ICPPFunction) { pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true); @@ -397,7 +397,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } } else if (binding instanceof ITypedef) { - pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef)binding); + pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef) binding); } if (pdomBinding != null) { @@ -611,7 +611,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null); } - private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, long[] fileLocalRecHolder) throws CoreException { + private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, long[] fileLocalRecHolder) + throws CoreException { if (cannotAdapt(inputBinding)) { return null; } @@ -639,7 +640,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { final Long key = record + CACHE_BASES; PDOMCPPNamespace[] result= (PDOMCPPNamespace[]) getPDOM().getCachedResult(key); if (result == null) { - List nslist = PDOMCPPNamespace.collectInlineNamespaces(getDB(), getLinkage(), record+FIRST_NAMESPACE_CHILD_OFFSET); + List nslist = PDOMCPPNamespace.collectInlineNamespaces(getDB(), + getLinkage(), record + FIRST_NAMESPACE_CHILD_OFFSET); if (nslist == null) { result= new PDOMCPPNamespace[0]; } else { @@ -651,9 +653,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } /** - * Find the equivalent binding, or binding place holder within this PDOM + * Finds the equivalent binding, or binding placeholder within this PDOM. */ - private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding, long[] fileLocalRecHolder) throws CoreException { + private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding, long[] fileLocalRecHolder) + throws CoreException { if (parent == null) { parent= adaptOrAddParent(false, binding); } @@ -935,9 +938,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { } } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage#getUsingDirectives() - */ @Override public ICPPUsingDirective[] getUsingDirectives(PDOMFile file) throws CoreException { long rec= file.getLastUsingDirectiveRec(); @@ -1025,7 +1025,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants { public PDOMBinding addTypeBinding(IBinding type) throws CoreException { return addBinding(type, null); } - @Override public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclaration.java index 888d4713d27..dc777af3e20 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclaration.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Sergey Prigogin (Google) - initial API and implementation - * Markus Schorn (Wind River Systems) + * Sergey Prigogin (Google) - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -33,7 +33,6 @@ import org.eclipse.core.runtime.CoreException; * @see ICPPUsingDeclaration */ class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclaration { - private static final int TARGET_BINDING = PDOMCPPBinding.RECORD_SIZE + 0; // Using declarations for functions may have multiple delegates. We model such case // by creating a chain of PDOMCPPUsingDeclaration objects linked by NEXT_DELEGATE field. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java index 2a305683c4f..953057620fc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPUsingDeclarationSpecialization.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn (Wind River Systems) + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.dom.cpp; @@ -67,7 +67,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem @Override public IBinding[] getDelegates() { if (delegates == null) { - PDOMNodeLinkedList list= new PDOMNodeLinkedList(getLinkage(), record+TARGET_BINDINGS); + PDOMNodeLinkedList list= new PDOMNodeLinkedList(getLinkage(), record+ TARGET_BINDINGS); final List result= new ArrayList(); try { list.accept(new IPDOMVisitor() { @@ -78,6 +78,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem } return true; } + @Override public void leave(IPDOMNode node) { } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java index c49939ad739..9ce5fe8f045 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RefactoringTests.java @@ -49,7 +49,7 @@ public class RefactoringTests extends BaseTestFramework { super.setUp(); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); fBufferSize= FileCharSequenceProvider.BUFFER_SIZE; - FileCharSequenceProvider.BUFFER_SIZE= 1024*4; + FileCharSequenceProvider.BUFFER_SIZE= 1024 * 4; } @Override @@ -65,7 +65,7 @@ public class RefactoringTests extends BaseTestFramework { protected void assertTotalChanges(int numChanges, int potChanges, int commentCh, Change changes) throws Exception { - int count[]= {0,0,0}; + int count[]= { 0, 0, 0 }; if (changes != null) { countChanges(changes, count); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java index 8d4fbaf1742..dbcadd68663 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameFunctionTests.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; @@ -21,12 +21,14 @@ import org.eclipse.ltk.core.refactoring.RefactoringStatus; public class RenameFunctionTests extends RenameTests { - public RenameFunctionTests(String name) { + public RenameFunctionTests(String name) { super(name); } + public static Test suite(){ return suite(true); } + public static Test suite( boolean cleanup ) { TestSuite suite = new TestSuite(RenameFunctionTests.class); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java index dd5c7874575..8c2478c4e8b 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameMacroTests.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; @@ -24,9 +24,11 @@ public class RenameMacroTests extends RenameTests { public RenameMacroTests(String name) { super(name); } + public static Test suite(){ return suite(true); } + public static Test suite( boolean cleanup ) { TestSuite suite = new TestSuite(RenameMacroTests.class); if (cleanup) { @@ -34,8 +36,7 @@ public class RenameMacroTests extends RenameTests { } return suite; } - - + public void testMacroRename() throws Exception { StringWriter writer = new StringWriter(); writer.write("#define HALLO x \n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java index 326072ac480..1adde370a20 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTemplatesTests.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.ui.tests.refactoring.rename; import java.io.StringWriter; @@ -28,9 +27,11 @@ public class RenameTemplatesTests extends RenameTests { public RenameTemplatesTests(String name) { super(name); } + public static Test suite(){ return suite(true); } + public static Test suite( boolean cleanup ) { TestSuite suite = new TestSuite(RenameTemplatesTests.class); if (cleanup) { @@ -39,7 +40,6 @@ public class RenameTemplatesTests extends RenameTests { return suite; } - public void testClassTemplate() throws Exception { StringWriter writer = new StringWriter(); writer.write("template \n"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java index 978507cb480..93c3c673ff7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.rename; @@ -31,7 +31,6 @@ import org.eclipse.cdt.internal.ui.refactoring.rename.TextSearchWrapper; * @author markus.schorn@windriver.com */ public class RenameTests extends RefactoringTests { - private static final IProgressMonitor NPM = new NullProgressMonitor(); public RenameTests(String name) { @@ -58,7 +57,7 @@ public class RenameTests extends RefactoringTests { return change; } - fail ("Input check on "+ newName + " failed. "+rs.getEntryMatchingSeverity(RefactoringStatus.ERROR) ); //$NON-NLS-1$ //$NON-NLS-2$ + fail ("Input check on " + newName + " failed. "+rs.getEntryMatchingSeverity(RefactoringStatus.ERROR) ); //$NON-NLS-1$ //$NON-NLS-2$ //rs.getFirstMessage(RefactoringStatus.ERROR) is not the message displayed in //the UI for renaming a method to a constructor, the first message which is only //a warning is shown in the UI. If you click preview, then the error and the warning @@ -153,8 +152,7 @@ public class RenameTests extends RefactoringTests { } @Override - protected IFile importFile(String fileName, String contents) - throws Exception { + protected IFile importFile(String fileName, String contents) throws Exception { IFile result= super.importFile(fileName, contents); waitForIndexer(); return result; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java index ed5621fdd6f..bc6464046c5 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTypeTests.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.ui.tests.refactoring.rename; import java.io.StringWriter; @@ -38,8 +37,7 @@ public class RenameTypeTests extends RenameTests { } return suite; } - - + public void testClassNameConflicts() throws Exception { createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ createCppDefs("cpp_def.hh"); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java index ff65483d6f9..6ef0899cd2a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameVariableTests.java @@ -6,9 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.ui.tests.refactoring.rename; import java.io.StringWriter; @@ -28,9 +27,11 @@ public class RenameVariableTests extends RenameTests { public RenameVariableTests(String name) { super(name); } + public static Test suite(){ return suite(true); } + public static Test suite( boolean cleanup ) { TestSuite suite = new TestSuite(RenameVariableTests.class); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java index 09c972267d0..5ad7cfecb86 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/TestRenameParticipant.java @@ -6,20 +6,24 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ - package org.eclipse.cdt.ui.tests.refactoring.rename; -import org.eclipse.core.runtime.*; -import org.eclipse.ltk.core.refactoring.*; -import org.eclipse.ltk.core.refactoring.participants.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.ltk.core.refactoring.Change; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext; +import org.eclipse.ltk.core.refactoring.participants.RenameArguments; +import org.eclipse.ltk.core.refactoring.participants.RenameParticipant; public class TestRenameParticipant extends RenameParticipant { - private static Object sElement= null; - private static RenameArguments sArguments= null; - private static int sConditionCheck= 0; - private static int sCreateChange= 0; + private static Object sElement; + private static RenameArguments sArguments; + private static int sConditionCheck; + private static int sCreateChange; public static int getConditionCheckCount() { return sConditionCheck; @@ -40,7 +44,8 @@ public class TestRenameParticipant extends RenameParticipant { public static void reset() { sElement= null; sArguments= null; - sConditionCheck= sCreateChange= 0; + sConditionCheck= 0; + sCreateChange= 0; } @Override 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 63cc8decf52..96690fba923 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 @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -63,7 +63,7 @@ public class CRefactoringMatch { return fFile; } public void setASTInformation(int val) { - switch(fAstInformation) { + switch (fAstInformation) { case AST_REFERENCE: case AST_REFERENCE_OTHER: case AST_REFEREENCE_CONFLICTING: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java index 222d6de2ba5..07a56aa5bc8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameClassProcessor.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -20,7 +20,6 @@ import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; - /** * Processor adding constructor and destructor to the bindings to be renamed. */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java index 97c094a4590..99fb91fd273 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameTypeProcessor.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename;