1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2012-04-24 17:31:36 -07:00
parent 383f0d289c
commit 10f7e547a1
17 changed files with 90 additions and 106 deletions

View file

@ -10,7 +10,6 @@
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.net.URI; import java.net.URI;
@ -41,7 +40,6 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
public abstract class CElement extends PlatformObject implements ICElement { public abstract class CElement extends PlatformObject implements ICElement {
public static final char CEM_ESCAPE = '\\'; public static final char CEM_ESCAPE = '\\';
public static final char CEM_CPROJECT = '='; public static final char CEM_CPROJECT = '=';
public static final char CEM_SOURCEROOT = '/'; 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_PARAMETER = '(';
public static final char CEM_ELEMENTTYPE = '#'; 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 int fType;
protected ICElement fParent; protected ICElement fParent;
protected String fName; protected String fName;
protected CElement(ICElement parent, String name, int type) { protected CElement(ICElement parent, String name, int type) {
@ -80,7 +77,6 @@ public abstract class CElement extends PlatformObject implements ICElement {
return super.getAdapter(adapter); return super.getAdapter(adapter);
} }
// setters // setters
public void setElementType (int type) { public void setElementType (int type) {
@ -123,14 +119,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
@Override @Override
public URI getLocationURI() { public URI getLocationURI() {
IResource res = getUnderlyingResource(); IResource res = getUnderlyingResource();
return res == null ? null : res.getLocationURI();
if(res != null) {
return res.getLocationURI();
}
else {
return null;
}
} }
@Override @Override
@ -138,8 +127,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
try { try {
return getElementInfo() != null; return getElementInfo() != null;
} catch (CModelException e) { } catch (CModelException e) {
// Do not log it, it will fil the .log alarming the user. // Do not log it, otherwise it would fill the .log alarming the user.
//CCorePlugin.log(e);
return false; return false;
} }
} }
@ -153,7 +141,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
*/ */
protected ICElement getSourceElementAtOffset(int offset) throws CModelException { protected ICElement getSourceElementAtOffset(int offset) throws CModelException {
if (this instanceof ISourceReference && this instanceof Parent) { if (this instanceof ISourceReference && this instanceof Parent) {
ICElement[] children = ((Parent)this).getChildren(); ICElement[] children = ((Parent) this).getChildren();
for (ICElement aChild : children) { for (ICElement aChild : children) {
if (aChild instanceof ISourceReference) { if (aChild instanceof ISourceReference) {
ISourceReference child = (ISourceReference) aChild; ISourceReference child = (ISourceReference) aChild;
@ -162,9 +150,9 @@ public abstract class CElement extends PlatformObject implements ICElement {
int endPos = startPos + range.getLength(); int endPos = startPos + range.getLength();
if (offset < endPos && offset >= startPos) { if (offset < endPos && offset >= startPos) {
if (child instanceof Parent) { 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 { protected ICElement[] getSourceElementsAtOffset(int offset) throws CModelException {
if (this instanceof ISourceReference && this instanceof Parent) { if (this instanceof ISourceReference && this instanceof Parent) {
ArrayList<Object> list = new ArrayList<Object>(); ArrayList<Object> list = new ArrayList<Object>();
ICElement[] children = ((Parent)this).getChildren(); ICElement[] children = ((Parent) this).getChildren();
for (ICElement aChild : children) { for (ICElement aChild : children) {
if (aChild instanceof ISourceReference) { if (aChild instanceof ISourceReference) {
ISourceReference child = (ISourceReference) aChild; ISourceReference child = (ISourceReference) aChild;
@ -194,7 +182,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
int endPos = startPos + range.getLength(); int endPos = startPos + range.getLength();
if (offset < endPos && offset >= startPos) { if (offset < endPos && offset >= startPos) {
if (child instanceof Parent) { if (child instanceof Parent) {
ICElement[] elements = ((Parent)child).getSourceElementsAtOffset(offset); ICElement[] elements = ((Parent) child).getSourceElementsAtOffset(offset);
list.addAll(Arrays.asList(elements)); list.addAll(Arrays.asList(elements));
} }
list.add(child); list.add(child);
@ -238,7 +226,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
public ICProject getCProject() { public ICProject getCProject() {
ICElement current = this; ICElement current = this;
do { do {
if (current instanceof ICProject) return (ICProject) current; if (current instanceof ICProject)
return (ICProject) current;
} while ((current = current.getParent()) != null); } while ((current = current.getParent()) != null);
return null; return null;
} }
@ -285,7 +274,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
String lhsName= lhs.getElementName(); String lhsName= lhs.getElementName();
String rhsName= rhs.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)) { !lhsName.equals(rhsName)) {
return false; return false;
} }
@ -311,7 +300,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
public CElementInfo getElementInfo (IProgressMonitor monitor) throws CModelException { public CElementInfo getElementInfo (IProgressMonitor monitor) throws CModelException {
CModelManager manager = CModelManager.getDefault(); CModelManager manager = CModelManager.getDefault();
CElementInfo info = (CElementInfo)manager.getInfo(this); CElementInfo info = (CElementInfo) manager.getInfo(this);
if (info != null) { if (info != null) {
return info; return info;
} }
@ -326,7 +315,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
public String toDebugString() { public String toDebugString() {
return getElementName() + " " + getTypeString(); //$NON-NLS-1$ return getElementName() + " " + getTypeString(); //$NON-NLS-1$
} }
// util // util
@ -367,11 +356,11 @@ public abstract class CElement extends PlatformObject implements ICElement {
case C_FIELD: case C_FIELD:
return "C_FIELD"; //$NON-NLS-1$ return "C_FIELD"; //$NON-NLS-1$
case C_METHOD: case C_METHOD:
return "C_METHOD"; //$NON-NLS-1$ return "C_METHOD"; //$NON-NLS-1$
case C_NAMESPACE: case C_NAMESPACE:
return "C_NAMESPACE"; //$NON-NLS-1$ return "C_NAMESPACE"; //$NON-NLS-1$
case C_USING: case C_USING:
return "C_USING"; //$NON-NLS-1$ return "C_USING"; //$NON-NLS-1$
case C_VCONTAINER: case C_VCONTAINER:
return "C_CONTAINER"; //$NON-NLS-1$ return "C_CONTAINER"; //$NON-NLS-1$
case C_BINARY: case C_BINARY:
@ -411,7 +400,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
*/ */
public IOpenable getOpenableParent() { public IOpenable getOpenableParent() {
if (fParent instanceof IOpenable) { if (fParent instanceof IOpenable) {
return (IOpenable)fParent; return (IOpenable) fParent;
} }
return null; 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 * if successful, or false if an error is encountered while determining
* the structure of this element. * the structure of this element.
*/ */
protected abstract void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements, IProgressMonitor monitor) throws CModelException; protected abstract void generateInfos(CElementInfo info, Map<ICElement, CElementInfo> newElements,
IProgressMonitor monitor) throws CModelException;
/** /**
* Open a <code>IOpenable</code> that is known to be closed (no check for * Open a <code>IOpenable</code> that is known to be closed (no check for
@ -441,13 +431,14 @@ public abstract class CElement extends PlatformObject implements ICElement {
if (info == null) { if (info == null) {
info = newElements.get(this); info = newElements.get(this);
} }
if (info == null) { // a source ref element could not be opened if (info == null) {
// close any buffer that was opened for the openable parent // A source ref element could not be opened.
// Close any buffer that was opened for the openable parent.
Iterator<ICElement> iterator = newElements.keySet().iterator(); Iterator<ICElement> iterator = newElements.keySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
ICElement element = iterator.next(); ICElement element = iterator.next();
if (element instanceof Openable) { if (element instanceof Openable) {
((Openable)element).closeBuffer(); ((Openable) element).closeBuffer();
} }
} }
throw newNotPresentException(); throw newNotPresentException();
@ -455,7 +446,6 @@ public abstract class CElement extends PlatformObject implements ICElement {
if (!hadTemporaryCache) { if (!hadTemporaryCache) {
manager.putInfos(this, newElements); manager.putInfos(this, newElements);
} }
} finally { } finally {
if (!hadTemporaryCache) { if (!hadTemporaryCache) {
manager.resetTemporaryCache(); manager.resetTemporaryCache();
@ -463,7 +453,6 @@ public abstract class CElement extends PlatformObject implements ICElement {
} }
} }
/** /**
* @see ICElement * @see ICElement
*/ */
@ -519,17 +508,14 @@ public abstract class CElement extends PlatformObject implements ICElement {
return Util.combineHashCodes(elem.getElementName().hashCode(), parent.hashCode()); 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 * Subclasses should override accordingly
*/ */
public boolean isIdentical(CElement otherElement){ public boolean isIdentical(CElement otherElement){
return this.equals(otherElement); return this.equals(otherElement);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ICElement#accept(org.eclipse.cdt.core.model.ICElementVisitor)
*/
@Override @Override
public void accept(ICElementVisitor visitor) throws CoreException { public void accept(ICElementVisitor visitor) throws CoreException {
// Visit me, return right away if the visitor doesn't want to visit my children // 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 I am a Parent, visit my children
if (this instanceof IParent) { if (this instanceof IParent) {
ICElement [] children = ((IParent)this).getChildren(); ICElement [] children = ((IParent) this).getChildren();
for (int i = 0; i < children.length; ++i) for (int i = 0; i < children.length; ++i) {
children[i].accept(visitor); children[i].accept(visitor);
}
} }
} }
/*
* @see org.eclipse.cdt.core.model.ICElement#getHandleIdentifier()
*/
@Override @Override
public String getHandleIdentifier() { public String getHandleIdentifier() {
return getHandleMemento(); return getHandleMemento();
@ -569,7 +553,7 @@ public abstract class CElement extends PlatformObject implements ICElement {
* @param buff the buffer building the memento string * @param buff the buffer building the memento string
*/ */
public void getHandleMemento(StringBuilder buff) { public void getHandleMemento(StringBuilder buff) {
((CElement)getParent()).getHandleMemento(buff); ((CElement) getParent()).getHandleMemento(buff);
buff.append(getHandleMementoDelimiter()); buff.append(getHandleMementoDelimiter());
escapeMementoName(buff, getElementName()); escapeMementoName(buff, getElementName());
} }

View file

@ -82,8 +82,7 @@ public interface IIndex {
* index.acquireReadLock(); * index.acquireReadLock();
* try { * try {
* .... * ....
* } * } finally {
* finally {
* index.releaseReadLock(); * index.releaseReadLock();
* } * }
* </pre> * </pre>
@ -113,8 +112,7 @@ public interface IIndex {
* try { * try {
* timestamp= index.getLastWriteAccess(); * timestamp= index.getLastWriteAccess();
* binding= index.findBinding(...); * binding= index.findBinding(...);
* } * } finally {
* finally {
* index.releaseReadLock(); * index.releaseReadLock();
* } * }
* ... * ...
@ -126,8 +124,7 @@ public interface IIndex {
* } * }
* String name= binding.getName(); * String name= binding.getName();
* ... * ...
* } * } finally {
* finally {
* index.releaseReadLock(); * index.releaseReadLock();
* } * }
*/ */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation * Bryan Wilkinson (QNX) - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index; package org.eclipse.cdt.internal.core.index;

View file

@ -336,7 +336,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return null; return null;
if (binding instanceof ICPPSpecialization) { if (binding instanceof ICPPSpecialization) {
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding(); IBinding specialized = ((ICPPSpecialization) binding).getSpecializedBinding();
PDOMBinding pdomSpecialized= addBinding(specialized, null); PDOMBinding pdomSpecialized= addBinding(specialized, null);
if (pdomSpecialized == null) if (pdomSpecialized == null)
return null; return null;
@ -371,11 +371,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
} else if (binding instanceof ICPPConstructor) { } else if (binding instanceof ICPPConstructor) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) { 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) { } else if (binding instanceof ICPPMethod) {
if (parent instanceof PDOMCPPClassType || parent instanceof PDOMCPPClassSpecialization) { 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) { } else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true); pdomBinding = new PDOMCPPFunction(this, parent, (ICPPFunction) binding, true);
@ -397,7 +397,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
} }
} else if (binding instanceof ITypedef) { } else if (binding instanceof ITypedef) {
pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef)binding); pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef) binding);
} }
if (pdomBinding != null) { if (pdomBinding != null) {
@ -611,7 +611,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null); 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)) { if (cannotAdapt(inputBinding)) {
return null; return null;
} }
@ -639,7 +640,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
final Long key = record + CACHE_BASES; final Long key = record + CACHE_BASES;
PDOMCPPNamespace[] result= (PDOMCPPNamespace[]) getPDOM().getCachedResult(key); PDOMCPPNamespace[] result= (PDOMCPPNamespace[]) getPDOM().getCachedResult(key);
if (result == null) { if (result == null) {
List<PDOMCPPNamespace> nslist = PDOMCPPNamespace.collectInlineNamespaces(getDB(), getLinkage(), record+FIRST_NAMESPACE_CHILD_OFFSET); List<PDOMCPPNamespace> nslist = PDOMCPPNamespace.collectInlineNamespaces(getDB(),
getLinkage(), record + FIRST_NAMESPACE_CHILD_OFFSET);
if (nslist == null) { if (nslist == null) {
result= new PDOMCPPNamespace[0]; result= new PDOMCPPNamespace[0];
} else { } 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) { if (parent == null) {
parent= adaptOrAddParent(false, binding); 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 @Override
public ICPPUsingDirective[] getUsingDirectives(PDOMFile file) throws CoreException { public ICPPUsingDirective[] getUsingDirectives(PDOMFile file) throws CoreException {
long rec= file.getLastUsingDirectiveRec(); long rec= file.getLastUsingDirectiveRec();
@ -1025,7 +1025,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
public PDOMBinding addTypeBinding(IBinding type) throws CoreException { public PDOMBinding addTypeBinding(IBinding type) throws CoreException {
return addBinding(type, null); return addBinding(type, null);
} }
@Override @Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Sergey Prigogin (Google) - initial API and implementation * Sergey Prigogin (Google) - initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -33,7 +33,6 @@ import org.eclipse.core.runtime.CoreException;
* @see ICPPUsingDeclaration * @see ICPPUsingDeclaration
*/ */
class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclaration { class PDOMCPPUsingDeclaration extends PDOMCPPBinding implements ICPPUsingDeclaration {
private static final int TARGET_BINDING = PDOMCPPBinding.RECORD_SIZE + 0; private static final int TARGET_BINDING = PDOMCPPBinding.RECORD_SIZE + 0;
// Using declarations for functions may have multiple delegates. We model such case // Using declarations for functions may have multiple delegates. We model such case
// by creating a chain of PDOMCPPUsingDeclaration objects linked by NEXT_DELEGATE field. // by creating a chain of PDOMCPPUsingDeclaration objects linked by NEXT_DELEGATE field.

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@ -67,7 +67,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem
@Override @Override
public IBinding[] getDelegates() { public IBinding[] getDelegates() {
if (delegates == null) { if (delegates == null) {
PDOMNodeLinkedList list= new PDOMNodeLinkedList(getLinkage(), record+TARGET_BINDINGS); PDOMNodeLinkedList list= new PDOMNodeLinkedList(getLinkage(), record+ TARGET_BINDINGS);
final List<IBinding> result= new ArrayList<IBinding>(); final List<IBinding> result= new ArrayList<IBinding>();
try { try {
list.accept(new IPDOMVisitor() { list.accept(new IPDOMVisitor() {
@ -78,6 +78,7 @@ class PDOMCPPUsingDeclarationSpecialization extends PDOMCPPSpecialization implem
} }
return true; return true;
} }
@Override @Override
public void leave(IPDOMNode node) { public void leave(IPDOMNode node) {
} }

View file

@ -49,7 +49,7 @@ public class RefactoringTests extends BaseTestFramework {
super.setUp(); super.setUp();
CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER); CCorePlugin.getIndexManager().setIndexerId(cproject, IPDOMManager.ID_FAST_INDEXER);
fBufferSize= FileCharSequenceProvider.BUFFER_SIZE; fBufferSize= FileCharSequenceProvider.BUFFER_SIZE;
FileCharSequenceProvider.BUFFER_SIZE= 1024*4; FileCharSequenceProvider.BUFFER_SIZE= 1024 * 4;
} }
@Override @Override
@ -65,7 +65,7 @@ public class RefactoringTests extends BaseTestFramework {
protected void assertTotalChanges(int numChanges, int potChanges, int commentCh, protected void assertTotalChanges(int numChanges, int potChanges, int commentCh,
Change changes) throws Exception { Change changes) throws Exception {
int count[]= {0,0,0}; int count[]= { 0, 0, 0 };
if (changes != null) { if (changes != null) {
countChanges(changes, count); countChanges(changes, count);
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; 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 class RenameFunctionTests extends RenameTests {
public RenameFunctionTests(String name) { public RenameFunctionTests(String name) {
super(name); super(name);
} }
public static Test suite(){ public static Test suite(){
return suite(true); return suite(true);
} }
public static Test suite( boolean cleanup ) { public static Test suite( boolean cleanup ) {
TestSuite suite = new TestSuite(RenameFunctionTests.class); TestSuite suite = new TestSuite(RenameFunctionTests.class);

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; package org.eclipse.cdt.ui.tests.refactoring.rename;
@ -24,9 +24,11 @@ public class RenameMacroTests extends RenameTests {
public RenameMacroTests(String name) { public RenameMacroTests(String name) {
super(name); super(name);
} }
public static Test suite(){ public static Test suite(){
return suite(true); return suite(true);
} }
public static Test suite( boolean cleanup ) { public static Test suite( boolean cleanup ) {
TestSuite suite = new TestSuite(RenameMacroTests.class); TestSuite suite = new TestSuite(RenameMacroTests.class);
if (cleanup) { if (cleanup) {
@ -34,8 +36,7 @@ public class RenameMacroTests extends RenameTests {
} }
return suite; return suite;
} }
public void testMacroRename() throws Exception { public void testMacroRename() throws Exception {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
writer.write("#define HALLO x \n"); //$NON-NLS-1$ writer.write("#define HALLO x \n"); //$NON-NLS-1$

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; package org.eclipse.cdt.ui.tests.refactoring.rename;
import java.io.StringWriter; import java.io.StringWriter;
@ -28,9 +27,11 @@ public class RenameTemplatesTests extends RenameTests {
public RenameTemplatesTests(String name) { public RenameTemplatesTests(String name) {
super(name); super(name);
} }
public static Test suite(){ public static Test suite(){
return suite(true); return suite(true);
} }
public static Test suite( boolean cleanup ) { public static Test suite( boolean cleanup ) {
TestSuite suite = new TestSuite(RenameTemplatesTests.class); TestSuite suite = new TestSuite(RenameTemplatesTests.class);
if (cleanup) { if (cleanup) {
@ -39,7 +40,6 @@ public class RenameTemplatesTests extends RenameTests {
return suite; return suite;
} }
public void testClassTemplate() throws Exception { public void testClassTemplate() throws Exception {
StringWriter writer = new StringWriter(); StringWriter writer = new StringWriter();
writer.write("template <class Type> \n"); //$NON-NLS-1$ writer.write("template <class Type> \n"); //$NON-NLS-1$

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; 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 * @author markus.schorn@windriver.com
*/ */
public class RenameTests extends RefactoringTests { public class RenameTests extends RefactoringTests {
private static final IProgressMonitor NPM = new NullProgressMonitor(); private static final IProgressMonitor NPM = new NullProgressMonitor();
public RenameTests(String name) { public RenameTests(String name) {
@ -58,7 +57,7 @@ public class RenameTests extends RefactoringTests {
return change; 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 //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 //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 //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 @Override
protected IFile importFile(String fileName, String contents) protected IFile importFile(String fileName, String contents) throws Exception {
throws Exception {
IFile result= super.importFile(fileName, contents); IFile result= super.importFile(fileName, contents);
waitForIndexer(); waitForIndexer();
return result; return result;

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; package org.eclipse.cdt.ui.tests.refactoring.rename;
import java.io.StringWriter; import java.io.StringWriter;
@ -38,8 +37,7 @@ public class RenameTypeTests extends RenameTests {
} }
return suite; return suite;
} }
public void testClassNameConflicts() throws Exception { public void testClassNameConflicts() throws Exception {
createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$ createCppFwdDecls("cpp_fwd.hh"); //$NON-NLS-1$
createCppDefs("cpp_def.hh"); //$NON-NLS-1$ createCppDefs("cpp_def.hh"); //$NON-NLS-1$

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; package org.eclipse.cdt.ui.tests.refactoring.rename;
import java.io.StringWriter; import java.io.StringWriter;
@ -28,9 +27,11 @@ public class RenameVariableTests extends RenameTests {
public RenameVariableTests(String name) { public RenameVariableTests(String name) {
super(name); super(name);
} }
public static Test suite(){ public static Test suite(){
return suite(true); return suite(true);
} }
public static Test suite( boolean cleanup ) { public static Test suite( boolean cleanup ) {
TestSuite suite = new TestSuite(RenameVariableTests.class); TestSuite suite = new TestSuite(RenameVariableTests.class);

View file

@ -6,20 +6,24 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.rename; package org.eclipse.cdt.ui.tests.refactoring.rename;
import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.CoreException;
import org.eclipse.ltk.core.refactoring.*; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ltk.core.refactoring.participants.*; 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 { public class TestRenameParticipant extends RenameParticipant {
private static Object sElement= null; private static Object sElement;
private static RenameArguments sArguments= null; private static RenameArguments sArguments;
private static int sConditionCheck= 0; private static int sConditionCheck;
private static int sCreateChange= 0; private static int sCreateChange;
public static int getConditionCheckCount() { public static int getConditionCheckCount() {
return sConditionCheck; return sConditionCheck;
@ -40,7 +44,8 @@ public class TestRenameParticipant extends RenameParticipant {
public static void reset() { public static void reset() {
sElement= null; sElement= null;
sArguments= null; sArguments= null;
sConditionCheck= sCreateChange= 0; sConditionCheck= 0;
sCreateChange= 0;
} }
@Override @Override

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename; package org.eclipse.cdt.internal.ui.refactoring.rename;
@ -63,7 +63,7 @@ public class CRefactoringMatch {
return fFile; return fFile;
} }
public void setASTInformation(int val) { public void setASTInformation(int val) {
switch(fAstInformation) { switch (fAstInformation) {
case AST_REFERENCE: case AST_REFERENCE:
case AST_REFERENCE_OTHER: case AST_REFERENCE_OTHER:
case AST_REFEREENCE_CONFLICTING: case AST_REFEREENCE_CONFLICTING:

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename; 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.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
/** /**
* Processor adding constructor and destructor to the bindings to be renamed. * Processor adding constructor and destructor to the bindings to be renamed.
*/ */

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
******************************************************************************/ ******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring.rename; package org.eclipse.cdt.internal.ui.refactoring.rename;