mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Cosmetics.
This commit is contained in:
parent
8241b40ddb
commit
774de9a0ea
11 changed files with 64 additions and 84 deletions
|
@ -50,7 +50,7 @@ import com.ibm.icu.text.MessageFormat;
|
|||
* 0 | version number
|
||||
* INT_SIZE | pointer to head of linked list of blocks of size MIN_BLOCK_DELTAS*BLOCK_SIZE_DELTA
|
||||
* .. | ...
|
||||
* INT_SIZE * m (1) | pointer to head of linked list of blocks of size (m+MIN_BLOCK_DELTAS) * BLOCK_SIZE_DELTA
|
||||
* INT_SIZE * m (1) | pointer to head of linked list of blocks of size (m + MIN_BLOCK_DELTAS) * BLOCK_SIZE_DELTA
|
||||
* DATA_AREA | undefined (PDOM stores its own house-keeping data in this area)
|
||||
*
|
||||
* (1) where 2 <= m <= CHUNK_SIZE/BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 1
|
||||
|
@ -60,7 +60,7 @@ import com.ibm.icu.text.MessageFormat;
|
|||
* offset content
|
||||
* _____________________________
|
||||
* 0 | size of block (negative indicates in use, positive unused) (2 bytes)
|
||||
* PREV_OFFSET | pointer to prev block (of same size) (only in free blocks)
|
||||
* PREV_OFFSET | pointer to previous block (of same size) (only in free blocks)
|
||||
* NEXT_OFFSET | pointer to next block (of same size) (only in free blocks)
|
||||
*
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ public class Database {
|
|||
// Public for tests only, you shouldn't need these.
|
||||
public static final int INT_SIZE = 4;
|
||||
public static final int CHUNK_SIZE = 1024 * 4;
|
||||
public static final int OFFSET_IN_CHUNK_MASK= CHUNK_SIZE-1;
|
||||
public static final int OFFSET_IN_CHUNK_MASK= CHUNK_SIZE - 1;
|
||||
public static final int BLOCK_HEADER_SIZE= 2;
|
||||
public static final int BLOCK_SIZE_DELTA_BITS = 3;
|
||||
public static final int BLOCK_SIZE_DELTA= 1 << BLOCK_SIZE_DELTA_BITS;
|
||||
|
|
|
@ -93,8 +93,7 @@ class PDOMCTypedef extends PDOMBinding implements ITypedef, ITypeContainer, IInd
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Doug Schaefer (QNX) - Initial API and implementation
|
||||
* IBM Corporation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||
|
||||
|
@ -31,7 +31,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* Database representation for c-variables
|
||||
*/
|
||||
class PDOMCVariable extends PDOMBinding implements IVariable {
|
||||
|
||||
/**
|
||||
* Offset of pointer to type information for this variable
|
||||
* (relative to the beginning of the record).
|
||||
|
|
|
@ -28,7 +28,7 @@ class PDOMCPPFriend extends PDOMNode {
|
|||
public PDOMCPPFriend(PDOMLinkage linkage, long record) {
|
||||
super(linkage, record);
|
||||
}
|
||||
|
||||
|
||||
public PDOMCPPFriend(PDOMLinkage linkage, PDOMName friendSpec) throws CoreException {
|
||||
super(linkage, null);
|
||||
|
||||
|
@ -48,10 +48,11 @@ class PDOMCPPFriend extends PDOMNode {
|
|||
|
||||
public PDOMName getSpecifierName() throws CoreException {
|
||||
long rec = getDB().getRecPtr(record + FRIEND_SPECIFIER);
|
||||
if (rec != 0) return new PDOMName(getLinkage(), rec);
|
||||
if (rec != 0)
|
||||
return new PDOMName(getLinkage(), rec);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public IBinding getFriendSpecifier() {
|
||||
PDOMName friendSpecName;
|
||||
try {
|
||||
|
@ -64,12 +65,12 @@ class PDOMCPPFriend extends PDOMNode {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public void setNextFriend(PDOMCPPFriend nextFriend) throws CoreException {
|
||||
long rec = nextFriend != null ? nextFriend.getRecord() : 0;
|
||||
getDB().putRecPtr(record + NEXT_FRIEND, rec);
|
||||
}
|
||||
|
||||
|
||||
public PDOMCPPFriend getNextFriend() throws CoreException {
|
||||
long rec = getDB().getRecPtr(record + NEXT_FRIEND);
|
||||
return rec != 0 ? new PDOMCPPFriend(getLinkage(), rec) : null;
|
||||
|
|
|
@ -6,21 +6,20 @@
|
|||
* 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.typehierarchy;
|
||||
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
|
||||
public class THContentProvider implements ITreeContentProvider {
|
||||
private static final Object[] NO_CHILDREN= new Object[0];
|
||||
private static final Object[] NO_CHILDREN= {};
|
||||
private THHierarchyModel fModel;
|
||||
|
||||
public THContentProvider() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
final public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
fModel= (THHierarchyModel) newInput;
|
||||
|
|
|
@ -39,10 +39,10 @@ import org.eclipse.cdt.internal.ui.viewsupport.IndexUI;
|
|||
|
||||
class THGraph {
|
||||
private static final ICElement[] NO_MEMBERS = {};
|
||||
private THGraphNode fInputNode= null;
|
||||
private HashSet<THGraphNode> fRootNodes= new HashSet<THGraphNode>();
|
||||
private HashSet<THGraphNode> fLeaveNodes= new HashSet<THGraphNode>();
|
||||
private HashMap<ICElement, THGraphNode> fNodes= new HashMap<ICElement, THGraphNode>();
|
||||
private THGraphNode fInputNode;
|
||||
private HashSet<THGraphNode> fRootNodes= new HashSet<>();
|
||||
private HashSet<THGraphNode> fLeafNodes= new HashSet<>();
|
||||
private HashMap<ICElement, THGraphNode> fNodes= new HashMap<>();
|
||||
private boolean fFileIsIndexed;
|
||||
|
||||
public THGraph() {
|
||||
|
@ -63,7 +63,7 @@ class THGraph {
|
|||
node= new THGraphNode(input);
|
||||
fNodes.put(input, node);
|
||||
fRootNodes.add(node);
|
||||
fLeaveNodes.add(node);
|
||||
fLeafNodes.add(node);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class THGraph {
|
|||
from.startEdge(edge);
|
||||
to.endEdge(edge);
|
||||
fRootNodes.remove(to);
|
||||
fLeaveNodes.remove(from);
|
||||
fLeafNodes.remove(from);
|
||||
return edge;
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,8 @@ class THGraph {
|
|||
return false;
|
||||
}
|
||||
|
||||
HashSet<THGraphNode> checked= new HashSet<THGraphNode>();
|
||||
ArrayList<THGraphNode> stack= new ArrayList<THGraphNode>();
|
||||
HashSet<THGraphNode> checked= new HashSet<>();
|
||||
ArrayList<THGraphNode> stack= new ArrayList<>();
|
||||
stack.add(to);
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
|
@ -119,8 +119,8 @@ class THGraph {
|
|||
return fRootNodes;
|
||||
}
|
||||
|
||||
public Collection<THGraphNode> getLeaveNodes() {
|
||||
return fLeaveNodes;
|
||||
public Collection<THGraphNode> getLeafNodes() {
|
||||
return fLeafNodes;
|
||||
}
|
||||
|
||||
public void defineInputNode(IIndex index, ICElement input) {
|
||||
|
@ -141,8 +141,8 @@ class THGraph {
|
|||
if (fInputNode == null) {
|
||||
return;
|
||||
}
|
||||
HashSet<ICElement> handled= new HashSet<ICElement>();
|
||||
ArrayList<ICElement> stack= new ArrayList<ICElement>();
|
||||
HashSet<ICElement> handled= new HashSet<>();
|
||||
ArrayList<ICElement> stack= new ArrayList<>();
|
||||
stack.add(fInputNode.getElement());
|
||||
handled.add(fInputNode.getElement());
|
||||
while (!stack.isEmpty()) {
|
||||
|
@ -204,8 +204,8 @@ class THGraph {
|
|||
if (fInputNode == null) {
|
||||
return;
|
||||
}
|
||||
HashSet<ICElement> handled= new HashSet<ICElement>();
|
||||
ArrayList<ICElement> stack= new ArrayList<ICElement>();
|
||||
HashSet<ICElement> handled= new HashSet<>();
|
||||
ArrayList<ICElement> stack= new ArrayList<>();
|
||||
ICElement element = fInputNode.getElement();
|
||||
stack.add(element);
|
||||
handled.add(element);
|
||||
|
@ -249,7 +249,7 @@ class THGraph {
|
|||
|
||||
private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws CoreException {
|
||||
if (graphNode.getMembers(false) == null) {
|
||||
ArrayList<ICElement> memberList= new ArrayList<ICElement>();
|
||||
ArrayList<ICElement> memberList= new ArrayList<>();
|
||||
if (binding instanceof ICPPClassType) {
|
||||
ICPPClassType ct= (ICPPClassType) binding;
|
||||
IBinding[] members= ClassTypeHelper.getDeclaredFields(ct, null);
|
||||
|
@ -285,7 +285,7 @@ class THGraph {
|
|||
}
|
||||
|
||||
public boolean isTrivial() {
|
||||
return fNodes.size() < 2;
|
||||
return fNodes.size() <= 1;
|
||||
}
|
||||
|
||||
public boolean isFileIndexed() {
|
||||
|
|
|
@ -11,10 +11,8 @@
|
|||
package org.eclipse.cdt.internal.ui.typehierarchy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -23,7 +21,7 @@ class THGraphNode {
|
|||
private List<THGraphEdge> fOutgoing= Collections.emptyList();
|
||||
private List<THGraphEdge> fIncoming= Collections.emptyList();
|
||||
private ICElement fElement;
|
||||
private ICElement[] fMembers= null;
|
||||
private ICElement[] fMembers;
|
||||
|
||||
THGraphNode(ICElement element) {
|
||||
fElement= element;
|
||||
|
@ -46,7 +44,7 @@ class THGraphNode {
|
|||
case 0:
|
||||
return Collections.singletonList(elem);
|
||||
case 1:
|
||||
list= new ArrayList<THGraphEdge>(list);
|
||||
list= new ArrayList<>(list);
|
||||
list.add(elem);
|
||||
return list;
|
||||
}
|
||||
|
@ -70,7 +68,7 @@ class THGraphNode {
|
|||
if (!addInherited) {
|
||||
return fMembers;
|
||||
}
|
||||
ArrayList<ICElement> list= new ArrayList<ICElement>();
|
||||
ArrayList<ICElement> list= new ArrayList<>();
|
||||
collectMembers(new HashSet<THGraphNode>(), list);
|
||||
return list.toArray(new ICElement[list.size()]);
|
||||
}
|
||||
|
@ -78,11 +76,10 @@ class THGraphNode {
|
|||
private void collectMembers(HashSet<THGraphNode> visited, List<ICElement> list) {
|
||||
if (visited.add(this)) {
|
||||
if (fMembers != null) {
|
||||
list.addAll(Arrays.asList(fMembers));
|
||||
Collections.addAll(list, fMembers);
|
||||
}
|
||||
List<THGraphEdge> bases= getOutgoing();
|
||||
for (Iterator<THGraphEdge> iterator = bases.iterator(); iterator.hasNext();) {
|
||||
THGraphEdge edge = iterator.next();
|
||||
for (THGraphEdge edge : bases) {
|
||||
edge.getEndNode().collectMembers(visited, list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,15 +179,15 @@ class THHierarchyModel {
|
|||
return;
|
||||
}
|
||||
boolean fwd= fHierarchyKind == SUPER_TYPE_HIERARCHY;
|
||||
ArrayList<THNode> stack= new ArrayList<THNode>();
|
||||
ArrayList<THNode> roots= new ArrayList<THNode>();
|
||||
ArrayList<THNode> leafs= new ArrayList<THNode>();
|
||||
ArrayList<THNode> stack= new ArrayList<>();
|
||||
ArrayList<THNode> roots= new ArrayList<>();
|
||||
ArrayList<THNode> leafs= new ArrayList<>();
|
||||
|
||||
THGraphNode inputNode= fGraph.getInputNode();
|
||||
Collection<THGraphNode> groots;
|
||||
|
||||
if (fHierarchyKind == TYPE_HIERARCHY) {
|
||||
groots= fGraph.getLeaveNodes();
|
||||
groots= fGraph.getLeafNodes();
|
||||
} else {
|
||||
THGraphNode node= fGraph.getInputNode();
|
||||
if (node != null) {
|
||||
|
@ -204,7 +204,7 @@ class THHierarchyModel {
|
|||
}
|
||||
|
||||
while (!stack.isEmpty()) {
|
||||
THNode node= stack.remove(stack.size()-1);
|
||||
THNode node= stack.remove(stack.size() - 1);
|
||||
THGraphNode gnode= fGraph.getNode(node.getElement());
|
||||
List<THGraphEdge> edges= fwd ? gnode.getOutgoing() : gnode.getIncoming();
|
||||
if (edges.isEmpty()) {
|
||||
|
@ -219,7 +219,7 @@ class THHierarchyModel {
|
|||
}
|
||||
}
|
||||
fRootNodes= roots.toArray(new THNode[roots.size()]);
|
||||
removeFilteredLeafs(fRootNodes);
|
||||
removeFilteredLeaves(fRootNodes);
|
||||
fSelectedTypeNode= findSelection(fRootNodes);
|
||||
if (fSelectedTypeNode != null) {
|
||||
fTypeToSelect= fSelectedTypeNode.getElement();
|
||||
|
@ -231,15 +231,15 @@ class THHierarchyModel {
|
|||
removeNonImplementorLeaves(fRootNodes);
|
||||
}
|
||||
|
||||
private void removeFilteredLeafs(THNode[] rootNodes) {
|
||||
private void removeFilteredLeaves(THNode[] rootNodes) {
|
||||
for (THNode node : rootNodes) {
|
||||
node.removeFilteredLeafs();
|
||||
node.removeFilteredLeaves();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeNonImplementorLeaves(THNode[] rootNodes) {
|
||||
for (THNode node : rootNodes) {
|
||||
node.removeNonImplementorLeafs();
|
||||
node.removeNonImplementorLeaves();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -394,8 +394,7 @@ class THHierarchyModel {
|
|||
}
|
||||
|
||||
private boolean isImplementor(ICElement element) {
|
||||
if (element == null
|
||||
|| fSelectedMember == null || fMemberSignatureToSelect == null) {
|
||||
if (element == null || fSelectedMember == null || fMemberSignatureToSelect == null) {
|
||||
return false;
|
||||
}
|
||||
THGraphNode gnode= fGraph.getNode(element);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* Markus Schorn - initial API and implementation
|
||||
* Patrick Hofer [bug 325488]
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.typehierarchy;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
@ -47,11 +46,10 @@ import org.eclipse.cdt.internal.ui.text.AbstractInformationControl;
|
|||
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
||||
|
||||
public class THInformationControl extends AbstractInformationControl implements ITHModelPresenter {
|
||||
|
||||
private THHierarchyModel fModel;
|
||||
private THLabelProvider fHierarchyLabelProvider;
|
||||
private TreeViewer fHierarchyTreeViewer;
|
||||
private boolean fDisposed= false;
|
||||
private boolean fDisposed;
|
||||
private KeyAdapter fKeyAdapter;
|
||||
|
||||
public THInformationControl(Shell parent, int shellStyle, int treeStyle) {
|
||||
|
@ -265,10 +263,11 @@ public class THInformationControl extends AbstractInformationControl implements
|
|||
protected void selectFirstMatch() {
|
||||
Tree tree= fHierarchyTreeViewer.getTree();
|
||||
Object element= findElement(tree.getItems());
|
||||
if (element != null)
|
||||
if (element != null) {
|
||||
fHierarchyTreeViewer.setSelection(new StructuredSelection(element), true);
|
||||
else
|
||||
} else {
|
||||
fHierarchyTreeViewer.setSelection(StructuredSelection.EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
protected void toggleHierarchy() {
|
||||
|
@ -301,7 +300,7 @@ public class THInformationControl extends AbstractInformationControl implements
|
|||
Object item= item2.getData();
|
||||
THNode element= null;
|
||||
if (item instanceof THNode) {
|
||||
element= (THNode)item;
|
||||
element= (THNode) item;
|
||||
if (fStringMatcher == null)
|
||||
return element;
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ import org.eclipse.core.runtime.IAdaptable;
|
|||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.util.CoreUtility;
|
||||
|
||||
public class THNode implements IAdaptable {
|
||||
private THNode fParent;
|
||||
private ICElement fElement;
|
||||
|
@ -32,30 +30,19 @@ public class THNode implements IAdaptable {
|
|||
private boolean fIsImplementor;
|
||||
|
||||
/**
|
||||
* Creates a new node for the include browser
|
||||
* Creates a new node for the type hierarchy browser.
|
||||
*/
|
||||
public THNode(THNode parent, ICElement decl) {
|
||||
fParent= parent;
|
||||
fElement= decl;
|
||||
fHashCode= computeHashCode();
|
||||
fHashCode= Objects.hash(fParent, fElement);
|
||||
}
|
||||
|
||||
private int computeHashCode() {
|
||||
int hashCode= 0;
|
||||
if (fParent != null) {
|
||||
hashCode= fParent.hashCode() * 31;
|
||||
}
|
||||
if (fElement != null) {
|
||||
hashCode+= fElement.hashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fHashCode;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof THNode)) {
|
||||
|
@ -69,9 +56,9 @@ public class THNode implements IAdaptable {
|
|||
|
||||
return Objects.equals(fElement, rhs.fElement);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the parent node or <code>null</code> for the root node.
|
||||
* Returns the parent node or {@code null} for the root node.
|
||||
*/
|
||||
public THNode getParent() {
|
||||
return fParent;
|
||||
|
@ -100,7 +87,7 @@ public class THNode implements IAdaptable {
|
|||
|
||||
public void addChild(THNode childNode) {
|
||||
if (fChildren.isEmpty()) {
|
||||
fChildren= new ArrayList<THNode>();
|
||||
fChildren= new ArrayList<>();
|
||||
}
|
||||
fChildren.add(childNode);
|
||||
}
|
||||
|
@ -121,20 +108,20 @@ public class THNode implements IAdaptable {
|
|||
return fIsImplementor;
|
||||
}
|
||||
|
||||
public void removeFilteredLeafs() {
|
||||
public void removeFilteredLeaves() {
|
||||
for (Iterator<THNode> iterator = fChildren.iterator(); iterator.hasNext();) {
|
||||
THNode child = iterator.next();
|
||||
child.removeFilteredLeafs();
|
||||
child.removeFilteredLeaves();
|
||||
if (child.isFiltered() && !child.hasChildren()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeNonImplementorLeafs() {
|
||||
public void removeNonImplementorLeaves() {
|
||||
for (Iterator<THNode> iterator = fChildren.iterator(); iterator.hasNext();) {
|
||||
THNode child = iterator.next();
|
||||
child.removeNonImplementorLeafs();
|
||||
child.removeNonImplementorLeaves();
|
||||
if (!child.isImplementor() && !child.hasChildren()) {
|
||||
iterator.remove();
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class LRCPPTests extends AST2CPPTests {
|
|||
|
||||
//DeclType
|
||||
@Override
|
||||
public void testDeclType_294730() throws Exception {}
|
||||
public void testDecltype_294730() throws Exception {}
|
||||
|
||||
//Defaulted and deleted functions
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue