package ruke.vrj.util;

import ruke.vrj.Symbol;
import ruke.vrj.SymbolFlag;

/**
 * MIT License
 *
 * Copyright (c) 2017 Franco Montenegro
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
public class NameGenerator {

  public static String to(final Symbol symbol) {
    final Symbol parent = symbol.parent;

    if (parent != null && parent.flags.contains(SymbolFlag.STRUCT)) {
      return String.format("%s_%s", parent.name, symbol.name);
    }

    return symbol.name;
  }

}

@@ -15,17 +15,19 @@
 rj.util;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -42,16 +42,17 @@
 .Symbol;
+%0D
 %0Aimport 
@@ -75,13 +75,16 @@
 lag;
-%0A
+%0D%0A%0D
 %0A/**
+%0D
 %0A * 
@@ -94,19 +94,21 @@
  License
+%0D
 %0A *
+%0D
 %0A * Copy
@@ -139,19 +139,21 @@
 ntenegro
+%0D
 %0A *
+%0D
 %0A * Perm
@@ -224,16 +224,17 @@
 g a copy
+%0D
 %0A * of t
@@ -306,16 +306,17 @@
  to deal
+%0D
 %0A * in t
@@ -387,16 +387,17 @@
 e rights
+%0D
 %0A * to u
@@ -465,16 +465,17 @@
 /or sell
+%0D
 %0A * copi
@@ -539,16 +539,17 @@
 tware is
+%0D
 %0A * furn
@@ -600,19 +600,21 @@
 ditions:
+%0D
 %0A *
+%0D
 %0A * The 
@@ -687,16 +687,17 @@
 d in all
+%0D
 %0A * copi
@@ -739,19 +739,21 @@
 oftware.
+%0D
 %0A *
+%0D
 %0A * THE 
@@ -822,16 +822,17 @@
 PRESS OR
+%0D
 %0A * IMPL
@@ -899,16 +899,17 @@
 ABILITY,
+%0D
 %0A * FITN
@@ -975,24 +975,25 @@
 NT SHALL THE
+%0D
 %0A * AUTHORS 
@@ -1054,16 +1054,17 @@
 OR OTHER
+%0D
 %0A * LIAB
@@ -1136,16 +1136,17 @@
 NG FROM,
+%0D
 %0A * OUT 
@@ -1218,16 +1218,17 @@
 S IN THE
+%0D
 %0A * SOFT
@@ -1236,12 +1236,14 @@
 ARE.
+%0D
 %0A */
+%0D
 %0Apub
@@ -1267,17 +1267,19 @@
 erator %7B
-%0A
+%0D%0A%0D
 %0A  publi
@@ -1319,16 +1319,17 @@
 ymbol) %7B
+%0D
 %0A    fin
@@ -1361,17 +1361,19 @@
 .parent;
-%0A
+%0D%0A%0D
 %0A    if 
@@ -1391,56 +1391,245 @@
 null
- && parent.flags.contains(SymbolFlag.STRUCT)) %7B%0A
+) %7B%0D%0A      final boolean mustUsePrefix =%0D%0A          parent.flags.contains(SymbolFlag.STRUCT) %7C%7C%0D%0A          parent.flags.contains(SymbolFlag.LIBRARY) %7C%7C%0D%0A          parent.flags.contains(SymbolFlag.SCOPE);%0D%0A%0D%0A      if (mustUsePrefix) %7B%0D%0A  
     
@@ -1690,15 +1690,27 @@
 me);
+%0D
 %0A    
-%7D%0A
+  %7D%0D%0A    %7D%0D%0A%0D
 %0A   
@@ -1733,12 +1733,16 @@
 ame;
+%0D
 %0A  %7D
-%0A
+%0D%0A%0D
 %0A%7D
+%0D
 %0A

Update name generator to add prefix to scopes & libraries