1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-05-28 23:09:39 +00:00
parent 635ec2ef98
commit 88f9c72b6a

View file

@ -7,7 +7,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Institute for Software - initial API and implementation * Institute for Software - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.refactoring; package org.eclipse.cdt.internal.ui.refactoring;
@ -106,7 +106,6 @@ public class NodeContainer {
public ArrayList<IASTName> getReferencesAfterSelection() { public ArrayList<IASTName> getReferencesAfterSelection() {
if (referencesAfterCached == null if (referencesAfterCached == null
|| lastCachedReferencesHash != references.hashCode()) { || lastCachedReferencesHash != references.hashCode()) {
lastCachedReferencesHash = references.hashCode(); lastCachedReferencesHash = references.hashCode();
referencesAfterCached = new ArrayList<IASTName>(); referencesAfterCached = new ArrayList<IASTName>();
for (IASTName ref : references) { for (IASTName ref : references) {
@ -266,7 +265,6 @@ public class NodeContainer {
public void setWriteAccess(boolean isWriteAceess) { public void setWriteAccess(boolean isWriteAceess) {
this.isWriteAccess = isWriteAceess; this.isWriteAccess = isWriteAceess;
} }
} }
public NodeContainer() { public NodeContainer() {
@ -275,10 +273,14 @@ public class NodeContainer {
names = new ArrayList<NameInformation>(); names = new ArrayList<NameInformation>();
} }
public int size() { public final int size() {
return vec.size(); return vec.size();
} }
public final boolean isEmpty() {
return vec.isEmpty();
}
public void add(IASTNode node) { public void add(IASTNode node) {
vec.add(node); vec.add(node);
} }
@ -300,7 +302,6 @@ public class NodeContainer {
try { try {
if (!cppBind.isGloballyQualified()) { if (!cppBind.isGloballyQualified()) {
NameInformation nameInformation = new NameInformation(name); NameInformation nameInformation = new NameInformation(name);
IASTName[] refs = name.getTranslationUnit().getReferences(bind); IASTName[] refs = name.getTranslationUnit().getReferences(bind);
for (IASTName ref : refs) { for (IASTName ref : refs) {
nameInformation.addReference(ref); nameInformation.addReference(ref);
@ -310,13 +311,11 @@ public class NodeContainer {
} catch (DOMException e) { } catch (DOMException e) {
ILog logger = CUIPlugin.getDefault().getLog(); ILog logger = CUIPlugin.getDefault().getLog();
IStatus status = new Status(IStatus.WARNING, IStatus status = new Status(IStatus.WARNING,
CUIPlugin.PLUGIN_ID, IStatus.OK, e CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
.getMessage(), e);
logger.log(status); logger.log(status);
} }
} else if (bind instanceof IVariable) { } else if (bind instanceof IVariable) {
NameInformation nameInformation = new NameInformation( NameInformation nameInformation = new NameInformation(name);
name);
IASTName[] refs = name.getTranslationUnit().getReferences(bind); IASTName[] refs = name.getTranslationUnit().getReferences(bind);
for (IASTName ref : refs) { for (IASTName ref : refs) {
@ -392,14 +391,12 @@ public class NodeContainer {
for (NameInformation nameInf : names) { for (NameInformation nameInf : names) {
if (!declarations.contains(nameInf.getDeclaration())) { if (!declarations.contains(nameInf.getDeclaration())) {
declarations.add(nameInf.getDeclaration()); declarations.add(nameInf.getDeclaration());
usedAfter.add(nameInf); usedAfter.add(nameInf);
} else { } else {
for (NameInformation nameInformation : usedAfter) { for (NameInformation nameInformation : usedAfter) {
if (nameInf.isWriteAccess() if (nameInf.isWriteAccess()
&& nameInf.getDeclaration() == nameInformation && nameInf.getDeclaration() == nameInformation.getDeclaration()) {
.getDeclaration()) {
nameInformation.setWriteAccess(true); nameInformation.setWriteAccess(true);
} }
} }
@ -421,11 +418,9 @@ public class NodeContainer {
for (NameInformation nameInf : names) { for (NameInformation nameInf : names) {
if (nameInf.isDeclarationInScope() if (nameInf.isDeclarationInScope()
&& !declarations.contains(nameInf.getDeclaration()) && nameInf.isUsedAfterReferences()) { && !declarations.contains(nameInf.getDeclaration()) && nameInf.isUsedAfterReferences()) {
declarations.add(nameInf.getDeclaration()); declarations.add(nameInf.getDeclaration());
usedAfter.add(nameInf); usedAfter.add(nameInf);
// is return value candidate, set returnvalue to true and // is return value candidate, set return value to true and reference to false
// reference to false
nameInf.setReturnValue(true); nameInf.setReturnValue(true);
nameInf.setReference(false); nameInf.setReference(false);
} }
@ -491,7 +486,7 @@ public class NodeContainer {
for (IASTNode node : vec) { for (IASTNode node : vec) {
int fileOffset = 0; int fileOffset = 0;
int length = 0; int length = 0;
IASTNodeLocation[] nodeLocations = node.getNodeLocations(); IASTNodeLocation[] nodeLocations = node.getNodeLocations();
for (IASTNodeLocation location : nodeLocations) { for (IASTNodeLocation location : nodeLocations) {
int nodeOffset, nodeLength; int nodeOffset, nodeLength;
@ -508,13 +503,13 @@ public class NodeContainer {
length = nodeLength; length = nodeLength;
} }
} }
int endNode = fileOffset + length; int endNode = fileOffset + length;
if (endNode > end) { if (endNode > end) {
end = endNode; end = endNode;
}
} }
}
return end; return end;
} }
@Override @Override
@ -522,8 +517,7 @@ public class NodeContainer {
return vec.toString(); return vec.toString();
} }
public ArrayList<NameInformation> getNames() { public List<NameInformation> getNames() {
return names; return names;
} }
} }