Ctf: remove circular initialization issue in LexicalScope
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 26 Mar 2015 15:53:51 +0000 (11:53 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 1 Apr 2015 01:50:53 +0000 (21:50 -0400)
Introduce ILexicalScope, an interface to make a scope.
May introduce performance regression, to be monitored

Change-Id: I1c0838e8190a665db8a2aaf99e974348d4f98da4
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/44607
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
27 files changed:
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/event/CTFEventDefinitionTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/scope/LexicalScopeTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamInputPacketIndexEntryTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/trace/CTFStreamInputTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/VariantDefinitionTest.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/EventDefinition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/EventHeaderScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/EventHeaderVScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/FieldsScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/IDefinitionScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/ILexicalScope.java [new file with mode: 0644]
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/LexicalScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/PacketHeaderScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/RootScope.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/Declaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/Definition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDefinition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/ScopedDefinition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDefinition.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/VariantDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInput.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFStreamInputPacketReader.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/trace/CTFTrace.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/EventDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderDefinition.java

index be48c95fae91ce54bfd4c668bd3cc9b5c60248b8..9ef88f695eac9f6d5ee0ab175193b6bb119a672e 100644 (file)
 
 package org.eclipse.tracecompass.ctf.core.tests.event;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.nio.ByteOrder;
 import java.util.ArrayList;
@@ -23,7 +23,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
 import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
 import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
@@ -78,10 +78,10 @@ public class CTFEventDefinitionTest {
 
         StructDeclaration pContextDec = new StructDeclaration(8);
 
-        StructDefinition sContext = new StructDefinition(streamContextDec, null, LexicalScope.STREAM_PACKET_CONTEXT.toString(), sFieldNames, sDefs);
-        StructDefinition eContext = new StructDefinition(eventContextDec, null, LexicalScope.STREAM_EVENT_CONTEXT.toString(), eFieldNames, eDefs);
-        StructDefinition pContext = new StructDefinition(pContextDec, null, LexicalScope.FIELDS.toString(), Collections.EMPTY_LIST, new Definition[0]);
-        StructDefinition fields = new StructDefinition(fDec, null, LexicalScope.FIELDS.toString(), fieldNames, fDefs);
+        StructDefinition sContext = new StructDefinition(streamContextDec, null, ILexicalScope.STREAM_PACKET_CONTEXT.getPath(), sFieldNames, sDefs);
+        StructDefinition eContext = new StructDefinition(eventContextDec, null, ILexicalScope.STREAM_EVENT_CONTEXT.getPath(), eFieldNames, eDefs);
+        StructDefinition pContext = new StructDefinition(pContextDec, null, ILexicalScope.FIELDS.getPath(), Collections.EMPTY_LIST, new Definition[0]);
+        StructDefinition fields = new StructDefinition(fDec, null, ILexicalScope.FIELDS.getPath(), fieldNames, fDefs);
 
         fixture.add(new EventDefinition(eventDeclaration, null, 100, null, null, null, null));
         fixture.add(new EventDefinition(eventDeclaration, null, 100, null, null, null, fields));
index 1a50adc114150d8a8cd1b58b1e3bca0975c565ce..d24da6b8812d2978369d9c998d8f1c6b49cbdeab 100644 (file)
 package org.eclipse.tracecompass.ctf.core.tests.scope;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
 import org.junit.Test;
 
@@ -29,8 +32,8 @@ public class LexicalScopeTest {
      * Root test
      */
     @Test
-    public void testRoot(){
-        LexicalScope scope = LexicalScope.ROOT;
+    public void testRoot() {
+        ILexicalScope scope = ILexicalScope.ROOT;
         assertNotNull(scope);
     }
 
@@ -38,9 +41,88 @@ public class LexicalScopeTest {
      * Test a more complex node
      */
     @Test
-    public void testComplexNode(){
-        LexicalScope scope = LexicalScope.STREAM_EVENT_CONTEXT;
+    public void testComplexNode() {
+        ILexicalScope scope = ILexicalScope.STREAM_EVENT_CONTEXT;
         assertEquals("context", scope.getName());
-        assertEquals("stream.event.context", scope.toString());
+        assertEquals("stream.event.context", scope.getPath());
+    }
+
+    /**
+     * Test that getChild returns the same items for event headers
+     */
+    @Test
+    public void testEventHeaders() {
+        ILexicalScope child = ILexicalScope.ROOT.getChild("event");
+        assertNotNull(child);
+        ILexicalScope scope2 = child.getChild("header");
+        ILexicalScope scope3 = ILexicalScope.ROOT.getChild("event.header");
+        assertEquals(ILexicalScope.EVENT_HEADER, scope2);
+        assertEquals(ILexicalScope.EVENT_HEADER, scope3);
+        // they should be the same
+        assert (ILexicalScope.EVENT_HEADER == scope2);
+
+        assertNotNull(scope2);
+        ILexicalScope id = scope2.getChild("id");
+        assertNotNull(id);
+        assert (ILexicalScope.EVENT_HEADER_ID == id);
+        ILexicalScope ts = scope2.getChild("v.timestamp");
+        ILexicalScope v = scope2.getChild("v");
+        assert (ILexicalScope.EVENT_HEADER_V_TIMESTAMP == ts);
+        assert (ILexicalScope.EVENT_HEADER_V == v);
+        assertNotNull(v);
+        ILexicalScope ts2 = v.getChild("timestamp");
+        assert (ILexicalScope.EVENT_HEADER_V_TIMESTAMP == ts2);
+        assertNotNull(v);
+        id = v.getChild("id");
+        assert (ILexicalScope.EVENT_HEADER_V_ID == id);
+        assertNotNull(v);
+        ILexicalScope other = v.getChild("other");
+        assertNull(other);
+    }
+
+    /**
+     * Test that getChild returns the same items for event headers
+     */
+    @Test
+    public void testFields() {
+        ILexicalScope child = ILexicalScope.ROOT.getChild("fields");
+        assertNotNull(child);
+        ILexicalScope scope2 = child.getChild("_ret");
+        ILexicalScope scope3 = child.getChild("_tid");
+        ILexicalScope empty = child.getChild("other");
+
+        assertEquals(ILexicalScope.FIELDS_RET, scope2);
+        // they should be the same
+        assert (ILexicalScope.FIELDS_RET == scope2);
+
+        assertEquals(ILexicalScope.FIELDS_TID, scope3);
+        // they should be the same
+        assert (ILexicalScope.FIELDS_TID == scope2);
+
+        assertNull(empty);
+    }
+
+    /**
+     * Check contexts are not equals
+     */
+    @Test
+    public void testNotEquals() {
+        assertNotEquals(ILexicalScope.CONTEXT, ILexicalScope.EVENT);
+        LexicalScope context = new LexicalScope(ILexicalScope.CONTEXT, "context");
+        LexicalScope otherContext = new LexicalScope(ILexicalScope.CONTEXT, "context2");
+        assertNotEquals(context, otherContext);
+        assertNotEquals(context, null);
+    }
+
+    /**
+     * Test to strings
+     */
+    @Test
+    public void testGetPath() {
+        ILexicalScope child = ILexicalScope.ROOT.getChild("fields");
+        assertNotNull(child);
+        ILexicalScope scope2 = child.getChild("_ret");
+        assertNotNull(scope2);
+        assertEquals("fields._ret", scope2.getPath());
     }
 }
index 0f358c8d8a9af169e7eeb55cff581ebc3ac9c038..ad9b4ebd306dafd31248871982aec46002584fe2 100644 (file)
@@ -22,7 +22,7 @@ import java.nio.ByteOrder;
 
 import org.eclipse.tracecompass.ctf.core.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Encoding;
 import org.eclipse.tracecompass.ctf.core.event.types.EnumDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.FloatDeclaration;
@@ -91,7 +91,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().put(("Test").getBytes());
         bb.getByteBuffer().put((byte) 0);
         bb.getByteBuffer().put((byte) 0);
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         StreamInputPacketIndexEntry sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
         assertNull(sipie.getTarget());
         assertEquals(100, sipie.getTimestampBegin());
@@ -120,7 +120,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().put(("Test").getBytes());
         bb.getByteBuffer().put((byte) 0);
         bb.getByteBuffer().put((byte) 0);
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         StreamInputPacketIndexEntry sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
         assertNull(sipie.getTarget());
         assertEquals(100, sipie.getTimestampBegin());
@@ -150,7 +150,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().put(("Test").getBytes());
         bb.getByteBuffer().put((byte) 0);
         bb.getByteBuffer().put((byte) 0);
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         StreamInputPacketIndexEntry sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
         assertNull(sipie.getTarget());
         assertEquals(100, sipie.getTimestampBegin());
@@ -178,7 +178,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().put(("Test").getBytes());
         bb.getByteBuffer().put((byte) 0);
         bb.getByteBuffer().put((byte) 0);
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         StreamInputPacketIndexEntry sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
         assertNull(sipie.getTarget());
         assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
@@ -205,7 +205,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().put(("Test66").getBytes());
         bb.getByteBuffer().put((byte) 0);
         bb.getByteBuffer().put((byte) 0);
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         StreamInputPacketIndexEntry sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 0);
         assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
@@ -232,7 +232,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         bb.getByteBuffer().putInt(0);
         bb.getByteBuffer().putInt(66);
         bb.getByteBuffer().putInt(300);
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         StreamInputPacketIndexEntry sipie = new StreamInputPacketIndexEntry(0, sdef, 128, 100);
         assertEquals(Long.MIN_VALUE, sipie.getTimestampBegin());
         assertEquals(Long.MAX_VALUE, sipie.getTimestampEnd());
@@ -259,7 +259,7 @@ public class CTFStreamInputPacketIndexEntryTest {
         @SuppressWarnings("null")
         BitBuffer bb = new BitBuffer(ByteBuffer.allocate(128));
 
-        StructDefinition sdef = sd.createDefinition(null, LexicalScope.PACKET_HEADER, bb);
+        StructDefinition sdef = sd.createDefinition(null, ILexicalScope.PACKET_HEADER, bb);
         assertEquals(expectedResult, new StreamInputPacketIndexEntry(0, sdef, 10000, 0).toString());
     }
 }
\ No newline at end of file
index 259a8311fd4c2be16c8ac5905f127f8bd8a2ece6..e778c30f6cee1f03de5162fb533d6cb14311f261 100644 (file)
@@ -96,7 +96,7 @@ public class CTFStreamInputTest {
      */
     @Test
     public void testGetPath() {
-        String result = fixture.getScopePath().toString();
+        String result = fixture.getScopePath().getPath();
         assertNotNull(result);
     }
 
index b330a876f2de8d0a4c85b55134f5b083d06cb87c..6f6a56dc6aaa4f49861b2f2748194028120b4fe9 100644 (file)
@@ -212,7 +212,7 @@ public class VariantDefinitionTest {
      */
     @Test
     public void testGetPath() {
-        String result = fixture.getScopePath().toString();
+        String result = fixture.getScopePath().getPath();
         assertNotNull(result);
     }
 
index 87730012d86d5ef1355125452d01333beed76403..16652b7b6d88c02e2e353183bc9d92aad48d3ec6 100644 (file)
@@ -17,6 +17,7 @@ import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
 import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
@@ -113,15 +114,18 @@ public final class EventDefinition implements IDefinitionScope {
     // Getters/Setters/Predicates
     // ------------------------------------------------------------------------
 
+    /**
+     * @since 1.0
+     */
     @Override
-    public LexicalScope getScopePath() {
+    public ILexicalScope getScopePath() {
         String eventName = fDeclaration.getName();
         if (eventName == null) {
             return null;
         }
-        LexicalScope myScope = LexicalScope.EVENT.getChild(eventName);
+        ILexicalScope myScope = ILexicalScope.EVENT.getChild(eventName);
         if (myScope == null) {
-            myScope = new LexicalScope(LexicalScope.EVENT, eventName);
+            myScope = new LexicalScope(ILexicalScope.EVENT, eventName);
         }
         return myScope;
     }
index f730dd731d584e62dde9ae5d0978fa611e5c2b77..1b370e26269fd5ff0077133c9edb3916426f6984 100644 (file)
@@ -22,17 +22,8 @@ import org.eclipse.jdt.annotation.Nullable;
  * @author Matthew Khouzam
  */
 @NonNullByDefault
-public class EventHeaderScope extends LexicalScope {
+public final class EventHeaderScope extends LexicalScope {
 
-    /**
-     * Event header id string
-     */
-    public static final LexicalScope EVENT_HEADER_ID = new LexicalScope(EVENT_HEADER, "id"); //$NON-NLS-1$
-
-    /**
-     * Event header v as in variant string
-     */
-    public static final LexicalScope EVENT_HEADER_V = new EventHeaderVScope(EVENT_HEADER, "v"); //$NON-NLS-1$
 
     /**
      * The scope constructor
@@ -42,13 +33,13 @@ public class EventHeaderScope extends LexicalScope {
      * @param name
      *            the name of the field
      */
-    public EventHeaderScope(LexicalScope parent, String name) {
+    EventHeaderScope(ILexicalScope parent, String name) {
         super(parent, name);
     }
 
     @Override
     @Nullable
-    public LexicalScope getChild(String name) {
+    public ILexicalScope getChild(String name) {
         if (name.equals(EVENT_HEADER_ID.getName())) {
             return EVENT_HEADER_ID;
         }
@@ -59,7 +50,7 @@ public class EventHeaderScope extends LexicalScope {
     }
 
     @Override
-    public String toString() {
+    public String getPath() {
         return "event.header"; //$NON-NLS-1$
     }
 
index d73adf5fc9b64843bda4550ddad728d7d8cf9a4d..5d3c2420d9d3603324248e7b94b341a55528e885 100644 (file)
@@ -22,16 +22,7 @@ import org.eclipse.jdt.annotation.Nullable;
  * @author Matthew Khouzam
  */
 @NonNullByDefault
-public class EventHeaderVScope extends LexicalScope {
-
-    /**
-     * Packet header v id string
-     */
-    public static final LexicalScope PACKET_HEADER_V_ID = new LexicalScope(PACKET_HEADER, "id"); //$NON-NLS-1$
-    /**
-     * Packet header v timestamp string
-     */
-    public static final LexicalScope PACKET_HEADER_V_TIMESTAMP = new LexicalScope(PACKET_HEADER, "timestamp"); //$NON-NLS-1$
+public final class EventHeaderVScope extends LexicalScope {
 
     /**
      * The scope constructor
@@ -41,18 +32,18 @@ public class EventHeaderVScope extends LexicalScope {
      * @param name
      *            the name of the field
      */
-    public EventHeaderVScope(LexicalScope parent, String name) {
+    EventHeaderVScope(ILexicalScope parent, String name) {
         super(parent, name);
     }
 
     @Override
     @Nullable
-    public LexicalScope getChild(String name) {
-        if (name.equals(PACKET_HEADER_V_TIMESTAMP.getName())) {
-            return PACKET_HEADER_V_TIMESTAMP;
+    public ILexicalScope getChild(String name) {
+        if (name.equals(EVENT_HEADER_V_TIMESTAMP.getName())) {
+            return EVENT_HEADER_V_TIMESTAMP;
         }
-        if (name.equals(PACKET_HEADER_V_ID.getName())) {
-            return PACKET_HEADER_V_ID;
+        if (name.equals(EVENT_HEADER_V_ID.getName())) {
+            return EVENT_HEADER_V_ID;
         }
         return super.getChild(name);
     }
index ae766c90a765b7cf47ba6ee2c8095e56ef837760..982eb41a4c88ab94d3119ce36ef54cd1ed02fa0f 100644 (file)
@@ -21,17 +21,7 @@ import org.eclipse.jdt.annotation.Nullable;
  * @author Matthew Khouzam
  */
 @NonNullByDefault
-public class FieldsScope extends LexicalScope {
-
-    /**
-     * ret field
-     */
-    public static final LexicalScope FIELDS_RET = new LexicalScope(FIELDS, "_ret"); //$NON-NLS-1$
-
-    /**
-     * tid field
-     */
-    public static final LexicalScope FIELDS_TID = new LexicalScope(FIELDS, "_tid"); //$NON-NLS-1$
+public final class FieldsScope extends LexicalScope {
 
     /**
      * The scope constructor
@@ -41,13 +31,13 @@ public class FieldsScope extends LexicalScope {
      * @param name
      *            the name of the field
      */
-    public FieldsScope(LexicalScope parent, String name) {
+    FieldsScope(ILexicalScope parent, String name) {
         super(parent, name);
     }
 
     @Override
     @Nullable
-    public LexicalScope getChild(String name) {
+    public ILexicalScope getChild(String name) {
         if (name.equals(FIELDS_RET.getName())) {
             return FIELDS_RET;
         }
index 099e788844b2736f115eac13d712f52f0a8c8461..94648b608319a15cc32dee0227f5377c74f08d89 100644 (file)
@@ -27,8 +27,9 @@ public interface IDefinitionScope {
      * Gets the path in a C style for the scope.
      *
      * @return the path
+     * @since 1.0
      */
-    LexicalScope getScopePath();
+    ILexicalScope getScopePath();
 
     /**
      * Looks up in this definition scope.
diff --git a/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/ILexicalScope.java b/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/scope/ILexicalScope.java
new file mode 100644 (file)
index 0000000..cfaf2a6
--- /dev/null
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tracecompass.ctf.core.event.scope;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+
+/**
+ * @since 1.0
+ */
+@NonNullByDefault
+public interface ILexicalScope {
+    /**
+     * Empty string
+     */
+    ILexicalScope ROOT = new RootScope();
+
+    /**
+     * Trace string
+     */
+    ILexicalScope TRACE = new LexicalScope(ROOT, "trace"); //$NON-NLS-1$
+    /**
+     * Env string
+     */
+    ILexicalScope ENV = new LexicalScope(ROOT, "env"); //$NON-NLS-1$
+    /**
+     * Stream string
+     */
+    LexicalScope STREAM = new LexicalScope(ROOT, "stream"); //$NON-NLS-1$
+    /**
+     * Event string
+     */
+    LexicalScope EVENT = new LexicalScope(ROOT, "event"); //$NON-NLS-1$
+    /**
+     * Variant string
+     */
+    ILexicalScope VARIANT = new LexicalScope(ROOT, "variant"); //$NON-NLS-1$
+    /**
+     * packet string
+     */
+    LexicalScope PACKET = new LexicalScope(ROOT, "packet"); //$NON-NLS-1$
+    /**
+     * Packet header string
+     */
+    LexicalScope PACKET_HEADER = new PacketHeaderScope();
+
+    /**
+     * Packet header v id string
+     */
+    ILexicalScope EVENT_HEADER_V_ID = new LexicalScope(PACKET_HEADER, "id"); //$NON-NLS-1$
+    /**
+     * Packet header v timestamp string
+     */
+    ILexicalScope EVENT_HEADER_V_TIMESTAMP = new LexicalScope(PACKET_HEADER, "timestamp"); //$NON-NLS-1$
+
+    /**
+     * Stream packet scope
+     */
+    LexicalScope STREAM_PACKET = new LexicalScope(STREAM, "packet"); //$NON-NLS-1$
+    /**
+     * Stream Packet header string
+     */
+    ILexicalScope STREAM_PACKET_CONTEXT = new LexicalScope(STREAM_PACKET, "context"); //$NON-NLS-1$
+    /**
+     * Trace packet scope
+     */
+    LexicalScope TRACE_PACKET = new LexicalScope(TRACE, "packet"); //$NON-NLS-1$
+    /**
+     * Stream event scope
+     */
+    LexicalScope STREAM_EVENT = new LexicalScope(STREAM, "event"); //$NON-NLS-1$
+    /**
+     * Trace packet header string
+     */
+    ILexicalScope TRACE_PACKET_HEADER = new LexicalScope(TRACE_PACKET, "header"); //$NON-NLS-1$
+    /**
+     * Stream event context
+     */
+    ILexicalScope STREAM_EVENT_CONTEXT = new LexicalScope(STREAM_EVENT, "context"); //$NON-NLS-1$
+    /**
+     * Stream event header
+     */
+    ILexicalScope STREAM_EVENT_HEADER = new LexicalScope(STREAM_EVENT, "header"); //$NON-NLS-1$
+    /**
+     * Context of an event
+     */
+    LexicalScope CONTEXT = new LexicalScope(ROOT, "context"); //$NON-NLS-1$
+    /**
+     * Event Header scope
+     */
+    ILexicalScope EVENT_HEADER = new EventHeaderScope(EVENT, "header"); //$NON-NLS-1$
+
+    /**
+     * Event header id string
+     */
+    ILexicalScope EVENT_HEADER_ID = new LexicalScope(EVENT_HEADER, "id"); //$NON-NLS-1$
+
+    /**
+     * Event header v as in variant string
+     */
+    ILexicalScope EVENT_HEADER_V = new EventHeaderVScope(EVENT_HEADER, "v"); //$NON-NLS-1$
+
+    /**
+     * Fields in an event
+     */
+    ILexicalScope FIELDS = new FieldsScope(ROOT, "fields"); //$NON-NLS-1$
+
+    /**
+     * ret field
+     */
+    ILexicalScope FIELDS_RET = new LexicalScope(FIELDS, "_ret"); //$NON-NLS-1$
+
+    /**
+     * tid field
+     */
+    ILexicalScope FIELDS_TID = new LexicalScope(FIELDS, "_tid"); //$NON-NLS-1$
+
+    /**
+     * Get the name
+     *
+     * @return the name
+     */
+    String getName();
+
+    /**
+     * Gets a child of a given name
+     *
+     * @param name
+     *            the child
+     * @return the scope, can be null
+     */
+    @Nullable
+    ILexicalScope getChild(String name);
+
+    // -------------------------------------------------------------------------
+    // helpers
+    // -------------------------------------------------------------------------
+
+    /**
+     * Adds a child lexical scope
+     *
+     * @param name
+     *            the name of the child
+     * @param child
+     *            the child
+     */
+    void addChild(String name, ILexicalScope child);
+
+    /**
+     * Get the path of the scope
+     *
+     * @return the path of the scope
+     */
+    String getPath();
+
+
+}
\ No newline at end of file
index a0935cdcfb81734bd55d3b5aaf094425a518e125..bd13dfd72878193deee41875a905c7b9ff9907d8 100644 (file)
 
 package org.eclipse.tracecompass.ctf.core.event.scope;
 
-import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
-
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 
-import com.google.common.base.Joiner;
-
 /**
  * A node of a lexical scope
  *
  * @author Matthew Khouzam
  */
 @NonNullByDefault
-public class LexicalScope implements Comparable<LexicalScope> {
-    /**
-     * Empty string
-     */
-    public static final LexicalScope ROOT = new RootScope();
-
-    /**
-     * Trace string
-     */
-    public static final LexicalScope TRACE = new LexicalScope(ROOT, "trace"); //$NON-NLS-1$
-
-    /**
-     * Env string
-     */
-    public static final LexicalScope ENV = new LexicalScope(ROOT, "env"); //$NON-NLS-1$
-
-    /**
-     * Stream string
-     */
-    public static final LexicalScope STREAM = new LexicalScope(ROOT, "stream"); //$NON-NLS-1$
-
-    /**
-     * Event string
-     */
-    public static final LexicalScope EVENT = new LexicalScope(ROOT, "event"); //$NON-NLS-1$
-
-    /**
-     * Variant string
-     */
-    public static final LexicalScope VARIANT = new LexicalScope(ROOT, "variant"); //$NON-NLS-1$
-
-    /**
-     * packet string
-     */
-    public static final LexicalScope PACKET = new LexicalScope(ROOT, "packet"); //$NON-NLS-1$
-
-    /**
-     * Packet header string
-     */
-    public static final LexicalScope PACKET_HEADER = new PacketHeaderScope();
-
-    /**
-     * Stream packet scope
-     */
-    public static final LexicalScope STREAM_PACKET = new LexicalScope(STREAM, "packet"); //$NON-NLS-1$
-
-    /**
-     * Stream Packet header string
-     */
-    public static final LexicalScope STREAM_PACKET_CONTEXT = new LexicalScope(STREAM_PACKET, "context"); //$NON-NLS-1$
-
-    /**
-     * Trace packet scope
-     */
-    public static final LexicalScope TRACE_PACKET = new LexicalScope(TRACE, "packet"); //$NON-NLS-1$
-
-    /**
-     * Stream event scope
-     */
-    public static final LexicalScope STREAM_EVENT = new LexicalScope(STREAM, "event"); //$NON-NLS-1$
-
-    /**
-     * Trace packet header string
-     */
-    public static final LexicalScope TRACE_PACKET_HEADER = new LexicalScope(TRACE_PACKET, "header"); //$NON-NLS-1$
-
-    /**
-     * Stream event context
-     */
-    public static final LexicalScope STREAM_EVENT_CONTEXT = new LexicalScope(STREAM_EVENT, "context"); //$NON-NLS-1$
-
-    /**
-     * Stream event header
-     */
-    public static final LexicalScope STREAM_EVENT_HEADER = new LexicalScope(STREAM_EVENT, "header"); //$NON-NLS-1$
-
-    /**
-     * Event header
-     */
-    public static final LexicalScope EVENT_HEADER = new EventHeaderScope(EVENT, "header"); //$NON-NLS-1$
-
-    /**
-     * Fields in an event
-     */
-    public static final LexicalScope FIELDS = new FieldsScope(ROOT, "fields"); //$NON-NLS-1$
-
-    /**
-     * Context of an event
-     */
-    public static final LexicalScope CONTEXT = new LexicalScope(ROOT, "context"); //$NON-NLS-1$
-
-    /**
-     * Sorted list of parent paths
-     */
-    public static final LexicalScope[] PARENT_PATHS = {
-            ROOT,
-            CONTEXT,
-            FIELDS,
-            PACKET_HEADER,
-            STREAM_EVENT_CONTEXT,
-            STREAM_EVENT_HEADER,
-            STREAM_PACKET_CONTEXT,
-            TRACE_PACKET_HEADER
-    };
-
+public class LexicalScope implements ILexicalScope {
     private int hash = 0;
     private final String fName;
     private final String fPath;
-    private final Map<String, LexicalScope> fChildren = new ConcurrentHashMap<>();
+    private final Map<String, ILexicalScope> fChildren = new ConcurrentHashMap<>();
+
+    /**
+     * Hidden constructor for the root node only
+     *
+     * @since 1.0
+     */
+    protected LexicalScope() {
+        fPath = ""; //$NON-NLS-1$
+        fName = ""; //$NON-NLS-1$
+    }
 
     /**
      * The scope constructor
@@ -145,77 +46,47 @@ public class LexicalScope implements Comparable<LexicalScope> {
      *            The parent node, can be null, but shouldn't
      * @param name
      *            the name of the field
+     * @since 1.0
      */
-    public LexicalScope(@Nullable LexicalScope parent, String name) {
+    public LexicalScope(ILexicalScope parent, String name) {
         fName = name;
-        if (parent != null) {
-            @NonNull String pathString = checkNotNull(Joiner.on('.').skipNulls().join(parent.fPath, parent.getName()));
-            /*
-             * if joiner return null, we get an NPE... so we won't assign fPath
-             * to null
-             */
-            if (pathString.startsWith(".")) { //$NON-NLS-1$
-                /*
-                 * substring throws an exception or returns a string, it won't
-                 * return null
-                 */
-                pathString = checkNotNull(pathString.substring(1));
-            }
-            fPath = pathString;
-            parent.addChild(fName, this);
-        } else {
-            fPath = ""; //$NON-NLS-1$
-        }
+        fPath = parent.getPath().isEmpty() ? fName : parent.getPath() + '.' + fName;
+        parent.addChild(name, this);
     }
 
     /**
-     * Adds a child lexical scope
-     *
-     * @param name
-     *            the name of the child
-     * @param child
-     *            the child
+     * @since 1.0
      */
-    private void addChild(String name, LexicalScope child) {
+    @Override
+    public void addChild(String name, ILexicalScope child) {
         fChildren.put(name, child);
     }
 
-    /**
-     * Get the name
-     *
-     * @return the name
-     */
+    @Override
     public String getName() {
         return fName;
     }
 
     /**
-     * Gets a child of a given name
-     *
-     * @param name
-     *            the child
-     * @return the scope, can be null
+     * @since 1.0
      */
-    @Nullable
-    public LexicalScope getChild(String name) {
+    @Override
+    public @Nullable ILexicalScope getChild(String name) {
         return fChildren.get(name);
     }
 
+    /**
+     * @since 1.0
+     */
     @Override
-    public String toString() {
-        return (fPath.isEmpty() ? fName : fPath + '.' + fName);
+    public String getPath() {
+        return fPath;
     }
 
+    // for debugging purposes
     @Override
-    public int compareTo(@Nullable LexicalScope other) {
-        if (other == null) {
-            throw new IllegalArgumentException();
-        }
-        int comp = fPath.compareTo(other.fPath);
-        if (comp == 0) {
-            return fName.compareTo(other.fName);
-        }
-        return comp;
+    public String toString() {
+        return getPath();
     }
 
     @Override
index 1aafcae7877e4fcfef2ddef6ee0e9f31c1dba50b..e8dc90c3f5ef1a9096e6f73314347a9bdbeb5b65 100644 (file)
@@ -31,7 +31,7 @@ public class PacketHeaderScope extends LexicalScope {
     }
 
     @Override
-    public String toString() {
+    public String getPath() {
         return "packet.header"; //$NON-NLS-1$
     }
 
index 5dc5b939b9f33a89660b6841b4c62c755eb3750d..76a209487303105ffc09eb4248bf2f3518885007 100644 (file)
@@ -22,40 +22,40 @@ import org.eclipse.jdt.annotation.Nullable;
  * @author Matthew Khouzam
  */
 @NonNullByDefault
-public class RootScope extends LexicalScope {
+public final class RootScope extends LexicalScope {
 
     /**
      * The scope constructor
      */
     public RootScope() {
-        super(null, ""); //$NON-NLS-1$
+        super();
     }
 
     @Override
     @Nullable
-    public LexicalScope getChild(String name) {
+    public ILexicalScope getChild(String name) {
         /*
          * This happens ~40 % of the time
          */
-        if (name.equals(EVENT_HEADER.toString())) {
+        if (name.equals(EVENT_HEADER.getPath())) {
             return EVENT_HEADER;
         }
         /*
          * This happens ~30 % of the time
          */
-        if (name.equals(FIELDS.toString())) {
+        if (name.equals(FIELDS.getPath())) {
             return FIELDS;
         }
         /*
          * This happens ~30 % of the time
          */
-        if (name.equals(CONTEXT.toString())) {
+        if (name.equals(CONTEXT.getPath())) {
             return CONTEXT;
         }
         /*
          * This happens ~1 % of the time
          */
-        if (name.equals(PACKET_HEADER.toString())) {
+        if (name.equals(PACKET_HEADER.getPath())) {
             return PACKET_HEADER;
         }
         return super.getChild(name);
index 6517d52834db407388bd4c3bc0d350b10ba42744..018acd24b149718f76fb9439aeedfd612c9f45bb 100644 (file)
@@ -15,6 +15,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
 
 /**
@@ -25,23 +26,26 @@ import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
  */
 public abstract class Declaration implements IDeclaration {
 
+    /**
+     * @since 1.0
+     */
     @Override
-    public LexicalScope getPath(IDefinitionScope definitionScope, @NonNull String fieldName) {
+    public ILexicalScope getPath(IDefinitionScope definitionScope, @NonNull String fieldName) {
         if (definitionScope != null) {
-            final LexicalScope parentPath = definitionScope.getScopePath();
+            final ILexicalScope parentPath = definitionScope.getScopePath();
             if (parentPath != null) {
-                LexicalScope myScope = parentPath.getChild(fieldName);
+                ILexicalScope myScope = parentPath.getChild(fieldName);
                 if (myScope == null) {
                     myScope = new LexicalScope(parentPath, fieldName);
                 }
                 return myScope;
             }
         }
-        LexicalScope child = LexicalScope.ROOT.getChild(fieldName);
+        ILexicalScope child = ILexicalScope.ROOT.getChild(fieldName);
         if (child != null) {
             return child;
         }
-        return new LexicalScope(LexicalScope.ROOT, fieldName);
+        return new LexicalScope(ILexicalScope.ROOT, fieldName);
     }
 
     /**
index 9e5c4fcff40bfdbbd64391981f56101e45fe2e30..425ca18efce94c5d8d29e0903e8a9b76eefb5923 100644 (file)
@@ -14,7 +14,7 @@ package org.eclipse.tracecompass.ctf.core.event.types;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 
 /**
  * A CTF definition
@@ -40,7 +40,7 @@ public abstract class Definition implements IDefinition {
     private final String fFieldName;
 
     /** The complete path of this field */
-    private final @NonNull LexicalScope fPath;
+    private final @NonNull ILexicalScope fPath;
 
     private final IDefinitionScope fDefinitionScope;
 
@@ -82,8 +82,9 @@ public abstract class Definition implements IDefinition {
      *
      * @param scope
      *            the scope
+     * @since 1.0
      */
-    public Definition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull LexicalScope scope) {
+    public Definition(@NonNull IDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, @NonNull ILexicalScope scope) {
         fDeclaration = declaration;
         fDefinitionScope = definitionScope;
         fFieldName = fieldName;
@@ -103,8 +104,11 @@ public abstract class Definition implements IDefinition {
         return fFieldName;
     }
 
+    /**
+     * @since 1.0
+     */
     @Override
-    public LexicalScope getScopePath() {
+    public ILexicalScope getScopePath() {
         return fPath;
     }
 
@@ -131,6 +135,6 @@ public abstract class Definition implements IDefinition {
 
     @Override
     public String toString() {
-        return fPath.toString() + '[' + Integer.toHexString(hashCode()) + ']';
+        return fPath.getPath() + '[' + Integer.toHexString(hashCode()) + ']';
     }
 }
index 7cd52d17710847939f113736bf5e61c637716db4..be778153cf0d20fa4b07ba66f0f11e51cdf80901 100644 (file)
@@ -16,7 +16,7 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 
 /**
  * A CTF data type declaration.
@@ -57,8 +57,9 @@ public interface IDeclaration {
      * @param fieldName
      *            the name of the definition
      * @return the path of the definition
+     * @since 1.0
      */
-    @NonNull LexicalScope getPath(IDefinitionScope definitionScope, @NonNull String fieldName);
+    @NonNull ILexicalScope getPath(IDefinitionScope definitionScope, @NonNull String fieldName);
 
     /**
      * The minimum alignment. if the field is 32 bits, the definition will pad
index e7049093c79dd1c419dfb48795462ac07f0d25d7..29b793c91d4865d5d7b8c46dae3eb7adad8d16aa 100644 (file)
@@ -13,7 +13,7 @@
 package org.eclipse.tracecompass.ctf.core.event.types;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 
 /**
  * Interface for data definitions. A definition is when a value is given to a
@@ -28,8 +28,9 @@ public interface IDefinition {
      * Get the complete path of this field.
      *
      * @return The path
+     * @since 1.0
      */
-    LexicalScope getScopePath();
+    ILexicalScope getScopePath();
 
     /**
      * Get the declaration of this definition
index ed4e449673f12bada5b9b7c1dea3445093a0a675..0254e9ae1d15c9a419f2efcf441c250c1390fc73 100644 (file)
@@ -15,7 +15,7 @@ package org.eclipse.tracecompass.ctf.core.event.types;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 
 /**
  * Scoped defintion. a defintion where you can lookup various datatypes
@@ -54,8 +54,9 @@ public abstract class ScopedDefinition extends Definition implements IDefinition
      *            the field name
      * @param scope
      *            the lexical scope
+     * @since 1.0
      */
-    public ScopedDefinition(StructDeclaration declaration, @Nullable IDefinitionScope definitionScope, String fieldName, LexicalScope scope) {
+    public ScopedDefinition(StructDeclaration declaration, @Nullable IDefinitionScope definitionScope, String fieldName, ILexicalScope scope) {
         super(declaration, definitionScope, fieldName, scope);
     }
 
index 86b31e8376cedca94706c866a25d65ffd81ef06e..809a26aff3fcbc0f794a60744d13e890a6c0f122 100644 (file)
@@ -26,7 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 
 /**
  * A CTF structure declaration.
@@ -180,9 +180,10 @@ public class StructDeclaration extends Declaration {
      * @return a reference to the definition
      * @throws CTFReaderException
      *             error in reading
+     * @since 1.0
      */
     public StructDefinition createDefinition(IDefinitionScope definitionScope,
-            LexicalScope fieldScope, @NonNull BitBuffer input) throws CTFReaderException {
+            ILexicalScope fieldScope, @NonNull BitBuffer input) throws CTFReaderException {
         alignRead(input);
         final Definition[] myFields = new Definition[fFieldMap.size()];
 
index 5571a39e33eb84f5b14a420b661b2ebbe6c6db69..6e9d3b30b020cba0e7c74a9660ff4794d599d93a 100644 (file)
@@ -19,7 +19,7 @@ import java.util.Map;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
@@ -122,9 +122,10 @@ public final class StructDefinition extends ScopedDefinition implements IComposi
      *            the list of fields
      * @param definitions
      *            the definitions
+     * @since 1.0
      */
     public StructDefinition(@NonNull StructDeclaration declaration,
-            IDefinitionScope definitionScope, @NonNull LexicalScope scope,
+            IDefinitionScope definitionScope, @NonNull ILexicalScope scope,
             @NonNull String structFieldName, @NonNull Iterable<String> fieldNames, Definition[] definitions) {
         super(declaration, definitionScope, structFieldName, scope);
         fFieldNames = ImmutableList.copyOf(fieldNames);
index caef959861b83ae26908ae6d96a972b54d020d36..f4907068c38e34e0881af4f3a390d94f8887d232 100644 (file)
@@ -128,7 +128,7 @@ public class VariantDeclaration extends Declaration {
         fDeclarationToPopulate = fFields.get(varFieldName);
         if (fDeclarationToPopulate == null) {
             throw new CTFReaderException("Unknown enum selector for variant " + //$NON-NLS-1$
-                    definitionScope.getScopePath().toString());
+                    definitionScope.getScopePath().getPath());
         }
         Definition fieldValue = fDeclarationToPopulate.createDefinition(definitionScope, fieldName, input);
         return new VariantDefinition(this, definitionScope, varFieldName, fieldName, fieldValue);
index c6e05c3249e2bc692dadadc781965ddc95c0fcb2..0c8c6cbc1af8bcdf289a05ac09b691f38fd05811 100644 (file)
@@ -25,6 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.eclipse.tracecompass.ctf.core.CTFReaderException;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
 import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
@@ -175,7 +176,7 @@ public class CTFStreamInput implements IDefinitionScope {
      */
     @Override
     public LexicalScope getScopePath() {
-        return LexicalScope.STREAM;
+        return ILexicalScope.STREAM;
     }
 
     // ------------------------------------------------------------------------
@@ -311,7 +312,7 @@ public class CTFStreamInput implements IDefinitionScope {
     private StructDefinition parseTracePacketHeader(
             BitBuffer bitBuffer) throws CTFReaderException {
 
-        StructDefinition tracePacketHeaderDef = fTracePacketHeaderDecl.createDefinition(fStream.getTrace(), LexicalScope.TRACE_PACKET_HEADER, bitBuffer);
+        StructDefinition tracePacketHeaderDef = fTracePacketHeaderDecl.createDefinition(fStream.getTrace(), ILexicalScope.TRACE_PACKET_HEADER, bitBuffer);
 
         /*
          * Check the CTF magic number
@@ -357,7 +358,7 @@ public class CTFStreamInput implements IDefinitionScope {
     private StreamInputPacketIndexEntry parsePacketContext(long dataOffsetBits, long fileSizeBytes,
             BitBuffer bitBuffer) throws CTFReaderException {
         StreamInputPacketIndexEntry packetIndex;
-        StructDefinition streamPacketContextDef = fStreamPacketContextDecl.createDefinition(this, LexicalScope.STREAM_PACKET_CONTEXT, bitBuffer);
+        StructDefinition streamPacketContextDef = fStreamPacketContextDecl.createDefinition(this, ILexicalScope.STREAM_PACKET_CONTEXT, bitBuffer);
         packetIndex = new StreamInputPacketIndexEntry(dataOffsetBits, streamPacketContextDef, fileSizeBytes, fLostSoFar);
         fLostSoFar = packetIndex.getLostEvents() + fLostSoFar;
         setTimestampEnd(packetIndex.getTimestampEnd());
index 96eb65cb39f448070749ed85f50d2bb9deba8be4..3dd76d2d56d606b13364647548d04c1906e1e5ba 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
 import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
 import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
@@ -135,7 +136,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
      *             out of bounds exception or such
      */
     public StructDefinition getEventContextDefinition(@NonNull BitBuffer input) throws CTFReaderException {
-        return fStreamEventContextDecl.createDefinition(fStreamInputReader.getStreamInput(), LexicalScope.STREAM_EVENT_CONTEXT, input);
+        return fStreamEventContextDecl.createDefinition(fStreamInputReader.getStreamInput(), ILexicalScope.STREAM_EVENT_CONTEXT, input);
     }
 
     /**
@@ -153,7 +154,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
         if (!(fStreamEventHeaderDecl instanceof StructDeclaration)) {
             throw new IllegalStateException("Definition is not a struct definition, this is a deprecated method that doesn't work so well, stop using it."); //$NON-NLS-1$
         }
-        return ((StructDeclaration) fStreamEventHeaderDecl).createDefinition(this, LexicalScope.STREAM_EVENT_HEADER, input);
+        return ((StructDeclaration) fStreamEventHeaderDecl).createDefinition(this, ILexicalScope.STREAM_EVENT_HEADER, input);
     }
 
     /**
@@ -166,7 +167,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
      *             out of bounds exception or such
      */
     public StructDefinition getStreamPacketContextDefinition(@NonNull BitBuffer input) throws CTFReaderException {
-        return fStreamPacketContextDecl.createDefinition(fStreamInputReader.getStreamInput(), LexicalScope.STREAM_PACKET_CONTEXT, input);
+        return fStreamPacketContextDecl.createDefinition(fStreamInputReader.getStreamInput(), ILexicalScope.STREAM_PACKET_CONTEXT, input);
     }
 
     /**
@@ -179,7 +180,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
      *             out of bounds exception or such
      */
     public StructDefinition getTracePacketHeaderDefinition(@NonNull BitBuffer input) throws CTFReaderException {
-        return fTracePacketHeaderDecl.createDefinition(fStreamInputReader.getStreamInput().getStream().getTrace(), LexicalScope.TRACE_PACKET_HEADER, input);
+        return fTracePacketHeaderDecl.createDefinition(fStreamInputReader.getStreamInput().getStream().getTrace(), ILexicalScope.TRACE_PACKET_HEADER, input);
     }
 
     /**
@@ -214,7 +215,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
 
     @Override
     public LexicalScope getScopePath() {
-        return LexicalScope.PACKET;
+        return ILexicalScope.PACKET;
     }
 
     // ------------------------------------------------------------------------
@@ -380,7 +381,7 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
                 eventID = ehd.getId();
                 timestamp = calculateTimestamp(ehd.getTimestamp(), ehd.getTimestampLength());
             } else {
-                fCurrentStreamEventHeaderDef = ((StructDeclaration) fStreamEventHeaderDecl).createDefinition(null, LexicalScope.EVENT_HEADER, currentBitBuffer);
+                fCurrentStreamEventHeaderDef = ((StructDeclaration) fStreamEventHeaderDecl).createDefinition(null, ILexicalScope.EVENT_HEADER, currentBitBuffer);
                 StructDefinition StructEventHeaderDef = (StructDefinition) fCurrentStreamEventHeaderDef;
                 /* Check for the event id. */
                 IDefinition idDef = StructEventHeaderDef.lookupDefinition("id"); //$NON-NLS-1$
@@ -498,10 +499,10 @@ public class CTFStreamInputPacketReader implements IDefinitionScope, AutoCloseab
 
     @Override
     public Definition lookupDefinition(String lookupPath) {
-        if (lookupPath.equals(LexicalScope.STREAM_PACKET_CONTEXT.toString())) {
+        if (lookupPath.equals(ILexicalScope.STREAM_PACKET_CONTEXT.getPath())) {
             return (Definition) fCurrentStreamPacketContextDef;
         }
-        if (lookupPath.equals(LexicalScope.TRACE_PACKET_HEADER.toString())) {
+        if (lookupPath.equals(ILexicalScope.TRACE_PACKET_HEADER.getPath())) {
             return (Definition) fCurrentTracePacketHeaderDef;
         }
         return null;
index e1eee14f701206e2e467880f4ab9332643ec4554..235618d7cdc9d79f6d19e96b2a9f8d0ccb41346c 100644 (file)
@@ -39,7 +39,7 @@ import org.eclipse.tracecompass.ctf.core.event.CTFClock;
 import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
 import org.eclipse.tracecompass.ctf.core.event.types.IDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
@@ -466,7 +466,7 @@ public class CTFTrace implements IDefinitionScope {
 
             if (fPacketHeaderDecl != null) {
                 /* Read the packet header */
-                fPacketHeaderDef = fPacketHeaderDecl.createDefinition(this, LexicalScope.PACKET_HEADER, streamBitBuffer);
+                fPacketHeaderDef = fPacketHeaderDecl.createDefinition(this, ILexicalScope.PACKET_HEADER, streamBitBuffer);
             }
         } catch (IOException e) {
             /* Shouldn't happen at this stage if every other check passed */
@@ -530,9 +530,12 @@ public class CTFTrace implements IDefinitionScope {
     // IDefinitionScope
     // ------------------------------------------------------------------------
 
+    /**
+     * @since 1.0
+     */
     @Override
-    public LexicalScope getScopePath() {
-        return LexicalScope.TRACE;
+    public ILexicalScope getScopePath() {
+        return ILexicalScope.TRACE;
     }
 
     /**
@@ -545,7 +548,7 @@ public class CTFTrace implements IDefinitionScope {
      */
     @Override
     public Definition lookupDefinition(String lookupPath) {
-        if (lookupPath.equals(LexicalScope.TRACE_PACKET_HEADER.toString())) {
+        if (lookupPath.equals(ILexicalScope.TRACE_PACKET_HEADER.getPath())) {
             return fPacketHeaderDef;
         }
         return null;
index 5cd2a153bdeb72bd07efa26ecb631a050e5c9433..9fbb31cae36b972b5f5cddbcd6b477ac87619333 100644 (file)
@@ -22,7 +22,7 @@ import org.eclipse.tracecompass.ctf.core.CTFStrings;
 import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
 import org.eclipse.tracecompass.ctf.core.event.IEventDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Declaration;
 import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
@@ -90,10 +90,10 @@ public class EventDeclaration implements IEventDeclaration {
     @Override
     public EventDefinition createDefinition(CTFStreamInputReader streamInputReader, @NonNull BitBuffer input, long timestamp) throws CTFReaderException {
         StructDeclaration streamEventContextDecl = streamInputReader.getStreamEventContextDecl();
-        StructDefinition streamEventContext = streamEventContextDecl != null ? streamEventContextDecl.createDefinition(fStream.getTrace(), LexicalScope.STREAM_EVENT_CONTEXT, input) : null;
+        StructDefinition streamEventContext = streamEventContextDecl != null ? streamEventContextDecl.createDefinition(fStream.getTrace(), ILexicalScope.STREAM_EVENT_CONTEXT, input) : null;
         StructDefinition packetContext = streamInputReader.getPacketReader().getCurrentPacketEventHeader();
-        StructDefinition eventContext = fContext != null ? fContext.createDefinition(fStream.getTrace(), LexicalScope.CONTEXT, input) : null;
-        StructDefinition eventPayload = fFields != null ? fFields.createDefinition(fStream.getTrace(), LexicalScope.FIELDS, input) : null;
+        StructDefinition eventContext = fContext != null ? fContext.createDefinition(fStream.getTrace(), ILexicalScope.CONTEXT, input) : null;
+        StructDefinition eventPayload = fFields != null ? fFields.createDefinition(fStream.getTrace(), ILexicalScope.FIELDS, input) : null;
 
         // a bit lttng specific
         // CTF doesn't require a timestamp,
index 39ab1ab637ae3388d3034719e59cd1fb79804201..0ca7d58199a28c98ba3b5f21ccf00cd04836f1ea 100644 (file)
@@ -15,7 +15,7 @@ package org.eclipse.tracecompass.internal.ctf.core.event.types.composite;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
-import org.eclipse.tracecompass.ctf.core.event.scope.LexicalScope;
+import org.eclipse.tracecompass.ctf.core.event.scope.ILexicalScope;
 import org.eclipse.tracecompass.ctf.core.event.types.Declaration;
 import org.eclipse.tracecompass.ctf.core.event.types.Definition;
 import org.eclipse.tracecompass.ctf.core.event.types.ICompositeDefinition;
@@ -55,7 +55,7 @@ public final class EventHeaderDefinition extends Definition implements IComposit
      *            the number of bits valid in the timestamp
      */
     public EventHeaderDefinition(@NonNull Declaration eventHeaderDecl, int id, long timestamp, int timestampLength) {
-        super(eventHeaderDecl, null, LexicalScope.EVENT_HEADER.toString(), LexicalScope.EVENT_HEADER);
+        super(eventHeaderDecl, null, ILexicalScope.EVENT_HEADER.getPath(), ILexicalScope.EVENT_HEADER);
         fId = id;
         fTimestamp = timestamp;
         fTimestampLength = timestampLength;
This page took 0.077265 seconds and 5 git commands to generate.