ctf: make HashMap child a Map and extract lookupStructScope
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 13 Jul 2015 14:30:37 +0000 (10:30 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 15 Dec 2015 20:28:25 +0000 (15:28 -0500)
The map is self explanatory. The method extraction improves readibility
in my opinion

Change-Id: I9fb23c3223641d80e2f70a18142c3d4b968f0dab
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/51854
Reviewed-by: Hudson CI
Reviewed-by: Francis Giraldeau <francis.giraldeau@gmail.com>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/metadata/DeclarationScope.java

index 1a96f6af08ac9e5c7896923366a5bb2f6a1d8207..fb0deeb916bb53fd5dfe0e11294c15d6d05dc598 100644 (file)
@@ -46,7 +46,7 @@ public class DeclarationScope {
     // ------------------------------------------------------------------------
 
     private DeclarationScope fParentScope;
-    private @NonNull HashMap<String, DeclarationScope> fChildren = new HashMap<>();
+    private @NonNull Map<String, DeclarationScope> fChildren = new HashMap<>();
 
     private final Map<String, StructDeclaration> fStructs = new HashMap<>();
     private final Map<String, EnumDeclaration> fEnums = new HashMap<>();
@@ -471,12 +471,7 @@ public class DeclarationScope {
 
     private IDeclaration lookupIdentifierElement(DeclarationScope scope, String scopeName, String[] scopes) {
         if (scope.fStructs.containsKey(scopeName)) {
-            final IDeclaration structDeclaration = scope.fStructs.get(scopeName);
-            if (scopes.length <= 1) {
-                return structDeclaration;
-            }
-            return lookupIdentifierStructElement((StructDeclaration) structDeclaration, scopes[1], Arrays.copyOfRange(scopes, 2, scopes.length));
-
+            return lookupStructScope(scope, scopeName, scopes);
         } else if (scope.fTypes.containsKey(scopeName)) {
             return scope.fTypes.get(scopeName);
         } else if (scope.fEnums.containsKey(scopeName)) {
@@ -487,6 +482,14 @@ public class DeclarationScope {
         return null;
     }
 
+    private IDeclaration lookupStructScope(DeclarationScope scope, String scopeName, String[] scopes) {
+        final IDeclaration structDeclaration = scope.fStructs.get(scopeName);
+        if (scopes.length <= 1) {
+            return structDeclaration;
+        }
+        return lookupIdentifierStructElement((StructDeclaration) structDeclaration, scopes[1], Arrays.copyOfRange(scopes, 2, scopes.length));
+    }
+
     private IDeclaration lookupIdentifierStructElement(StructDeclaration structDeclaration, String string, String[] children) {
         IDeclaration field = structDeclaration.getField(string);
         if (children == null || children.length <= 0) {
This page took 0.024758 seconds and 5 git commands to generate.