From 0594c61c463e8721bc1df21dad90f748d6957076 Mon Sep 17 00:00:00 2001 From: Alexandre Montplaisir Date: Fri, 17 May 2013 11:48:23 -0400 Subject: [PATCH] ctf: Fix some Sonar warnings Change-Id: I6414bc064c4ab55ec574f582d7901c20b906b404 Signed-off-by: Alexandre Montplaisir Reviewed-on: https://git.eclipse.org/r/13239 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann Tested-by: Bernd Hufmann --- .../ctf/core/tests/trace/CTFTraceTest.java | 2 +- .../ctf/core/tests/trace/IOstructgenTest.java | 7 +- .../ctf/core/tests/trace/StreamTest.java | 4 +- .../ctf/core/tests/trace/UtilsTest.java | 9 -- .../tests/types/StructDeclarationTest.java | 4 +- .../tests/types/VariantDefinitionTest.java | 3 +- .../ctf/core/event/CTFCallsite.java | 69 +++++++------- .../linuxtools/ctf/core/event/CTFClock.java | 10 ++- .../ctf/core/event/io/BitBuffer.java | 9 +- .../core/event/types/ArrayDeclaration.java | 3 +- .../ctf/core/event/types/ArrayDefinition.java | 6 +- .../ctf/core/event/types/Definition.java | 50 ++++++++--- .../ctf/core/event/types/EnumDeclaration.java | 12 +-- .../ctf/core/event/types/EnumDefinition.java | 8 +- .../ctf/core/event/types/IDeclaration.java | 3 +- .../core/event/types/IntegerDeclaration.java | 14 +-- .../core/event/types/SequenceDefinition.java | 8 +- .../core/event/types/StructDeclaration.java | 6 +- .../core/event/types/StructDefinition.java | 5 -- .../core/event/types/VariantDeclaration.java | 10 ++- .../core/event/types/VariantDefinition.java | 20 ++--- .../linuxtools/ctf/core/trace/CTFTrace.java | 38 ++++---- .../ctf/core/trace/CTFTraceReader.java | 43 ++++----- .../linuxtools/ctf/core/trace/Metadata.java | 21 ++--- .../linuxtools/ctf/core/trace/Stream.java | 5 +- .../ctf/core/trace/StreamInput.java | 45 +++++----- .../core/trace/StreamInputPacketReader.java | 16 ++-- .../linuxtools/ctf/core/trace/Utils.java | 14 +-- .../ctf/core/event/EventDeclaration.java | 2 +- .../ctf/core/event/metadata/CTFStrings.java | 89 ++++++++++--------- .../core/event/metadata/DeclarationScope.java | 35 ++++---- .../ctf/core/event/metadata/IOStructGen.java | 87 ++++++++---------- .../ctf/core/event/metadata/Messages.java | 6 ++ .../core/event/metadata/messages.properties | 11 ++- .../tmf/core/ctfadaptor/CtfIterator.java | 2 +- 35 files changed, 340 insertions(+), 336 deletions(-) diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java index fcf44a48db..6d94600004 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java @@ -96,7 +96,7 @@ public class CTFTraceTest { */ @Test public void testUUIDIsSet() { - boolean result = fixture.UUIDIsSet(); + boolean result = fixture.uuidIsSet(); assertTrue(result); } diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/IOstructgenTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/IOstructgenTest.java index 25dc04d0af..c138ce680e 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/IOstructgenTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/IOstructgenTest.java @@ -12,7 +12,8 @@ package org.eclipse.linuxtools.ctf.core.tests.trace; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.File; import java.io.FileOutputStream; @@ -20,7 +21,7 @@ import java.io.FileWriter; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; -import java.util.HashMap; +import java.util.Map; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; @@ -511,7 +512,7 @@ public class IOstructgenTest { trace = new CTFTrace(tempTraceDir); assertNotNull(trace); - HashMap events = trace.getEvents(0L); + Map events = trace.getEvents(0L); final EventDeclaration eventDeclaration = (EventDeclaration) events.get(2L); assertEquals("http://example.com/path_to_model?q=ust_tests_demo:done", eventDeclaration.getCustomAttribute("model.emf.uri")); diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java index 568262d23b..89265db208 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/StreamTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeTrue; import java.nio.channels.FileChannel; -import java.util.HashMap; +import java.util.Map; import java.util.Set; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; @@ -129,7 +129,7 @@ public class StreamTest { */ @Test public void testGetEvents() { - HashMap result = fixture.getEvents(); + Map result = fixture.getEvents(); assertNotNull(result); } diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/UtilsTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/UtilsTest.java index 784478786b..c2cbecc484 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/UtilsTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/UtilsTest.java @@ -28,15 +28,6 @@ import org.junit.Test; */ public class UtilsTest { - /** - * Run the Utils() constructor test. - */ - @Test - public void testUtils() { - Utils result = new Utils(); - assertNotNull(result); - } - /** * Run the UUID makeUUID(byte[]) method test. */ diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java index c6627b4543..e170e4423d 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/StructDeclarationTest.java @@ -15,8 +15,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.linuxtools.ctf.core.event.types.IDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration; @@ -82,7 +82,7 @@ public class StructDeclarationTest { */ @Test public void testGetFields() { - HashMap result = fixture.getFields(); + Map result = fixture.getFields(); assertNotNull(result); assertEquals(0, result.size()); diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java index 1393403a00..9deda2317d 100644 --- a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java +++ b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/types/VariantDefinitionTest.java @@ -17,6 +17,7 @@ import static org.junit.Assert.assertNull; import java.nio.ByteOrder; import java.util.HashMap; +import java.util.Map; import org.eclipse.linuxtools.ctf.core.event.types.ArrayDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.ArrayDefinition; @@ -172,7 +173,7 @@ public class VariantDefinitionTest { */ @Test public void testGetDefinitions() { - HashMap result = fixture.getDefinitions(); + Map result = fixture.getDefinitions(); assertNotNull(result); } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java index 7b55d934ad..9c33db3fa4 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFCallsite.java @@ -21,63 +21,68 @@ package org.eclipse.linuxtools.ctf.core.event; * @since 1.2 */ public class CTFCallsite implements Comparable { - /** - * The callsite constructor - * - * @param en - * The event name - * @param func - * the function name - * @param ip - * the instruction pointer of the callsite - * @param fn - * the file name of the callsite - * @param line - * the line number of the callsite - */ - public CTFCallsite(String en, String func, long ip, String fn, long line) { - EventName = en; - FileName = fn; - FunctionName = func; - this.ip = ip; - this.LineNumber = line; - } - static private final long MASK32 = 0x00000000ffffffffL; + private static final long MASK32 = 0x00000000ffffffffL; + /** * The event name */ - private final String EventName; + private final String eventName; + /** * the file name of the callsite */ - private final String FileName; + private final String fileName; + /** * the instruction pointer */ private final long ip; + /** * the function name */ - private final String FunctionName; + private final String functionName; + /** * the line number of the callsite */ - private final long LineNumber; + private final long lineNumber; + + /** + * The callsite constructor + * + * @param en + * The event name + * @param func + * the function name + * @param ip + * the instruction pointer of the callsite + * @param fn + * the file name of the callsite + * @param line + * the line number of the callsite + */ + public CTFCallsite(String en, String func, long ip, String fn, long line) { + eventName = en; + fileName = fn; + functionName = func; + this.ip = ip; + this.lineNumber = line; + } - /* Getters */ /** * @return the eventName */ public String getEventName() { - return EventName; + return eventName; } /** * @return the fileName */ public String getFileName() { - return FileName; + return fileName; } /** @@ -91,14 +96,14 @@ public class CTFCallsite implements Comparable { * @return the functionName */ public String getFunctionName() { - return FunctionName; + return functionName; } /** * @return the lineNumber */ public long getLineNumber() { - return LineNumber; + return lineNumber; } /* @@ -145,6 +150,6 @@ public class CTFCallsite implements Comparable { @Override public String toString() { - return FileName + "/" + FunctionName + ":" + LineNumber; //$NON-NLS-1$ //$NON-NLS-2$ + return fileName + "/" + functionName + ":" + lineNumber; //$NON-NLS-1$ //$NON-NLS-2$ } } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java index ffd2285ff9..f3c2be6e85 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/CTFClock.java @@ -13,12 +13,16 @@ package org.eclipse.linuxtools.ctf.core.event; import java.util.HashMap; +import java.util.Map; /** * Clock description used in CTF traces */ public class CTFClock { + private static final long ONE_BILLION_L = 1000000000L; + private static final double ONE_BILLION_D = 1000000000.0; + private static final String NAME = "name"; //$NON-NLS-1$ private static final String FREQ = "freq"; //$NON-NLS-1$ private static final String OFFSET = "offset"; //$NON-NLS-1$ @@ -30,7 +34,7 @@ public class CTFClock { /** * Field properties. */ - final private HashMap properties = new HashMap(); + private final Map properties = new HashMap(); /** * Field name. */ @@ -64,8 +68,8 @@ public class CTFClock { * have a system with a frequency of > 1 600 000 000 GHz with * 200 ppm precision */ - isScaled = !((Long) getProperty(FREQ)).equals(1000000000L); - clockScale = 1000000000.0 / ((Long) getProperty(FREQ)).doubleValue(); + isScaled = !((Long) getProperty(FREQ)).equals(ONE_BILLION_L); + clockScale = ONE_BILLION_D / ((Long) getProperty(FREQ)).doubleValue(); clockAntiScale = 1.0 / clockScale; } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java index 7aae945ef4..07df164117 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/io/BitBuffer.java @@ -23,7 +23,7 @@ import java.nio.ByteOrder; * A bitwise buffer capable of accessing fields with bit offsets. * @since 2.0 */ -public class BitBuffer { +public final class BitBuffer { // ------------------------------------------------------------------------ // Constants @@ -96,8 +96,7 @@ public class BitBuffer { * @return The int value read from the buffer */ public int getInt() { - int val = getInt(BIT_INT, true); - return val; + return getInt(BIT_INT, true); } /** @@ -201,7 +200,6 @@ public class BitBuffer { lshift = BIT_CHAR - cshift; value <<= lshift; value |= cmask; - // index += lshift; currByte++; } for (; currByte < (endByte - 1); currByte++) { @@ -255,7 +253,6 @@ public class BitBuffer { cmask = cache & mask; value <<= cshift; value |= cmask; - // end -= cshift; currByte--; } for (; currByte >= (startByte + 1); currByte--) { @@ -372,7 +369,6 @@ public class BitBuffer { int b = this.buf.get(currByte) & 0xFF; this.buf.put(currByte, (byte) ((b & mask) | cmask)); correctedValue >>>= cshift; - // end -= cshift; currByte--; } @@ -437,7 +433,6 @@ public class BitBuffer { int b = this.buf.get(currByte) & 0xFF; this.buf.put(currByte, (byte) ((b & mask) | cmask)); correctedValue >>>= BIT_CHAR - cshift; - // index += BIT_CHAR - cshift; currByte++; } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java index fd3c79c744..ef6ff9283a 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDeclaration.java @@ -70,8 +70,7 @@ public class ArrayDeclaration implements IDeclaration { @Override public long getAlignment() { - long retVal = this.getElementType().getAlignment(); - return retVal; + return getElementType().getAlignment(); } // ------------------------------------------------------------------------ // Operations diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java index 96c6d06f2b..1e4b8c2134 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/ArrayDefinition.java @@ -12,6 +12,8 @@ package org.eclipse.linuxtools.ctf.core.event.types; +import java.util.Arrays; + import org.eclipse.linuxtools.ctf.core.event.io.BitBuffer; /** @@ -68,7 +70,7 @@ public class ArrayDefinition extends Definition { * @return the definitions */ public Definition[] getDefinitions() { - return definitions; + return Arrays.copyOf(definitions, definitions.length); } /** @@ -76,7 +78,7 @@ public class ArrayDefinition extends Definition { * the definitions to set */ public void setDefinitions(Definition[] definitions) { - this.definitions = definitions; + this.definitions = Arrays.copyOf(definitions, definitions.length); } /** diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java index 729e155328..d8b5002497 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/Definition.java @@ -35,19 +35,15 @@ public abstract class Definition { // Attributes // ------------------------------------------------------------------------ - /** The name of the field in its container */ - protected final String fieldName; + private final String fieldName; /** The complete path of this field */ - protected final String path; + private final String path; /** - * The definition scope in which this definition is found. * - * The complete path of a definition is thus the path of the definition - * scope DOT the name of the definition (name of the field in its container) */ - protected final IDefinitionScope definitionScope; + private final IDefinitionScope definitionScope; // ------------------------------------------------------------------------ // Constructors @@ -75,11 +71,43 @@ public abstract class Definition { } else { path = fieldName; } + } - /* - * System.out.println("[definition] " + this.getClass().getSimpleName() - * + " " + path + " created"); - */ + // ------------------------------------------------------------------------ + // Getters + // ------------------------------------------------------------------------ + + /** + * Get the field name in its container. + * + * @return The field name + * @since 2.0 + */ + protected String getFieldName() { + return fieldName; + } + + /** + * Get the complete path of this field. + * + * @return The path + * @since 2.0 + */ + public String getPath() { + return path; + } + + /** + * Get the definition scope in which this definition is found. + * + * The complete path of a definition is thus the path of the definition + * scope DOT the name of the definition (name of the field in its container) + * + * @return The definition scope + * @since 2.0 + */ + protected IDefinitionScope getDefinitionScope() { + return definitionScope; } // ------------------------------------------------------------------------ diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java index 4c145b4c01..44a5206e72 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDeclaration.java @@ -17,7 +17,7 @@ import java.util.List; /** * A CTF enum declaration. - * + * * The definition of a enum point basic data type. It will take the data * from a trace and store it (and make it fit) as an integer and a string. * @@ -102,9 +102,9 @@ public class EnumDeclaration implements IDeclaration { * Maps integer range -> string. A simple list for now, but feel free to * optimize it. Babeltrace suggests an interval tree. */ - static private class EnumTable { + private static class EnumTable { - List ranges = new LinkedList(); + private List ranges = new LinkedList(); public EnumTable() { } @@ -137,10 +137,10 @@ public class EnumDeclaration implements IDeclaration { return null; } - static private class Range { + private static class Range { - long low, high; - String str; + private long low, high; + private String str; public Range(long low, long high, String str) { this.low = low; diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java index 330eb000df..9e6e237a47 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/EnumDefinition.java @@ -85,11 +85,11 @@ public class EnumDefinition extends SimpleDatatypeDefinition { /** * Sets the value of the enum in string format so "Enum a{DAY="0", NIGHT="1"}; will set 0 - * @param Value The value of the enum. + * @param value The value of the enum. */ - public void setIntegerValue(long Value) { - integerValue.setValue(Value); - value = declaration.query(Value); + public void setIntegerValue(long value) { + integerValue.setValue(value); + this.value = declaration.query(value); } @Override diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java index 3f9406c78f..9892552499 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IDeclaration.java @@ -37,8 +37,7 @@ public interface IDeclaration { * the name of the definition * @return a reference to the definition */ - Definition createDefinition(IDefinitionScope definitionScope, - String fieldName); + Definition createDefinition(IDefinitionScope definitionScope, String fieldName); /** * The minimum alignment. if the field is 32 bits, the definition will pad diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java index 5481e7f9f3..d1de809d0f 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/IntegerDeclaration.java @@ -32,13 +32,13 @@ public class IntegerDeclaration implements IDeclaration { // Attributes // ------------------------------------------------------------------------ - final private int length; - final private boolean signed; - final private int base; - final private ByteOrder byteOrder; - final private Encoding encoding; - final private long alignment; - final private String clock; + private final int length; + private final boolean signed; + private final int base; + private final ByteOrder byteOrder; + private final Encoding encoding; + private final long alignment; + private final String clock; // ------------------------------------------------------------------------ // Constructors diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java index b7d9d918ca..c910adbea5 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/SequenceDefinition.java @@ -145,15 +145,13 @@ public class SequenceDefinition extends Definition { int i = 0; if (definitions != null) { - for (; i < definitions.length; i++) { - newDefinitions[i] = definitions[i]; - } + System.arraycopy(definitions, 0, newDefinitions, 0, definitions.length); } for (; i < currentLength; i++) { newDefinitions[i] = declaration.getElementType() - .createDefinition(definitionScope, - fieldName + "[" + i + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + .createDefinition(getDefinitionScope(), + getFieldName() + "[" + i + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } definitions = newDefinitions; diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java index eefbb61c86..e43db0d813 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDeclaration.java @@ -15,6 +15,7 @@ package org.eclipse.linuxtools.ctf.core.event.types; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; /** * A CTF structure declaration. @@ -33,7 +34,7 @@ public class StructDeclaration implements IDeclaration { // Attributes // ------------------------------------------------------------------------ - private final HashMap fields = new HashMap(); + private final Map fields = new HashMap(); private final List fieldsList = new LinkedList(); private long maxAlign; @@ -77,8 +78,9 @@ public class StructDeclaration implements IDeclaration { /** * get the fields of the struct in a map. Faster access time than a list. * @return a HashMap of the fields (key is the name) + * @since 2.0 */ - public HashMap getFields() { + public Map getFields() { return this.fields; } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java index b7603497b4..97b711c636 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/StructDefinition.java @@ -72,11 +72,6 @@ public class StructDefinition extends Definition implements IDefinitionScope { // Getters/Setters/Predicates // ------------------------------------------------------------------------ - @Override - public String getPath() { - return path; - } - /** * @return The definitions of all the fields * @since 2.0 diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java index fcedc1bed2..42a9f431dc 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDeclaration.java @@ -13,10 +13,11 @@ package org.eclipse.linuxtools.ctf.core.event.types; import java.util.HashMap; +import java.util.Map; /** * A CTFC variant declaration. - * + * * A variant is similar to a C union, only taking the minimum size of the types, * it is a compound data type that contains other datatypes in fields. they are * stored in an hashmap and indexed by names which are strings. @@ -32,8 +33,8 @@ public class VariantDeclaration implements IDeclaration { // ------------------------------------------------------------------------ private String tag = null; - final static private long alignment = 1; - private final HashMap fields = new HashMap(); + private static final long alignment = 1; + private final Map fields = new HashMap(); // ------------------------------------------------------------------------ // Constructors @@ -85,8 +86,9 @@ public class VariantDeclaration implements IDeclaration { /** * Gets the fields of the variant * @return the fields of the variant + * @since 2.0 */ - public HashMap getFields() { + public Map getFields() { return this.fields; } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java index 70e2eb0a8d..8d73ef1d2d 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/event/types/VariantDefinition.java @@ -37,7 +37,7 @@ public class VariantDefinition extends Definition implements IDefinitionScope { private VariantDeclaration declaration; private EnumDefinition tagDefinition; - private HashMap definitions = new HashMap(); + private Map definitions = new HashMap(); private String currentField; // ------------------------------------------------------------------------ @@ -57,13 +57,6 @@ public class VariantDefinition extends Definition implements IDefinitionScope { this.declaration = declaration; Definition tagDef = definitionScope.lookupDefinition(declaration.getTag()); - /* - * if (tagDef == null) { throw new - * Exception("Variant tag field not found"); } - * - * if (!(tagDef instanceof EnumDefinition)) { throw new - * Exception("Variant tag field not enum"); } - */ this.tagDefinition = (EnumDefinition) tagDef; for (Map.Entry field : declaration.getFields().entrySet()) { @@ -109,16 +102,18 @@ public class VariantDefinition extends Definition implements IDefinitionScope { /** * Get the definitions in the variant * @return the definitions + * @since 2.0 */ - public HashMap getDefinitions() { + public Map getDefinitions() { return definitions; } /** * Set the definitions in a variant * @param definitions the definitions + * @since 2.0 */ - public void setDefinitions(HashMap definitions) { + public void setDefinitions(Map definitions) { this.definitions = definitions; } @@ -130,11 +125,6 @@ public class VariantDefinition extends Definition implements IDefinitionScope { this.currentField = currentField; } - @Override - public String getPath() { - return path; - } - /** * Get the current field name * @return the current field name diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java index 915061760b..f7b0bad5fa 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTrace.java @@ -76,11 +76,6 @@ public class CTFTrace implements IDefinitionScope { */ private final File path; - /** - * The metadata parsing object. - */ - private final Metadata metadata; - /** * Major CTF version number */ @@ -138,9 +133,8 @@ public class CTFTrace implements IDefinitionScope { private final List fileInputStreams = new LinkedList(); /** Handlers for the metadata files */ - private final static FileFilter metadataFileFilter = new MetadataFileFilter(); - private final static Comparator metadataComparator = new MetadataComparator(); // $codepro.audit.disable - // fieldJavadoc + private static final FileFilter METADATA_FILE_FILTER = new MetadataFileFilter(); + private static final Comparator METADATA_COMPARATOR = new MetadataComparator(); /** map of all the event types */ private final Map> eventDecs = new HashMap>(); @@ -151,6 +145,7 @@ public class CTFTrace implements IDefinitionScope { /** Callsite helpers */ private Map> callsitesByName = new HashMap>(); + /** Callsite helpers */ private TreeSet callsitesByIP = new TreeSet(); @@ -183,7 +178,7 @@ public class CTFTrace implements IDefinitionScope { */ public CTFTrace(File path) throws CTFReaderException { this.path = path; - this.metadata = new Metadata(this); + final Metadata metadata = new Metadata(this); /* Set up the internal containers for this trace */ if (!this.path.exists()) { @@ -205,8 +200,8 @@ public class CTFTrace implements IDefinitionScope { } /* List files not called metadata and not hidden. */ - File[] files = path.listFiles(metadataFileFilter); - Arrays.sort(files, metadataComparator); + File[] files = path.listFiles(METADATA_FILE_FILTER); + Arrays.sort(files, METADATA_COMPARATOR); /* Try to open each file */ for (File streamFile : files) { openStreamInput(streamFile); @@ -263,8 +258,9 @@ public class CTFTrace implements IDefinitionScope { * @param streamId * The ID of the stream from which to read * @return The Hash map with the event declarations + * @since 2.0 */ - public HashMap getEvents(Long streamId) { + public Map getEvents(Long streamId) { return eventDecs.get(streamId); } @@ -286,7 +282,7 @@ public class CTFTrace implements IDefinitionScope { * @return the hashmap with the event definitions * @since 2.0 */ - public HashMap getEventDefs(StreamInput id) { + public Map getEventDefs(StreamInput id) { if(! eventDefs.containsKey(id)){ eventDefs.put(id, new HashMap()); } @@ -400,8 +396,9 @@ public class CTFTrace implements IDefinitionScope { * Method UUIDIsSet is the UUID set? * * @return boolean is the UUID set? + * @since 2.0 */ - public boolean UUIDIsSet() { + public boolean uuidIsSet() { return uuid != null; } @@ -455,7 +452,7 @@ public class CTFTrace implements IDefinitionScope { * * @return ByteOrder gets the trace byte order */ - public ByteOrder getByteOrder() { + public final ByteOrder getByteOrder() { return byteOrder; } @@ -533,7 +530,7 @@ public class CTFTrace implements IDefinitionScope { byteBuffer = fc.map(MapMode.READ_ONLY, 0, Math.min((int)fc.size(), 4096)); } catch (IOException e) { /* Shouldn't happen at this stage if every other check passed */ - throw new CTFReaderException(); + throw new CTFReaderException(e); } /* Create a BitBuffer with this mapping and the trace byte order */ @@ -729,7 +726,7 @@ public class CTFTrace implements IDefinitionScope { * * @return the time offset of a clock with respect to UTC in nanoseconds */ - private final double getTimeScale() { + private double getTimeScale() { if (getClock() == null) { return 1.0; } @@ -741,7 +738,7 @@ public class CTFTrace implements IDefinitionScope { * * @return if the trace is in ns or cycles. */ - private final boolean clockNeedsScale() { + private boolean clockNeedsScale() { if (getClock() == null) { return false; } @@ -753,7 +750,7 @@ public class CTFTrace implements IDefinitionScope { * * @return 1.0 / scale */ - private final double getInverseTimeScale() { + private double getInverseTimeScale() { if (getClock() == null) { return 1.0; } @@ -811,8 +808,9 @@ public class CTFTrace implements IDefinitionScope { * Add an event declaration map to the events map. * @param id the id of a stream * @return the hashmap containing events. + * @since 2.0 */ - public HashMap createEvents(Long id){ + public Map createEvents(Long id){ HashMap value = eventDecs.get(id); if( value == null ) { value = new HashMap(); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java index 2aa6afb30d..812f6bd362 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/CTFTraceReader.java @@ -13,10 +13,11 @@ package org.eclipse.linuxtools.ctf.core.trace; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import java.util.PriorityQueue; import java.util.Set; -import java.util.Vector; import org.eclipse.linuxtools.ctf.core.event.EventDefinition; import org.eclipse.linuxtools.internal.ctf.core.Activator; @@ -43,12 +44,12 @@ public class CTFTraceReader { /** * Vector of all the trace file readers. */ - private final Vector streamInputReaders = new Vector(); + private final List streamInputReaders = new ArrayList(); /** * Priority queue to order the trace file readers by timestamp. */ - protected PriorityQueue prio; + private PriorityQueue prio; /** * Array to count the number of event per trace file. @@ -93,7 +94,7 @@ public class CTFTraceReader { * Get the start Time of this trace bear in mind that the trace could be * empty. */ - this.startTime = 0;// prio.peek().getPacketReader().getCurrentPacket().getTimestampBegin(); + this.startTime = 0; if (hasMoreEvents()) { this.startTime = prio.peek().getCurrentEvent().getTimestamp(); this.setEndTime(this.startTime); @@ -146,10 +147,20 @@ public class CTFTraceReader { * @param endTime * The end time to use */ - protected void setEndTime(long endTime) { + protected final void setEndTime(long endTime) { this.endTime = endTime; } + /** + * Get the priority queue of this trace reader. + * + * @return The priority queue of input readers + * @since 2.0 + */ + protected PriorityQueue getPrio() { + return prio; + } + // ------------------------------------------------------------------------ // Operations @@ -330,23 +341,6 @@ public class CTFTraceReader { return hasMoreEvents(); } -// /** -// * Go to the first entry of a trace -// * -// * @return 0, the first index. -// */ -// private long goToZero() { -// long tempIndex; -// for (StreamInputReader streamInputReader : this.streamInputReaders) { -// /* -// * Seek the trace reader. -// */ -// streamInputReader.seek(0); -// } -// tempIndex = 0; -// return tempIndex; -// } - /** * gets the stream with the oldest event * @@ -361,7 +355,7 @@ public class CTFTraceReader { * * @return true if yes. */ - public boolean hasMoreEvents() { + public final boolean hasMoreEvents() { return this.prio.size() > 0; } @@ -394,7 +388,8 @@ public class CTFTraceReader { long len = (width * this.eventCountPerTraceFile[se.getName()]) / numEvents; - StringBuilder sb = new StringBuilder(se.getFilename() + "\t["); //$NON-NLS-1$ + StringBuilder sb = new StringBuilder(se.getFilename()); + sb.append("\t["); //$NON-NLS-1$ for (int i = 0; i < len; i++) { sb.append('+'); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java index 2e75e6a2f7..64e50669a3 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Metadata.java @@ -54,12 +54,12 @@ public class Metadata { /** * Name of the metadata file in the trace directory */ - final static String METADATA_FILENAME = "metadata"; //$NON-NLS-1$ + private static final String METADATA_FILENAME = "metadata"; //$NON-NLS-1$ /** * Size of the metadata packet header, in bytes, computed by hand. */ - final static int METADATA_PACKET_HEADER_SIZE = 37; + private static final int METADATA_PACKET_HEADER_SIZE = 37; // ------------------------------------------------------------------------ // Attributes @@ -221,12 +221,9 @@ public class Metadata { CTFLexer ctfLexer = new CTFLexer(antlrStream); CommonTokenStream tokens = new CommonTokenStream(ctfLexer); CTFParser ctfParser = new CTFParser(tokens, false); - parse_return ret; - ret = ctfParser.parse(); - - CommonTree tree = (CommonTree) ret.getTree(); - return tree; + parse_return pr = ctfParser.parse(); + return (CommonTree) pr.getTree(); } /** @@ -251,7 +248,7 @@ public class Metadata { try { metadataFileChannel.read(magicByteBuffer, 0); } catch (IOException e) { - throw new CTFReaderException("Unable to read metadata file channel."); //$NON-NLS-1$ + throw new CTFReaderException("Unable to read metadata file channel.", e); //$NON-NLS-1$ } /* Get the first int from the file */ @@ -298,7 +295,7 @@ public class Metadata { try { nbBytesRead = metadataFileChannel.read(headerByteBuffer); } catch (IOException e) { - throw new CTFReaderException("Error reading the metadata header."); //$NON-NLS-1$ + throw new CTFReaderException("Error reading the metadata header.", e); //$NON-NLS-1$ } /* Return null if EOF */ @@ -335,7 +332,7 @@ public class Metadata { /* Check UUID */ UUID uuid = Utils.makeUUID(header.uuid); - if (!trace.UUIDIsSet()) { + if (!trace.uuidIsSet()) { trace.setUUID(uuid); } else { if (!trace.getUUID().equals(uuid)) { @@ -356,7 +353,7 @@ public class Metadata { try { metadataFileChannel.read(payloadByteBuffer); } catch (IOException e) { - throw new CTFReaderException("Error reading metadata packet payload."); //$NON-NLS-1$ + throw new CTFReaderException("Error reading metadata packet payload.", e); //$NON-NLS-1$ } payloadByteBuffer.rewind(); @@ -373,7 +370,7 @@ public class Metadata { return header; } - static class MetadataPacketHeader { + private static class MetadataPacketHeader { public int magic; public byte uuid[] = new byte[16]; diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java index 5fb6de2f22..774a95e887 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Stream.java @@ -14,6 +14,7 @@ package org.eclipse.linuxtools.ctf.core.trace; import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; @@ -53,7 +54,7 @@ public class Stream { /** * Maps event ids to events */ - private HashMap events = new HashMap(); + private Map events = new HashMap(); /** * The inputs associated to this stream @@ -196,7 +197,7 @@ public class Stream { * * @return all the event declarations for this stream, using the id as a key for the hashmap. */ - public HashMap getEvents() { + public Map getEvents() { return events; } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java index 407db54586..6b640cb1c9 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInput.java @@ -56,7 +56,7 @@ public class StreamInput implements IDefinitionScope { /** * Information on the file (used for debugging) */ - public final File file; + private final File file; /** * The packet index of this input @@ -68,17 +68,17 @@ public class StreamInput implements IDefinitionScope { /* * Definition of trace packet header */ - StructDefinition tracePacketHeaderDef = null; + private StructDefinition tracePacketHeaderDef = null; /* * Definition of trace stream packet context */ - StructDefinition streamPacketContextDef = null; + private StructDefinition streamPacketContextDef = null; /* * Total number of lost events in this stream */ - long lostSoFar = 0; + private long lostSoFar = 0; // ------------------------------------------------------------------------ // Constructors @@ -244,9 +244,9 @@ public class StreamInput implements IDefinitionScope { StructDefinition tracePacketHeaderDef, StructDefinition streamPacketContextDef, BitBuffer bitBuffer) throws CTFReaderException { - @SuppressWarnings("unused") - MappedByteBuffer bb = createPacketBitBuffer(fileSizeBytes, - packetOffsetBytes, packetIndex, bitBuffer); + + /* Ignoring the return value, but this call is needed to initialize the input */ + createPacketBitBuffer(fileSizeBytes, packetOffsetBytes, packetIndex, bitBuffer); /* * Read the trace packet header if it exists. @@ -358,14 +358,13 @@ public class StreamInput implements IDefinitionScope { /* * Check the trace UUID */ - ArrayDefinition uuidDef = (ArrayDefinition) tracePacketHeaderDef - .lookupDefinition("uuid"); //$NON-NLS-1$ + ArrayDefinition uuidDef = + (ArrayDefinition) tracePacketHeaderDef.lookupDefinition("uuid"); //$NON-NLS-1$ if (uuidDef != null) { byte[] uuidArray = new byte[16]; - for (int i = 0; i < 16; i++) { - IntegerDefinition uuidByteDef = (IntegerDefinition) uuidDef - .getElem(i); + for (int i = 0; i < uuidArray.length; i++) { + IntegerDefinition uuidByteDef = (IntegerDefinition) uuidDef.getElem(i); uuidArray[i] = (byte) uuidByteDef.getValue(); } @@ -426,11 +425,11 @@ public class StreamInput implements IDefinitionScope { Long contentSize = (Long) packetIndex.lookupAttribute("content_size"); //$NON-NLS-1$ Long packetSize = (Long) packetIndex.lookupAttribute("packet_size"); //$NON-NLS-1$ - Long timestampBegin = (Long) packetIndex.lookupAttribute("timestamp_begin"); //$NON-NLS-1$ - Long timestampEnd = (Long) packetIndex.lookupAttribute("timestamp_end"); //$NON-NLS-1$ + Long tsBegin = (Long) packetIndex.lookupAttribute("timestamp_begin"); //$NON-NLS-1$ + Long tsEnd = (Long) packetIndex.lookupAttribute("timestamp_end"); //$NON-NLS-1$ String device = (String) packetIndex.lookupAttribute("device"); //$NON-NLS-1$ // LTTng Specific - Long CPU_ID = (Long) packetIndex.lookupAttribute("cpu_id"); //$NON-NLS-1$ + Long cpuId = (Long) packetIndex.lookupAttribute("cpu_id"); //$NON-NLS-1$ Long lostEvents = (Long) packetIndex.lookupAttribute("events_discarded"); //$NON-NLS-1$ /* Read the content size in bits */ @@ -452,16 +451,16 @@ public class StreamInput implements IDefinitionScope { } /* Read the begin timestamp */ - if (timestampBegin != null) { - packetIndex.setTimestampBegin(timestampBegin.longValue()); + if (tsBegin != null) { + packetIndex.setTimestampBegin(tsBegin.longValue()); } /* Read the end timestamp */ - if (timestampEnd != null) { - if( timestampEnd == -1 ) { - timestampEnd = Long.MAX_VALUE; + if (tsEnd != null) { + if( tsEnd == -1 ) { + tsEnd = Long.MAX_VALUE; } - packetIndex.setTimestampEnd(timestampEnd.longValue()); + packetIndex.setTimestampEnd(tsEnd.longValue()); setTimestampEnd(packetIndex.getTimestampEnd()); } @@ -469,8 +468,8 @@ public class StreamInput implements IDefinitionScope { packetIndex.setTarget(device); } - if (CPU_ID != null) { - packetIndex.setTarget("CPU" + CPU_ID.toString()); //$NON-NLS-1$ + if (cpuId != null) { + packetIndex.setTarget("CPU" + cpuId.toString()); //$NON-NLS-1$ } if (lostEvents != null) { diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java index f6bb3db057..7076d26719 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/StreamInputPacketReader.java @@ -15,7 +15,7 @@ import java.io.IOException; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel.MapMode; import java.util.Collection; -import java.util.HashMap; +import java.util.Map; import org.eclipse.linuxtools.ctf.core.event.EventDefinition; import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration; @@ -62,7 +62,7 @@ public class StreamInputPacketReader implements IDefinitionScope { private final StructDefinition streamEventContextDef; /** Maps event ID to event definitions. */ - private final HashMap events; + private final Map events; /** Reference to the index entry of the current packet. */ private StreamInputPacketIndexEntry currentPacket = null; @@ -315,9 +315,9 @@ public class StreamInputPacketReader implements IDefinitionScope { } // else, eventID remains 0 /* Get the timestamp from the event header (may be overridden later on) */ - Definition timestampDef = sehd.lookupInteger("timestamp"); //$NON-NLS-1$ - if (timestampDef instanceof IntegerDefinition) { - timestamp = calculateTimestamp((IntegerDefinition) timestampDef); + IntegerDefinition timestampDef = sehd.lookupInteger("timestamp"); //$NON-NLS-1$ + if (timestampDef != null) { + timestamp = calculateTimestamp(timestampDef); } // else timestamp remains 0 /* Check for the variant v. */ @@ -337,9 +337,9 @@ public class StreamInputPacketReader implements IDefinitionScope { } /* Get the timestamp. This would overwrite any previous timestamp definition */ - timestampDef = variantCurrentField.lookupDefinition("timestamp"); //$NON-NLS-1$ - if (timestampDef instanceof IntegerDefinition) { - timestamp = calculateTimestamp((IntegerDefinition) timestampDef); + Definition def = variantCurrentField.lookupDefinition("timestamp"); //$NON-NLS-1$ + if (def instanceof IntegerDefinition) { + timestamp = calculateTimestamp((IntegerDefinition) def); } } } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Utils.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Utils.java index 90f8958606..d0cb11e3eb 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Utils.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/ctf/core/trace/Utils.java @@ -16,13 +16,15 @@ import java.util.UUID; /** * Various utilities. - * + * * @version 1.0 * @author Matthew Khouzam * @author Simon Marchi */ public class Utils { + private Utils() {} + // ------------------------------------------------------------------------ // Constants // ------------------------------------------------------------------------ @@ -30,27 +32,27 @@ public class Utils { /** * CTF magic number. (sort of looks like CTF CTF CT) */ - public final static int CTF_MAGIC = 0xC1FC1FC1; + public static final int CTF_MAGIC = 0xC1FC1FC1; /** * TSDL magic number. (sort of looks like TSDL LSDT) */ - public final static int TSDL_MAGIC = 0x75D11D57; + public static final int TSDL_MAGIC = 0x75D11D57; /** * TSDL magic number length in bytes. */ - public final static int TSDL_MAGIC_LEN = 4; + public static final int TSDL_MAGIC_LEN = 4; /** * Directory separator on the current platform. */ - public final static String SEPARATOR = System.getProperty("file.separator"); //$NON-NLS-1$ + public static final String SEPARATOR = System.getProperty("file.separator"); //$NON-NLS-1$ /** * Length in bytes of a UUID value. */ - public final static int UUID_LEN = 16; + public static final int UUID_LEN = 16; // ------------------------------------------------------------------------ // Operations diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java index 035c99f588..26b3c75d43 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/EventDeclaration.java @@ -97,7 +97,7 @@ public class EventDeclaration implements IEventDeclaration { * * @return the lost event */ - public synchronized static EventDeclaration getLostEventDeclaration() { + public static synchronized EventDeclaration getLostEventDeclaration() { EventDeclaration lostEvent = new EventDeclaration(); lostEvent.fields = new StructDeclaration(1); lostEvent.id = -1L; diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java index 11dc2e65e1..4c2f344c01 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/CTFStrings.java @@ -16,95 +16,96 @@ package org.eclipse.linuxtools.internal.ctf.core.event.metadata; * they get quarked. See CTF specs for more details * * @author Matthew Khouzam and All - * */ +@SuppressWarnings("nls") public interface CTFStrings { /** None */ - public static final String NONE = "none"; //$NON-NLS-1$ + + static final String NONE = "none"; /** Ascii */ - public static final String ASCII = "ASCII"; //$NON-NLS-1$ + static final String ASCII = "ASCII"; /** UTF8 */ - public static final String UTF8 = "UTF8"; //$NON-NLS-1$ + static final String UTF8 = "UTF8"; /** b (for binary like b11010010 */ - public static final String BIN = "b"; //$NON-NLS-1$ + static final String BIN = "b"; /** Binary */ - public static final String BINARY = "binary"; //$NON-NLS-1$ + static final String BINARY = "binary"; /** Octal like o177 */ - public static final String OCTAL_CTE = "o"; //$NON-NLS-1$ + static final String OCTAL_CTE = "o"; /** Octal like oct177 */ - public static final String OCT = "oct"; //$NON-NLS-1$ + static final String OCT = "oct"; /** Octal like octal177 */ - public static final String OCTAL = "octal"; //$NON-NLS-1$ + static final String OCTAL = "octal"; /** Pointer (memory address for all the hardcore Java gurus out there)*/ - public static final String POINTER = "p"; //$NON-NLS-1$ + static final String POINTER = "p"; /** X for hex */ - public static final String X2 = "X"; //$NON-NLS-1$ + static final String X2 = "X"; /** x for hex */ - public static final String X = "x"; //$NON-NLS-1$ + static final String X = "x"; /** hex */ - public static final String HEX = "hex"; //$NON-NLS-1$ + static final String HEX = "hex"; /** Hexadecimal */ - public static final String HEXADECIMAL = "hexadecimal"; //$NON-NLS-1$ + static final String HEXADECIMAL = "hexadecimal"; /** unsigned like in 10000ul */ - public static final String UNSIGNED_CTE = "u"; //$NON-NLS-1$ + static final String UNSIGNED_CTE = "u"; /** Decimal */ - public static final String DEC_CTE = "d"; //$NON-NLS-1$ + static final String DEC_CTE = "d"; /** Integer like 1000i */ - public static final String INT_MOD = "i"; //$NON-NLS-1$ + static final String INT_MOD = "i"; /** Decimal */ - public static final String DEC = "dec"; //$NON-NLS-1$ + static final String DEC = "dec"; /** Decimal */ - public static final String DECIMAL = "decimal"; //$NON-NLS-1$ + static final String DECIMAL = "decimal"; /** native for byteorders*/ - public static final String NATIVE = "native"; //$NON-NLS-1$ + static final String NATIVE = "native"; /** network for byteorders*/ - public static final String NETWORK = "network"; //$NON-NLS-1$ + static final String NETWORK = "network"; /** Big endian */ - public static final String BE = "be"; //$NON-NLS-1$ + static final String BE = "be"; /** Little endian */ - public static final String LE = "le"; //$NON-NLS-1$ + static final String LE = "le"; /** Alignment of a field */ - public static final String ALIGN = "align"; //$NON-NLS-1$ + static final String ALIGN = "align"; /** Mantissa digits */ - public static final String MANT_DIG = "mant_dig"; //$NON-NLS-1$ + static final String MANT_DIG = "mant_dig"; /** Exponent digits */ - public static final String EXP_DIG = "exp_dig"; //$NON-NLS-1$ + static final String EXP_DIG = "exp_dig"; /** Loglevel */ - public static final String LOGLEVEL2 = "loglevel"; //$NON-NLS-1$ + static final String LOGLEVEL2 = "loglevel"; /** Name */ - public static final String NAME2 = "name"; //$NON-NLS-1$ + static final String NAME2 = "name"; /** Event context */ - public static final String EVENT_CONTEXT = "event.context"; //$NON-NLS-1$ + static final String EVENT_CONTEXT = "event.context"; /** Fields */ - public static final String FIELDS_STRING = "fields"; //$NON-NLS-1$ + static final String FIELDS_STRING = "fields"; /** context */ - public static final String CONTEXT = "context"; //$NON-NLS-1$ + static final String CONTEXT = "context"; /** Stream ID */ - public static final String STREAM_ID = "stream_id"; //$NON-NLS-1$ + static final String STREAM_ID = "stream_id"; /** Packet context */ - public static final String PACKET_CONTEXT = "packet.context"; //$NON-NLS-1$ + static final String PACKET_CONTEXT = "packet.context"; /** ID */ - public static final String ID = "id"; //$NON-NLS-1$ + static final String ID = "id"; /** Packet Header */ - public static final String PACKET_HEADER = "packet.header"; //$NON-NLS-1$ + static final String PACKET_HEADER = "packet.header"; /** Event Header */ - public static final String EVENT_HEADER = "event.header"; //$NON-NLS-1$ + static final String EVENT_HEADER = "event.header"; /** Byte order */ - public static final String BYTE_ORDER = "byte_order"; //$NON-NLS-1$ + static final String BYTE_ORDER = "byte_order"; /** UUID */ - public static final String UUID_STRING = "uuid"; //$NON-NLS-1$ + static final String UUID_STRING = "uuid"; /** False */ - public static final String FALSE2 = "FALSE"; //$NON-NLS-1$ + static final String FALSE2 = "FALSE"; /** False */ - public static final String FALSE = "false"; //$NON-NLS-1$ + static final String FALSE = "false"; /** True */ - public static final String TRUE2 = "TRUE"; //$NON-NLS-1$ + static final String TRUE2 = "TRUE"; /** True */ - public static final String TRUE = "true"; //$NON-NLS-1$ + static final String TRUE = "true"; /** Minor (Vresion)*/ - public static final String MINOR = "minor"; //$NON-NLS-1$ + static final String MINOR = "minor"; /** Major (Vresion)*/ - public static final String MAJOR = "major"; //$NON-NLS-1$ + static final String MAJOR = "major"; } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/DeclarationScope.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/DeclarationScope.java index 81b2596905..6c5606a744 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/DeclarationScope.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/DeclarationScope.java @@ -13,6 +13,7 @@ package org.eclipse.linuxtools.internal.ctf.core.event.metadata; import java.util.HashMap; +import java.util.Map; import org.eclipse.linuxtools.ctf.core.event.types.EnumDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.IDeclaration; @@ -34,10 +35,10 @@ public class DeclarationScope { private DeclarationScope parentScope = null; - private final HashMap structs = new HashMap(); - private final HashMap enums = new HashMap(); - private final HashMap variants = new HashMap(); - private final HashMap types = new HashMap(); + private final Map structs = new HashMap(); + private final Map enums = new HashMap(); + private final Map variants = new HashMap(); + private final Map types = new HashMap(); // ------------------------------------------------------------------------ // Constructors @@ -90,8 +91,7 @@ public class DeclarationScope { throws ParseException { /* Check if the type has been defined in the current scope */ if (types.containsKey(name)) { - throw new ParseException("Type " + name //$NON-NLS-1$ - + " has already been defined."); //$NON-NLS-1$ + throw new ParseException(Messages.TypeAlreadyDefined + ':' + name); } /* Add it to the register. */ @@ -112,16 +112,15 @@ public class DeclarationScope { throws ParseException { /* Check if the struct has been defined in the current scope. */ if (structs.containsKey(name)) { - throw new ParseException("struct " + name //$NON-NLS-1$ - + " has already been defined."); //$NON-NLS-1$ + throw new ParseException(Messages.StructAlreadyDefined + ':' + name); } /* Add it to the register. */ structs.put(name, declaration); /* It also defined a new type, so add it to the type declarations. */ - String struct_prefix = "struct "; //$NON-NLS-1$ - registerType(struct_prefix + name, declaration); + String structPrefix = "struct "; //$NON-NLS-1$ + registerType(structPrefix + name, declaration); } /** @@ -138,16 +137,15 @@ public class DeclarationScope { throws ParseException { /* Check if the enum has been defined in the current scope. */ if (lookupEnum(name) != null) { - throw new ParseException("enum " + name //$NON-NLS-1$ - + " has already been defined."); //$NON-NLS-1$ + throw new ParseException(Messages.EnumAlreadyDefined + ':' + name); } /* Add it to the register. */ enums.put(name, declaration); /* It also defined a new type, so add it to the type declarations. */ - String enum_prefix = "enum "; //$NON-NLS-1$ - registerType(enum_prefix + name, declaration); + String enumPrefix = "enum "; //$NON-NLS-1$ + registerType(enumPrefix + name, declaration); } /** @@ -164,16 +162,15 @@ public class DeclarationScope { throws ParseException { /* Check if the variant has been defined in the current scope. */ if (lookupVariant(name) != null) { - throw new ParseException("variant " + name //$NON-NLS-1$ - + " has already been defined."); //$NON-NLS-1$ + throw new ParseException(Messages.VariantAlreadyDefined + ':' + name); } /* Add it to the register. */ variants.put(name, declaration); /* It also defined a new type, so add it to the type declarations. */ - String variant_prefix = "variant "; //$NON-NLS-1$ - registerType(variant_prefix + name, declaration); + String variantPrefix = "variant "; //$NON-NLS-1$ + registerType(variantPrefix + name, declaration); } // ------------------------------------------------------------------------ @@ -333,7 +330,7 @@ public class DeclarationScope { if (types.containsKey(name)) { types.put(name, newType); } else { - throw new ParseException("Trace does not contain type: " + name); //$NON-NLS-1$ + throw new ParseException(Messages.TraceDoesNotContainType + ':' + name); } } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java index 10e9282f9a..79a4fe6c00 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/IOStructGen.java @@ -38,7 +38,6 @@ import org.eclipse.linuxtools.ctf.core.event.types.SequenceDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StringDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration; import org.eclipse.linuxtools.ctf.core.event.types.VariantDeclaration; -import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException; import org.eclipse.linuxtools.ctf.core.trace.CTFTrace; import org.eclipse.linuxtools.ctf.core.trace.Stream; import org.eclipse.linuxtools.ctf.parser.CTFParser; @@ -55,7 +54,7 @@ public class IOStructGen { // Attributes // ------------------------------------------------------------------------ - static private final boolean DEBUG_ = false; + private static final boolean DEBUG = false; /** * The trace @@ -111,7 +110,7 @@ public class IOStructGen { List children = root.getChildren(); java.io.FileOutputStream fos = null; java.io.OutputStreamWriter out = null; - if (DEBUG_) { + if (DEBUG) { try { fos = new java.io.FileOutputStream("/tmp/astInfo.txt"); //$NON-NLS-1$ out = new java.io.OutputStreamWriter(fos, "UTF-8"); //$NON-NLS-1$ @@ -137,7 +136,7 @@ public class IOStructGen { try { for (CommonTree child : children) { final int type = child.getType(); - if (DEBUG_) { + if (DEBUG) { out.write(child.toString() + " -> " + type + '\n'); //$NON-NLS-1$ } @@ -171,11 +170,11 @@ public class IOStructGen { childTypeError(child); } } - if (DEBUG_) { + if (DEBUG) { out.write("Declarations\n"); //$NON-NLS-1$ } for (CommonTree decl : declarations) { - if (DEBUG_) { + if (DEBUG) { out.write(decl.toString() + '\n'); } parseRootDeclaration(decl); @@ -186,31 +185,31 @@ public class IOStructGen { parseTrace(traceNode); - if (DEBUG_) { + if (DEBUG) { out.write("Environments\n"); //$NON-NLS-1$ } for (CommonTree environment : environments) { parseEnvironment(environment); } - if (DEBUG_) { + if (DEBUG) { out.write("Clocks\n"); //$NON-NLS-1$ } for (CommonTree clock : clocks) { parseClock(clock); } - if (DEBUG_) { + if (DEBUG) { out.write("Callsites\n"); //$NON-NLS-1$ } for (CommonTree callsite : callsites) { parseCallsite(callsite); } - if (DEBUG_) { + if (DEBUG) { out.write("Streams\n"); //$NON-NLS-1$ } if (streams.size() > 0) { for (CommonTree stream : streams) { - if (DEBUG_) { + if (DEBUG) { try { out.write(stream.toString() + '\n'); } catch (IOException e) { @@ -224,19 +223,19 @@ public class IOStructGen { trace.addStream(new Stream(trace)); } - if (DEBUG_) { + if (DEBUG) { out.write("Events\n"); //$NON-NLS-1$ } for (CommonTree event : events) { parseEvent(event); - if (DEBUG_) { + if (DEBUG) { CommonTree name = (CommonTree) event.getChild(0).getChild(1).getChild(0).getChild(0); CommonTree id = (CommonTree) event.getChild(1).getChild(1).getChild(0).getChild(0); out.write("Name = " + name + " Id = " + id + '\n'); //$NON-NLS-1$ //$NON-NLS-2$ } } - if (DEBUG_) { + if (DEBUG) { out.close(); fos.close(); } @@ -250,10 +249,10 @@ public class IOStructGen { List children = callsite.getChildren(); String name = null; - String func_name = null; - long line_number = -1; + String funcName = null; + long lineNumber = -1; long ip = -1; - String file_name = null; + String fileName = null; for (CommonTree child : children) { String left; @@ -265,16 +264,16 @@ public class IOStructGen { if (left.equals("name")) { //$NON-NLS-1$ name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString); } else if (left.equals("func")) { //$NON-NLS-1$ - func_name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString); + funcName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString); } else if (left.equals("ip")) { //$NON-NLS-1$ - ip = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText().substring(2),16); // trim the 0x + ip = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText().substring(2), 16); // trim the 0x } else if (left.equals("file")) { //$NON-NLS-1$ - file_name = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString); + fileName = child.getChild(1).getChild(0).getChild(0).getText().replaceAll(regex, nullString); } else if (left.equals("line")) { //$NON-NLS-1$ - line_number = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText()); + lineNumber = Long.parseLong(child.getChild(1).getChild(0).getChild(0).getText()); } } - trace.addCallsite(name, func_name, ip,file_name, line_number); + trace.addCallsite(name, funcName, ip,fileName, lineNumber); } private void parseEnvironment(CommonTree environment) { @@ -321,8 +320,8 @@ public class IOStructGen { } } - String NameValue = ctfClock.getName(); - trace.addClock(NameValue, ctfClock); + String nameValue = ctfClock.getName(); + trace.addClock(nameValue, ctfClock); } private void parseTrace(CommonTree traceNode) throws ParseException { @@ -399,7 +398,7 @@ public class IOStructGen { * If uuid was already set by a metadata packet, compare it to see * if it matches */ - if (trace.UUIDIsSet()) { + if (trace.uuidIsSet()) { if (trace.getUUID().compareTo(uuid) != 0) { throw new ParseException("UUID mismatch. Packet says " //$NON-NLS-1$ + trace.getUUID() + " but metadata says " + uuid); //$NON-NLS-1$ @@ -880,11 +879,9 @@ public class IOStructGen { IDeclaration targetDeclaration = parseTypealiasTarget(target); - if (targetDeclaration instanceof VariantDeclaration) { - if (((VariantDeclaration) targetDeclaration).isTagged()) { - throw new ParseException( - "Typealias of untagged variant is not permitted"); //$NON-NLS-1$ - } + if ((targetDeclaration instanceof VariantDeclaration) + && ((VariantDeclaration) targetDeclaration).isTagged()) { + throw new ParseException("Typealias of untagged variant is not permitted"); //$NON-NLS-1$ } String aliasString = parseTypealiasAlias(alias); @@ -1018,7 +1015,6 @@ public class IOStructGen { case CTFParser.IDENTIFIER: throw new ParseException("Identifier (" + child.getText() //$NON-NLS-1$ + ") not expected in the typealias target"); //$NON-NLS-1$ - /* break; */ default: childTypeError(child); break; @@ -1049,18 +1045,17 @@ public class IOStructGen { for (CommonTree typeDeclaratorNode : typeDeclaratorList) { StringBuilder identifierSB = new StringBuilder(); - IDeclaration type_declaration = parseTypeDeclarator( + IDeclaration typeDeclaration = parseTypeDeclarator( typeDeclaratorNode, typeSpecifierListNode, identifierSB); - if (type_declaration instanceof VariantDeclaration) { - if (((VariantDeclaration) type_declaration).isTagged()) { - throw new ParseException( - "Typealias of untagged variant is not permitted"); //$NON-NLS-1$ - } + if ((typeDeclaration instanceof VariantDeclaration) + && ((VariantDeclaration) typeDeclaration).isTagged()) { + throw new ParseException( + "Typealias of untagged variant is not permitted"); //$NON-NLS-1$ } getCurrentScope().registerType(identifierSB.toString(), - type_declaration); + typeDeclaration); } } @@ -1694,14 +1689,14 @@ public class IOStructGen { /** * Parses an enum declaration and returns the corresponding declaration. * - * @param _enum + * @param theEnum * An ENUM node. * @return The corresponding enum declaration. * @throws ParseException */ - private EnumDeclaration parseEnum(CommonTree _enum) throws ParseException { + private EnumDeclaration parseEnum(CommonTree theEnum) throws ParseException { - List children = _enum.getChildren(); + List children = theEnum.getChildren(); /* The return value */ EnumDeclaration enumDeclaration = null; @@ -1720,21 +1715,15 @@ public class IOStructGen { switch (child.getType()) { case CTFParser.ENUM_NAME: { CommonTree enumNameIdentifier = (CommonTree) child.getChild(0); - enumName = enumNameIdentifier.getText(); - break; } case CTFParser.ENUM_BODY: { - enumBody = child; - break; } case CTFParser.ENUM_CONTAINER_TYPE: { - containerTypeDeclaration = parseEnumContainerType(child); - break; } default: @@ -2232,7 +2221,6 @@ public class IOStructGen { case CTFParser.STRING: throw new ParseException( "CTF type found in createTypeSpecifierString"); //$NON-NLS-1$ - /* break; */ default: childTypeError(typeSpecifier); break; @@ -2386,8 +2374,7 @@ public class IOStructGen { String uuidstr = parseUnaryString(firstChild); try { - UUID uuid = UUID.fromString(uuidstr); - return uuid; + return UUID.fromString(uuidstr); } catch (IllegalArgumentException e) { throw new ParseException("Invalid format for UUID"); //$NON-NLS-1$ } diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/Messages.java b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/Messages.java index b8ace5b587..8b5a06fa7c 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/Messages.java +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/Messages.java @@ -22,6 +22,12 @@ public class Messages extends NLS { public static String IOStructGen_UnknownStreamAttributeWarning; public static String IOStructGen_UnknownIntegerAttributeWarning; + public static String TypeAlreadyDefined; + public static String StructAlreadyDefined; + public static String EnumAlreadyDefined; + public static String VariantAlreadyDefined; + public static String TraceDoesNotContainType; + static { // initialize resource bundle NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/messages.properties b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/messages.properties index e274854b98..256e44b97a 100644 --- a/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/messages.properties +++ b/org.eclipse.linuxtools.ctf.core/src/org/eclipse/linuxtools/internal/ctf/core/event/metadata/messages.properties @@ -8,8 +8,17 @@ # # Contributors: # Marc-Andre Laperle - Initial API and implementation +# Alexandre Montplaisir - Added strings from DeclarationScope ############################################################################### +#IOStructGen IOStructGen_UnknownTraceAttributeWarning=Unknown trace attribute: IOStructGen_UnknownStreamAttributeWarning=Unknown stream attribute: -IOStructGen_UnknownIntegerAttributeWarning=Unknown integer attribute: \ No newline at end of file +IOStructGen_UnknownIntegerAttributeWarning=Unknown integer attribute: + +# DeclarationScope +TypeAlreadyDefined=Type has already been defined +StructAlreadyDefined=Struct has already been defined +EnumAlreadyDefined=Enum has already been defined +VariantAlreadyDefined=Variant has already been defined +TraceDoesNotContainType=Trace does not contain type diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java index b5d6c8f22f..befd10461c 100644 --- a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java +++ b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfIterator.java @@ -101,7 +101,7 @@ public class CtfIterator extends CTFTraceReader implements ITmfContext, * @return CtfTmfEvent */ public CtfTmfEvent getCurrentEvent() { - final StreamInputReader top = super.prio.peek(); + final StreamInputReader top = super.getPrio().peek(); if (top != null) { return CtfTmfEventFactory.createEvent(top.getCurrentEvent(), top.getFilename(), ctfTmfTrace); -- 2.34.1