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 2015-05-06 17:31:46 -07:00
parent 0f25dd18d3
commit f14b41343a
10 changed files with 44 additions and 46 deletions

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTName;

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
import org.eclipse.cdt.core.dom.ast.IBinding; 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 * Finds or creates a tag reader for the specified binding or null if a reader cannot be
* associated with this binding. * associated with this binding.
* *
* @param binding * @param binding could be null
* could be null
*/ */
public ITagReader findTagReader(IBinding binding); public ITagReader findTagReader(IBinding binding);
} }

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,8 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast.tag; package org.eclipse.cdt.core.dom.ast.tag;
/** /**
@ -21,7 +21,9 @@ package org.eclipse.cdt.core.dom.ast.tag;
* @since 5.5 * @since 5.5
*/ */
public interface IWritableTag extends ITag { 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); public boolean putByte(int offset, byte data);
/** /**

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,12 +7,12 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -42,13 +42,13 @@ public class BTreeIterable<T> implements Iterable<T> {
btree.accept(v); btree.accept(v);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
return Collections.<T> emptyList().iterator(); return Collections.<T>emptyList().iterator();
} }
return new BTreeIterator(v.records); return new BTreeIterator(v.records);
} }
private class Visitor implements IBTreeVisitor { private class Visitor implements IBTreeVisitor {
public final List<Long> records = new LinkedList<Long>(); public final List<Long> records = new ArrayList<>();
@Override @Override
public int compare(long record) throws CoreException { public int compare(long record) throws CoreException {

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,8 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -109,27 +108,28 @@ public class PDOMTag implements IWritableTag {
@Override @Override
public String getTaggerId() { public String getTaggerId() {
if (taggerId == null) if (taggerId == null) {
try { try {
long taggerIdRecord = Fields.TaggerId.getRecPtr(db, record, 0); long taggerIdRecord = Fields.TaggerId.getRecPtr(db, record, 0);
taggerId = taggerIdRecord == 0L ? new String() : db.getString(taggerIdRecord) taggerId = taggerIdRecord == 0L ? "" : db.getString(taggerIdRecord).getString(); //$NON-NLS-1$
.getString();
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
}
return taggerId; return taggerId;
} }
@Override @Override
public int getDataLen() { public int getDataLen() {
if (dataLen < 0) if (dataLen < 0) {
try { try {
dataLen = Fields.DataLen.getInt(db, record, 0); dataLen = Fields.DataLen.getInt(db, record, 0);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
return 0; return 0;
} }
}
return dataLen; return dataLen;
} }
@ -165,12 +165,13 @@ public class PDOMTag implements IWritableTag {
} }
public void delete() { public void delete() {
if (db != null && record != 0) if (db != null && record != 0) {
try { try {
db.free(record); db.free(record);
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
}
} }
public static class BTreeComparator implements IBTreeComparator { public static class BTreeComparator implements IBTreeComparator {

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,8 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
import java.util.Collections; import java.util.Collections;
@ -28,10 +27,6 @@ import org.eclipse.core.runtime.CoreException;
* Not thread-safe. * Not thread-safe.
*/ */
public class PDOMTagIndex { public class PDOMTagIndex {
private final Database db;
private final long ptr;
private long rootRecord;
private static enum Fields { private static enum Fields {
TaggerIds, Tags, _last; TaggerIds, Tags, _last;
@ -39,6 +34,10 @@ public class PDOMTagIndex {
public static int sizeof = _last.ordinal() * Database.PTR_SIZE; public static int sizeof = _last.ordinal() * Database.PTR_SIZE;
} }
private final Database db;
private final long ptr;
private long rootRecord;
private PDOMStringSet taggerIds; private PDOMStringSet taggerIds;
private BTree tags; private BTree tags;
@ -80,8 +79,9 @@ public class PDOMTagIndex {
assert !taggerId.isEmpty(); assert !taggerId.isEmpty();
if (db == null || taggerId == null || taggerId.isEmpty() if (db == null || taggerId == null || taggerId.isEmpty()
|| (taggerIds == null && !createIfNeeded)) || (taggerIds == null && !createIfNeeded)) {
return 0L; return 0L;
}
try { try {
long record = getTaggerIds().find(taggerId); long record = getTaggerIds().find(taggerId);
@ -181,8 +181,8 @@ public class PDOMTagIndex {
for (ITag tag : tags) { for (ITag tag : tags) {
ITag dupTag = newTags.put(tag.getTaggerId(), tag); ITag dupTag = newTags.put(tag.getTaggerId(), tag);
if (dupTag != null) if (dupTag != null)
CCorePlugin CCorePlugin.log("Duplicate incoming tag for record " + binding_record //$NON-NLS-1$
.log("Duplicate incoming tag for record " + binding_record + " from taggerId " + tag.getTaggerId()); //$NON-NLS-1$ //$NON-NLS-2$ + " from taggerId " + tag.getTaggerId()); //$NON-NLS-1$
} }
BTree btree = null; BTree btree = null;
@ -193,8 +193,7 @@ public class PDOMTagIndex {
return false; return false;
} }
PDOMTagSynchronizer sync = new PDOMTagSynchronizer(db, Long.valueOf(binding_record), PDOMTagSynchronizer sync = new PDOMTagSynchronizer(db, Long.valueOf(binding_record), newTags);
newTags);
// visit the full tree, then return true on success and false on failure // visit the full tree, then return true on success and false on failure
try { try {
@ -210,8 +209,7 @@ public class PDOMTagIndex {
// insert any new tags that are left in the incoming list // insert any new tags that are left in the incoming list
for (ITag newTag : newTags.values()) { for (ITag newTag : newTags.values()) {
IWritableTag pdomTag = createTag(binding_record, newTag.getTaggerId(), IWritableTag pdomTag = createTag(binding_record, newTag.getTaggerId(), newTag.getDataLen());
newTag.getDataLen());
pdomTag.putBytes(0, newTag.getBytes(0, -1), -1); pdomTag.putBytes(0, newTag.getBytes(0, -1), -1);
} }

View file

@ -1,4 +1,4 @@
/* /*******************************************************************************
* Copyright (c) 2013 QNX Software Systems and others. * Copyright (c) 2013 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
@ -7,8 +7,7 @@
* *
* Contributors: * Contributors:
* Andrew Eidsness - Initial implementation * Andrew Eidsness - Initial implementation
*/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.tag; package org.eclipse.cdt.internal.core.pdom.tag;
import org.eclipse.cdt.core.dom.ast.tag.ITag; import org.eclipse.cdt.core.dom.ast.tag.ITag;