From 88f9c72b6a9b04ff5c309fe2418b28e9f50b4a53 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sat, 28 May 2011 23:09:39 +0000 Subject: [PATCH] Cosmetics. --- .../ui/refactoring/NodeContainer.java | 40 ++++++++----------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java index 9d2ba645f25..169f1400639 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/NodeContainer.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -106,7 +106,6 @@ public class NodeContainer { public ArrayList getReferencesAfterSelection() { if (referencesAfterCached == null || lastCachedReferencesHash != references.hashCode()) { - lastCachedReferencesHash = references.hashCode(); referencesAfterCached = new ArrayList(); for (IASTName ref : references) { @@ -266,7 +265,6 @@ public class NodeContainer { public void setWriteAccess(boolean isWriteAceess) { this.isWriteAccess = isWriteAceess; } - } public NodeContainer() { @@ -275,10 +273,14 @@ public class NodeContainer { names = new ArrayList(); } - public int size() { + public final int size() { return vec.size(); } + public final boolean isEmpty() { + return vec.isEmpty(); + } + public void add(IASTNode node) { vec.add(node); } @@ -300,7 +302,6 @@ public class NodeContainer { try { if (!cppBind.isGloballyQualified()) { NameInformation nameInformation = new NameInformation(name); - IASTName[] refs = name.getTranslationUnit().getReferences(bind); for (IASTName ref : refs) { nameInformation.addReference(ref); @@ -310,13 +311,11 @@ public class NodeContainer { } catch (DOMException e) { ILog logger = CUIPlugin.getDefault().getLog(); IStatus status = new Status(IStatus.WARNING, - CUIPlugin.PLUGIN_ID, IStatus.OK, e - .getMessage(), e); + CUIPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e); logger.log(status); } } else if (bind instanceof IVariable) { - NameInformation nameInformation = new NameInformation( - name); + NameInformation nameInformation = new NameInformation(name); IASTName[] refs = name.getTranslationUnit().getReferences(bind); for (IASTName ref : refs) { @@ -392,14 +391,12 @@ public class NodeContainer { for (NameInformation nameInf : names) { if (!declarations.contains(nameInf.getDeclaration())) { - declarations.add(nameInf.getDeclaration()); usedAfter.add(nameInf); } else { for (NameInformation nameInformation : usedAfter) { if (nameInf.isWriteAccess() - && nameInf.getDeclaration() == nameInformation - .getDeclaration()) { + && nameInf.getDeclaration() == nameInformation.getDeclaration()) { nameInformation.setWriteAccess(true); } } @@ -421,11 +418,9 @@ public class NodeContainer { for (NameInformation nameInf : names) { if (nameInf.isDeclarationInScope() && !declarations.contains(nameInf.getDeclaration()) && nameInf.isUsedAfterReferences()) { - declarations.add(nameInf.getDeclaration()); usedAfter.add(nameInf); - // is return value candidate, set returnvalue to true and - // reference to false + // is return value candidate, set return value to true and reference to false nameInf.setReturnValue(true); nameInf.setReference(false); } @@ -491,7 +486,7 @@ public class NodeContainer { for (IASTNode node : vec) { int fileOffset = 0; int length = 0; - + IASTNodeLocation[] nodeLocations = node.getNodeLocations(); for (IASTNodeLocation location : nodeLocations) { int nodeOffset, nodeLength; @@ -508,13 +503,13 @@ public class NodeContainer { length = nodeLength; } } - int endNode = fileOffset + length; - if (endNode > end) { - end = endNode; + int endNode = fileOffset + length; + if (endNode > end) { + end = endNode; + } } - } - return end; + return end; } @Override @@ -522,8 +517,7 @@ public class NodeContainer { return vec.toString(); } - public ArrayList getNames() { + public List getNames() { return names; } - }