/**
   * Walks to the enclosing type's simple names and applies naming convention. This shortcut/fix
   * shows deficiency of model (it's probably more complicated than needed).
   *
   * @return enclosing immutable name
   */
  @Value.Lazy
  String typeImmutableEnclosingSimpleName() {
    DeclaringType declaringType = protoclass().enclosingOf().get();
    String enclosingSimpleName = declaringType.element().getSimpleName().toString();
    String enclosingRawName = names().rawFromAbstract(enclosingSimpleName);
    // Here we checking for having both enclosing and value
    // if we had protoclass it would be kind().isEnclosing() && kind().isValue()
    Naming naming =
        declaringType.isImmutable()
            ? names().namings.typeImmutable
            : names().namings.typeImmutableEnclosing;

    return naming.apply(enclosingRawName);
  }
Example #2
0
 @Nullable
 private String getFromSourceImports(String resolvable) {
   if (sourceClassesImports == null) {
     sourceClassesImports = declaringType.associatedTopLevel().sourceImports().classes;
   }
   return sourceClassesImports.get(resolvable);
 }
 @Nullable
 private String getFromSourceImports(String resolvable) {
   if (sourceClassesImports == null) {
     sourceClassesImports = Lists.newArrayList();
     for (DeclaringType t : declaringTypes) {
       Imports imports = t.associatedTopLevel().sourceImports();
       if (!sourceClassesImports.contains(imports)) {
         sourceClassesImports.add(imports);
       }
     }
   }
   for (SourceExtraction.Imports imports : sourceClassesImports) {
     @Nullable String resolved = imports.classes.get(resolvable);
     if (resolved != null) {
       return resolved;
     }
   }
   return null;
 }