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;
} }
} }
@ -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;
} }
@ -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,8 +431,9 @@ 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();
@ -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
@ -539,14 +525,12 @@ 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();

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

@ -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();
@ -1026,7 +1026,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return addBinding(type, null); return addBinding(type, null);
} }
@Override @Override
public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException { public IType unmarshalType(ITypeMarshalBuffer buffer) throws CoreException {
int firstByte= buffer.getByte(); int firstByte= buffer.getByte();

View file

@ -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

@ -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

@ -24,9 +24,11 @@ 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

@ -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) {
@ -35,7 +37,6 @@ 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

@ -8,7 +8,6 @@
* 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

@ -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) {
@ -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

@ -8,7 +8,6 @@
* 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;
@ -39,7 +38,6 @@ 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

@ -8,7 +8,6 @@
* 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

@ -8,18 +8,22 @@
* 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

@ -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.
*/ */