From f14b41343a876fe65a478acff0de966c849dab6f Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 6 May 2015 17:31:46 -0700 Subject: [PATCH] Cosmetics. --- .../cdt/core/dom/ast/tag/IBindingTagger.java | 4 +-- .../eclipse/cdt/core/dom/ast/tag/ITag.java | 4 +-- .../cdt/core/dom/ast/tag/ITagReader.java | 4 +-- .../cdt/core/dom/ast/tag/ITagService.java | 7 +++-- .../cdt/core/dom/ast/tag/ITagWriter.java | 5 ++-- .../cdt/core/dom/ast/tag/IWritableTag.java | 8 +++--- .../internal/core/pdom/tag/BTreeIterable.java | 10 +++---- .../cdt/internal/core/pdom/tag/PDOMTag.java | 17 ++++++------ .../internal/core/pdom/tag/PDOMTagIndex.java | 26 +++++++++---------- .../internal/core/pdom/tag/PDOMTaggable.java | 5 ++-- 10 files changed, 44 insertions(+), 46 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IBindingTagger.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IBindingTagger.java index 1829adb1465..28cb300d8d5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IBindingTagger.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IBindingTagger.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,7 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.tag; import org.eclipse.cdt.core.dom.ast.IASTName; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITag.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITag.java index a51c712281a..fa2aec55212 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITag.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITag.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,7 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.tag; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagReader.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagReader.java index 96d272b3966..7829acdee81 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagReader.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagReader.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,7 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.tag; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagService.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagService.java index 31a4ad384fc..4acdfdee293 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagService.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagService.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,7 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.tag; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -25,8 +25,7 @@ public interface ITagService { * Finds or creates a tag reader for the specified binding or null if a reader cannot be * associated with this binding. * - * @param binding - * could be null + * @param binding could be null */ public ITagReader findTagReader(IBinding binding); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagWriter.java index 50c39180436..c459fc9d4e1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/ITagWriter.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,8 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ - + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.tag; /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IWritableTag.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IWritableTag.java index cf790cd2190..836a11184b8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IWritableTag.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/tag/IWritableTag.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,7 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ + *******************************************************************************/ package org.eclipse.cdt.core.dom.ast.tag; /** @@ -21,7 +21,9 @@ package org.eclipse.cdt.core.dom.ast.tag; * @since 5.5 */ public interface IWritableTag extends ITag { - /** Writes the given byte to the given offset in the tag. Returns {@code true} if successful. */ + /** + * Writes the given byte to the given offset in the tag. Returns {@code true} if successful. + */ public boolean putByte(int offset, byte data); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/BTreeIterable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/BTreeIterable.java index c5774014f73..d9ea02ac17f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/BTreeIterable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/BTreeIterable.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,12 +7,12 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ + *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.tag; +import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import org.eclipse.cdt.core.CCorePlugin; @@ -42,13 +42,13 @@ public class BTreeIterable implements Iterable { btree.accept(v); } catch (CoreException e) { CCorePlugin.log(e); - return Collections. emptyList().iterator(); + return Collections.emptyList().iterator(); } return new BTreeIterator(v.records); } private class Visitor implements IBTreeVisitor { - public final List records = new LinkedList(); + public final List records = new ArrayList<>(); @Override public int compare(long record) throws CoreException { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTag.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTag.java index c332fcc5b83..e6b2277523b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTag.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTag.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,8 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ - + *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.tag; import org.eclipse.cdt.core.CCorePlugin; @@ -109,27 +108,28 @@ public class PDOMTag implements IWritableTag { @Override public String getTaggerId() { - if (taggerId == null) + if (taggerId == null) { try { long taggerIdRecord = Fields.TaggerId.getRecPtr(db, record, 0); - taggerId = taggerIdRecord == 0L ? new String() : db.getString(taggerIdRecord) - .getString(); + taggerId = taggerIdRecord == 0L ? "" : db.getString(taggerIdRecord).getString(); //$NON-NLS-1$ } catch (CoreException e) { CCorePlugin.log(e); } + } return taggerId; } @Override public int getDataLen() { - if (dataLen < 0) + if (dataLen < 0) { try { dataLen = Fields.DataLen.getInt(db, record, 0); } catch (CoreException e) { CCorePlugin.log(e); return 0; } + } return dataLen; } @@ -165,12 +165,13 @@ public class PDOMTag implements IWritableTag { } public void delete() { - if (db != null && record != 0) + if (db != null && record != 0) { try { db.free(record); } catch (CoreException e) { CCorePlugin.log(e); } + } } public static class BTreeComparator implements IBTreeComparator { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTagIndex.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTagIndex.java index 614ba8f34d4..309761a8bcb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTagIndex.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTagIndex.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,8 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ - + *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.tag; import java.util.Collections; @@ -28,10 +27,6 @@ import org.eclipse.core.runtime.CoreException; * Not thread-safe. */ public class PDOMTagIndex { - private final Database db; - private final long ptr; - private long rootRecord; - private static enum Fields { TaggerIds, Tags, _last; @@ -39,6 +34,10 @@ public class PDOMTagIndex { public static int sizeof = _last.ordinal() * Database.PTR_SIZE; } + private final Database db; + private final long ptr; + private long rootRecord; + private PDOMStringSet taggerIds; private BTree tags; @@ -80,8 +79,9 @@ public class PDOMTagIndex { assert !taggerId.isEmpty(); if (db == null || taggerId == null || taggerId.isEmpty() - || (taggerIds == null && !createIfNeeded)) + || (taggerIds == null && !createIfNeeded)) { return 0L; + } try { long record = getTaggerIds().find(taggerId); @@ -181,8 +181,8 @@ public class PDOMTagIndex { for (ITag tag : tags) { ITag dupTag = newTags.put(tag.getTaggerId(), tag); if (dupTag != null) - CCorePlugin - .log("Duplicate incoming tag for record " + binding_record + " from taggerId " + tag.getTaggerId()); //$NON-NLS-1$ //$NON-NLS-2$ + CCorePlugin.log("Duplicate incoming tag for record " + binding_record //$NON-NLS-1$ + + " from taggerId " + tag.getTaggerId()); //$NON-NLS-1$ } BTree btree = null; @@ -193,8 +193,7 @@ public class PDOMTagIndex { return false; } - PDOMTagSynchronizer sync = new PDOMTagSynchronizer(db, Long.valueOf(binding_record), - newTags); + PDOMTagSynchronizer sync = new PDOMTagSynchronizer(db, Long.valueOf(binding_record), newTags); // visit the full tree, then return true on success and false on failure try { @@ -210,8 +209,7 @@ public class PDOMTagIndex { // insert any new tags that are left in the incoming list for (ITag newTag : newTags.values()) { - IWritableTag pdomTag = createTag(binding_record, newTag.getTaggerId(), - newTag.getDataLen()); + IWritableTag pdomTag = createTag(binding_record, newTag.getTaggerId(), newTag.getDataLen()); pdomTag.putBytes(0, newTag.getBytes(0, -1), -1); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTaggable.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTaggable.java index 5714ee6655b..52218206848 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTaggable.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/tag/PDOMTaggable.java @@ -1,4 +1,4 @@ -/* +/******************************************************************************* * Copyright (c) 2013 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -7,8 +7,7 @@ * * Contributors: * Andrew Eidsness - Initial implementation - */ - + *******************************************************************************/ package org.eclipse.cdt.internal.core.pdom.tag; import org.eclipse.cdt.core.dom.ast.tag.ITag;