protected IScope getExecutableScope(XAbstractFeatureCall call, JvmIdentifiableElement feature) {
   QualifiedName name = QualifiedName.create(feature.getSimpleName());
   if (call.isOperation()) {
     QualifiedName operator = getOperator(call, name);
     if (operator == null) {
       return IScope.NULLSCOPE;
     }
     return new SingletonScope(EObjectDescription.create(operator, feature), IScope.NULLSCOPE);
   }
   if (call instanceof XAssignment) {
     String propertyName = Strings.toFirstLower(feature.getSimpleName().substring(3));
     return new SingletonScope(EObjectDescription.create(propertyName, feature), IScope.NULLSCOPE);
   }
   if (call.isExplicitOperationCallOrBuilderSyntax()
       || ((JvmExecutable) feature).getParameters().size() > 1
       || (!call.isExtension() && ((JvmExecutable) feature).getParameters().size() == 1)) {
     return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE);
   }
   if (feature.getSimpleName().startsWith("get") || feature.getSimpleName().startsWith("is")) {
     List<IEObjectDescription> result = Lists.newArrayListWithCapacity(2);
     result.add(EObjectDescription.create(name, feature));
     if (feature.getSimpleName().startsWith("get")) {
       String propertyName = Strings.toFirstLower(feature.getSimpleName().substring(3));
       result.add(EObjectDescription.create(propertyName, feature));
     } else {
       String propertyName = Strings.toFirstLower(feature.getSimpleName().substring(2));
       result.add(EObjectDescription.create(propertyName, feature));
     }
     return new SimpleScope(result);
   }
   return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE);
 }
예제 #2
0
 private void addTypeCastToExplicitReceiver(
     XAbstractFeatureCall featureCall,
     IModificationContext context,
     JvmType declaringType,
     EReference structuralFeature)
     throws BadLocationException {
   List<INode> nodes = NodeModelUtils.findNodesForFeature(featureCall, structuralFeature);
   if (nodes.isEmpty()) return;
   INode firstNode = IterableExtensions.head(nodes);
   INode lastNode = IterableExtensions.last(nodes);
   int offset = firstNode.getOffset();
   int length = lastNode.getEndOffset() - offset;
   ReplacingAppendable appendable =
       appendableFactory.create(
           context.getXtextDocument(), (XtextResource) featureCall.eResource(), offset, length);
   appendable.append("(");
   ListIterator<INode> nodeIter = nodes.listIterator();
   while (nodeIter.hasNext()) {
     String text = nodeIter.next().getText();
     if (nodeIter.previousIndex() == 0) appendable.append(Strings.removeLeadingWhitespace(text));
     else if (nodeIter.nextIndex() == nodes.size())
       appendable.append(Strings.trimTrailingLineBreak(text));
     else appendable.append(text);
   }
   appendable.append(" as ");
   appendable.append(declaringType);
   appendable.append(")");
   appendable.commitChanges();
 }
예제 #3
0
 public String migrate(String formattedString, String toBeFormattedString, Pattern format) {
   if (Strings.isEmpty(toBeFormattedString) || Strings.isEmpty(formattedString))
     return toBeFormattedString;
   FormattedString formatted = createFormattedString(formattedString, format);
   FormattedString toBeFormatted = createFormattedString(toBeFormattedString, format);
   if (formatted.semantic.equals(toBeFormatted.semantic)) return formattedString;
   List<Mapping> mappings = Lists.newArrayList();
   List<Region> remainingRegions = Lists.newArrayList();
   findLinearMatches(formatted, toBeFormatted, mappings, remainingRegions);
   for (Mapping m : mappings) toBeFormatted.migrateFrom(formatted, m);
   return toBeFormatted.toString();
 }
 protected IScope doGetTypeScope(XMemberFeatureCall call, JvmType type) {
   if (call.isPackageFragment()) {
     if (type instanceof JvmDeclaredType) {
       int segmentIndex = countSegments(call);
       String packageName = ((JvmDeclaredType) type).getPackageName();
       List<String> splitted = Strings.split(packageName, '.');
       String segment = splitted.get(segmentIndex);
       return new SingletonScope(EObjectDescription.create(segment, type), IScope.NULLSCOPE);
     }
     return IScope.NULLSCOPE;
   } else {
     if (type instanceof JvmDeclaredType && ((JvmDeclaredType) type).getDeclaringType() == null) {
       return new SingletonScope(
           EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
     } else {
       XAbstractFeatureCall target = (XAbstractFeatureCall) call.getMemberCallTarget();
       if (target.isPackageFragment()) {
         String qualifiedName = type.getQualifiedName();
         int dot = qualifiedName.lastIndexOf('.');
         String simpleName = qualifiedName.substring(dot + 1);
         return new SingletonScope(EObjectDescription.create(simpleName, type), IScope.NULLSCOPE);
       } else {
         return new SingletonScope(
             EObjectDescription.create(type.getSimpleName(), type), IScope.NULLSCOPE);
       }
     }
   }
 }
예제 #5
0
 @Override
 public String apply(IGeneratorFragment from) {
   if (from instanceof CompositeGeneratorFragment) {
     return Strings.toString(((CompositeGeneratorFragment) from).fragments, this, delim);
   }
   return from.getClass().getSimpleName();
 }
 public String getJavaFileName(IEObjectDescription description) {
   if (!isJvmDeclaredType(description)) {
     return null;
   }
   QualifiedName typeName = description.getName();
   return Strings.concat("/", typeName.getSegments()) + ".java";
 }
예제 #7
0
 public String getLanguageNameAbbreviation() {
   String[] packageNames = this.languageName.split("\\.");
   final String[] _converted_packageNames = (String[]) packageNames;
   String _last =
       IterableExtensions.<String>last(
           ((Iterable<String>) Conversions.doWrapArray(_converted_packageNames)));
   return Strings.toFirstUpper(_last);
 }
예제 #8
0
 @Override
 public void generate(Grammar grammar, XpandExecutionContext ctx) {
   if (LOG.isInfoEnabled()) {
     LOG.info(
         "generating infrastructure for "
             + grammar.getName()
             + " with fragments : "
             + Strings.toString(this.fragments, new ToStringFunction(", "), ", "));
   }
   super.generate(grammar, ctx);
 }
 @Override
 public String getQualifiedName(char innerClassDelimiter) {
   if (simpleName == null) return null;
   JvmDeclaredType declaringType = getDeclaringType();
   if (declaringType == null) {
     if (Strings.isEmpty(packageName)) return simpleName;
     return packageName + "." + simpleName;
   }
   String parentName = declaringType.getQualifiedName(innerClassDelimiter);
   if (parentName == null) return null;
   return parentName + innerClassDelimiter + simpleName;
 }
 @Override
 protected String computeIdentifier() {
   if (simpleName == null) return null;
   JvmDeclaredType declaringType = internalGetDeclaringType();
   if (declaringType == null) {
     if (Strings.isEmpty(packageName)) return simpleName;
     return packageName + "." + simpleName;
   }
   String parentName = declaringType.getIdentifier();
   if (parentName == null) return null;
   return parentName + '$' + simpleName;
 }
 @Override
 protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(
     EObject context, boolean ignoreCase) {
   if (!(context instanceof XtendFile)) return Collections.emptyList();
   List<ImportNormalizer> importedNamespaceResolvers =
       super.internalGetImportedNamespaceResolvers(context, ignoreCase);
   if (context instanceof XtendFile && !Strings.isEmpty(((XtendFile) context).getPackage())) {
     importedNamespaceResolvers.add(
         new ImportNormalizer(
             nameConverter.toQualifiedName(((XtendFile) context).getPackage()), true, ignoreCase));
   }
   return importedNamespaceResolvers;
 }
 public Number toValue(String string, INode node) {
   if (Strings.isEmpty(string))
     throw new ValueConverterException("Couldn't convert empty string to number", node, null);
   try {
     if (string.contains(".") || string.contains("e") || string.contains("e")) {
       return new BigDecimal(string);
     } else {
       return new BigInteger(string);
     }
   } catch (NumberFormatException e) {
     throw new ValueConverterException("Couldn't convert '" + string + "' to number", node, e);
   }
 }
예제 #13
0
 /** This test assumes that an EPackage with indexed references is no longer available. */
 public void testExternalFormOfEReferenceNoNPE() throws Exception {
   EReference reference = EcorePackage.Literals.EATTRIBUTE__EATTRIBUTE_TYPE;
   URI uri = EcoreUtil.getURI(reference);
   String externalForm = uri.toString();
   EReference foundReference =
       EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, externalForm);
   assertSame(reference, foundReference);
   String brokenExternalFrom = Strings.toFirstUpper(externalForm);
   assertNull(
       EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, brokenExternalFrom));
   String shortExternalForm = EcoreUtil2.toExternalForm(reference);
   foundReference =
       EcoreUtil2.getEReferenceFromExternalForm(EPackage.Registry.INSTANCE, shortExternalForm);
   assertSame(reference, foundReference);
   String brokenShortExternalFrom = Strings.toFirstUpper(shortExternalForm);
   assertNull(
       EcoreUtil2.getEReferenceFromExternalForm(
           EPackage.Registry.INSTANCE, brokenShortExternalFrom));
   brokenShortExternalFrom = shortExternalForm.replace('A', 'a');
   assertNull(
       EcoreUtil2.getEReferenceFromExternalForm(
           EPackage.Registry.INSTANCE, brokenShortExternalFrom));
 }
 /**
  * Create a new {@link ImportNormalizer} for the given namespace.
  *
  * @param namespace the namespace.
  * @param ignoreCase <code>true</code> if the resolver should be case insensitive.
  * @return a new {@link ImportNormalizer} or <code>null</code> if the namespace cannot be
  *     converted to a valid qualified name.
  */
 protected ImportNormalizer createImportedNamespaceResolver(
     final String namespace, boolean ignoreCase) {
   if (Strings.isEmpty(namespace)) return null;
   QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
   if (importedNamespace == null || importedNamespace.getSegmentCount() < 1) {
     return null;
   }
   boolean hasWildcard =
       ignoreCase
           ? importedNamespace.getLastSegment().equalsIgnoreCase(getWildcard())
           : importedNamespace.getLastSegment().equals(getWildcard());
   if (hasWildcard) {
     if (importedNamespace.getSegmentCount() <= 1) return null;
     return doCreateImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
   } else {
     return doCreateImportNormalizer(importedNamespace, false, ignoreCase);
   }
 }
예제 #15
0
 protected String decode(final String string) {
   try {
     boolean _equals = Objects.equal(string, null);
     if (_equals) {
       return "";
     } else {
       return Strings.convertFromJavaString(string, true);
     }
   } catch (final Throwable _t) {
     if (_t instanceof IllegalArgumentException) {
       final IllegalArgumentException e = (IllegalArgumentException) _t;
       AbstractDocGenerator.LOG.error("Exception when converting string", e);
       return string;
     } else {
       throw Exceptions.sneakyThrow(_t);
     }
   }
 }
예제 #16
0
  public static String getPojoDefinitions(List<Class<?>> pojoClasses) {
    if (pojoClasses == null) return null;
    TreeMap<String, String> map = new TreeMap<String, String>();
    for (Class<?> clazz : pojoClasses) {
      map.put(toCamelCase(clazz), clazz.getName());
    }

    StringBuilder builder = new StringBuilder();
    for (Entry<String, String> pojo : map.entrySet()) {
      builder
          .append("is-pojo ")
          .append(Strings.toFirstUpper(pojo.getKey()))
          .append(' ')
          .append(pojo.getValue())
          .append(";\n");
    }
    return builder.toString();
  }
 public String check(IEObjectDescription input) {
   if (input instanceof IValidatedEObjectDescription) {
     final IValidatedEObjectDescription validatedDescription =
         (IValidatedEObjectDescription) input;
     JvmIdentifiableElement identifiable = validatedDescription.getEObjectOrProxy();
     if (identifiable.eIsProxy())
       identifiable = (JvmIdentifiableElement) EcoreUtil.resolve(identifiable, context);
     String issueCode;
     if (identifiable.eIsProxy()) issueCode = UNRESOLVABLE_PROXY;
     else if (!validatedDescription.isValid()) {
       if (Strings.isEmpty(validatedDescription.getIssueCode())) issueCode = FEATURE_NOT_VISIBLE;
       else return validatedDescription.getIssueCode();
     } else issueCode = dispatcher.invoke(identifiable, context, reference, validatedDescription);
     validatedDescription.setIssueCode(issueCode);
     return issueCode;
   }
   return null;
 }
예제 #18
0
 protected JvmType findNestedType(JvmType result, int index, QualifiedName name) {
   List<String> segments =
       name.getSegmentCount() == 1
           ? Strings.split(name.getFirstSegment(), '$')
           : name.getSegments();
   for (int i = 1, size = segments.size(); i < size && result instanceof JvmDeclaredType; i++) {
     JvmDeclaredType declaredType = (JvmDeclaredType) result;
     String simpleName = segments.get(i);
     // TODO handle ambiguous types
     for (JvmMember member : declaredType.findAllNestedTypesByName(simpleName)) {
       result = (JvmType) member;
       break;
     }
     if (declaredType == result) {
       return null;
     }
   }
   return result;
 }
예제 #19
0
  public static void setUp() throws Exception {
    if (javaProject != null) return;
    javaProject =
        createJavaProject(
            "projectWithoutSources",
            new String[] {JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"});
    String path = "/org/eclipse/xtext/common/types/testSetups";
    String jarFileName = "/testData.jar";
    IFile jarFile =
        PluginUtil.copyFileToWorkspace(
            AbstractActivator.getInstance(),
            path + jarFileName,
            javaProject.getProject(),
            jarFileName);
    JavaProjectSetupUtil.addJarToClasspath(javaProject, jarFile);

    javaProjectWithSources =
        createJavaProject(
            "projectWithSources",
            new String[] {JavaCore.NATURE_ID, "org.eclipse.pde.PluginNature"});
    IFolder sourceFolder = JavaProjectSetupUtil.addSourceFolder(javaProjectWithSources, "src");

    List<String> filesToCopy = readResource(path + "/files.list");
    IFolder srcFolder = sourceFolder.getFolder(new Path(path));
    createFolderRecursively(srcFolder);
    for (String fileToCopy : filesToCopy) {
      List<String> content = readResource(path + "/" + fileToCopy);
      String contentAsString = Strings.concat("\n", content);
      createFile(
          fileToCopy.substring(0, fileToCopy.length() - ".txt".length()),
          srcFolder,
          contentAsString);
    }
    createFile(
        "ClassWithDefaultPackage.java", sourceFolder, "public class ClassWithDefaultPackage {}");
    waitForAutoBuild();
  }
예제 #20
0
 protected String computeFieldName(XtendField field, JvmGenericType declaringType) {
   if (field.getName() != null) return field.getName();
   JvmTypeReference type = field.getType();
   String name = null;
   if (type != null) {
     while (type instanceof JvmGenericArrayTypeReference) {
       type = ((JvmGenericArrayTypeReference) type).getComponentType();
     }
     if (type instanceof JvmParameterizedTypeReference) {
       List<INode> nodes =
           NodeModelUtils.findNodesForFeature(
               type, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE);
       if (!nodes.isEmpty()) {
         String typeName = nodes.get(0).getText().trim();
         int lastDot = typeName.lastIndexOf('.');
         if (lastDot != -1) {
           typeName = typeName.substring(lastDot + 1);
         }
         name = "_" + Strings.toFirstLower(typeName);
       }
     }
   }
   return name;
 }
예제 #21
0
 public static String toStringInAntlrAction(String string) {
   return Strings.convertToJavaString(string, true).replace("%", "\\%").replace("$", "\\$");
 }
 public List<String> javaVerbatimLines(final JavaVerbatim javaVerbatim) {
   String _verbatim = javaVerbatim.getVerbatim();
   String _property = System.getProperty("line.separator");
   return Strings.split(_verbatim, _property);
 }
  protected IScope getLocalElementsScope(
      IScope parent, IScope globalScope, EObject context, EReference reference) {
    IScope result = parent;
    QualifiedName name = getQualifiedNameOfLocalElement(context);
    boolean ignoreCase = isIgnoreCase(reference);
    ISelectable resourceOnlySelectable = getAllDescriptions(context.eResource());
    ISelectable globalScopeSelectable = new ScopeBasedSelectable(globalScope);

    // imports
    List<ImportNormalizer> explicitImports = getImportedNamespaceResolvers(context, ignoreCase);
    if (!explicitImports.isEmpty()) {
      result =
          createImportScope(
              result,
              explicitImports,
              globalScopeSelectable,
              reference.getEReferenceType(),
              ignoreCase);
    }

    // local element
    if (name != null) {
      ImportNormalizer localNormalizer = doCreateImportNormalizer(name, true, ignoreCase);
      result =
          createImportScope(
              result,
              singletonList(localNormalizer),
              resourceOnlySelectable,
              reference.getEReferenceType(),
              ignoreCase);
    }

    // scope for jvm elements
    Set<EObject> elements = associations.getJvmElements(context);
    for (EObject derivedJvmElement : elements) {
      // scope for JvmDeclaredTypes
      if (derivedJvmElement instanceof JvmDeclaredType) {
        JvmDeclaredType declaredType = (JvmDeclaredType) derivedJvmElement;
        QualifiedName jvmTypeName = getQualifiedNameOfLocalElement(declaredType);
        if (declaredType.getDeclaringType() == null
            && !Strings.isEmpty(declaredType.getPackageName())) {
          QualifiedName packageName =
              this.qualifiedNameConverter.toQualifiedName(declaredType.getPackageName());
          ImportNormalizer normalizer = doCreateImportNormalizer(packageName, true, ignoreCase);
          result =
              createImportScope(
                  result,
                  singletonList(normalizer),
                  globalScopeSelectable,
                  reference.getEReferenceType(),
                  ignoreCase);
        }
        if (jvmTypeName != null && !jvmTypeName.equals(name)) {
          ImportNormalizer localNormalizer =
              doCreateImportNormalizer(jvmTypeName, true, ignoreCase);
          result =
              createImportScope(
                  result,
                  singletonList(localNormalizer),
                  resourceOnlySelectable,
                  reference.getEReferenceType(),
                  ignoreCase);
        }
      }
      // scope for JvmTypeParameterDeclarator
      if (derivedJvmElement instanceof JvmTypeParameterDeclarator) {
        JvmTypeParameterDeclarator parameterDeclarator =
            (JvmTypeParameterDeclarator) derivedJvmElement;
        List<IEObjectDescription> descriptions = null;
        for (JvmTypeParameter param : parameterDeclarator.getTypeParameters()) {
          if (param.getSimpleName() != null) {
            if (descriptions == null) descriptions = Lists.newArrayList();
            QualifiedName paramName = QualifiedName.create(param.getSimpleName());
            descriptions.add(EObjectDescription.create(paramName, param));
          }
        }
        if (descriptions != null && !descriptions.isEmpty())
          result = MapBasedScope.createScope(result, descriptions);
      }
    }
    return result;
  }
예제 #24
0
 protected String toTitle(final String string) {
   String _decode = this.decode(string);
   return Strings.toFirstUpper(_decode);
 }
예제 #25
0
 @Override
 public Boolean caseLiteral(Literal object) {
   if (announced == null || announced != object.getLiteral()) {
     acceptor.announceNextLiteral(object.getLiteral());
     announced = object.getLiteral();
   }
   Line line = object.getLine();
   TextLine textLine =
       new TextLine(
           Strings.emptyIfNull(object.getLiteral().getValue()),
           object.getOffset(),
           object.getLength(),
           0);
   CharSequence ws = textLine.getLeadingWhiteSpace();
   ProcessedRichString string = line.getRichString();
   boolean firstOrLast =
       string.getLines().get(0) == line
           || string.getLines().get(string.getLines().size() - 1) == line;
   if (isTemplateLine(line)) {
     if (line.getParts().get(0) == object) {
       if (!firstOrLast) {
         boolean followedByOpening = false;
         if (line.getParts().size() >= 2) {
           LinePart next = line.getParts().get(1);
           if (next instanceof ForLoopStart || next instanceof IfConditionStart) {
             followedByOpening = true;
           }
         }
         if (!followedByOpening) {
           pushSemanticIndentation(indentationHandler.getTotalIndentation());
         } else {
           pushSemanticIndentation(ws);
         }
       }
     }
     announceTemplateText(textLine, object.getLiteral());
   } else {
     if (skipCount <= 1) {
       firstOrLast = false;
       if (skipCount == 0 && line.getParts().get(0) == object) {
         if (textLine.length() == ws.length()) {
           for (int i = 1; i < line.getParts().size(); i++) {
             if (line.getParts().get(i) instanceof Literal
                 && !(line.getParts().get(i) instanceof LineBreak)) {
               Literal nextLiteralInSameLine = (Literal) line.getParts().get(i);
               TextLine nextLiteralLine =
                   new TextLine(
                       nextLiteralInSameLine.getLiteral().getValue(),
                       nextLiteralInSameLine.getOffset(),
                       nextLiteralInSameLine.getLength(),
                       0);
               CharSequence nextLeading = nextLiteralLine.getLeadingWhiteSpace();
               if (nextLeading.length() > 0) {
                 ws = ws.toString() + nextLeading;
               }
               skipCount++;
               if (nextLeading.length() != nextLiteralLine.length()) {
                 break;
               }
             } else {
               break;
             }
           }
           if (skipCount != 0) {
             pushSemanticIndentation(ws);
           } else {
             pushSemanticIndentation(ws);
             announceIndentation();
             announceSemanticText(
                 textLine.subSequence(ws.length(), textLine.length()), object.getLiteral());
           }
         } else {
           pushSemanticIndentation(ws);
           announceIndentation();
           announceSemanticText(
               textLine.subSequence(ws.length(), textLine.length()), object.getLiteral());
         }
       } else {
         if (skipCount == 1) {
           skipCount--;
           announceIndentation();
           announceSemanticText(
               textLine.subSequence(ws.length(), textLine.length()), object.getLiteral());
         } else {
           announceSemanticText(textLine, object.getLiteral());
         }
       }
     } else {
       skipCount--;
     }
   }
   if (!firstOrLast && line.getParts().get(line.getParts().size() - 1) == object) {
     popIndentation();
   }
   computeNextPart(object);
   return Boolean.TRUE;
 }
예제 #26
0
 public static String toAntlrString(String string) {
   return Strings.convertToJavaString(string, true).replace("\\\"", "\"");
 }
예제 #27
0
 @Override
 public String[] getExportedPackagesRt(Grammar grammar) {
   return new String[] {Strings.skipLastToken(getScopeProviderName(grammar, getNaming()), ".")};
 }
예제 #28
0
 protected String getReplacement(ITextSegment region, String replacement) {
   String string = region.getText();
   if (Strings.equal(string, replacement))
     return "<" + region.getOffset() + "|" + replacement + ">";
   return "<" + region.getOffset() + ":" + region.getLength() + "|" + replacement + ">";
 }
 public String genGetUnassignedRuleCallToken(
     final JavaFile file, final AbstractRule rule, final boolean isAbstract) {
   if ((rule instanceof TerminalRule)) {
     boolean _and = false;
     if (!this.detectSyntheticTerminals) {
       _and = false;
     } else {
       boolean _isSyntheticTerminalRule =
           this.syntheticTerminalDetector.isSyntheticTerminalRule(((TerminalRule) rule));
       _and = _isSyntheticTerminalRule;
     }
     if (_and) {
       StringConcatenation _builder = new StringConcatenation();
       _builder.append("/**");
       _builder.newLine();
       _builder.append(" ");
       _builder.append(
           "* Synthetic terminal rule. The concrete syntax is to be specified by clients.");
       _builder.newLine();
       {
         if ((!isAbstract)) {
           _builder.append(" * Defaults to the empty string.");
         }
       }
       _builder.newLineIfNotEmpty();
       _builder.append(" ");
       _builder.append("*/");
       _builder.newLine();
       _builder.append("protected ");
       {
         if (isAbstract) {
           _builder.append("abstract ");
         }
       }
       _builder.append("String ");
       CharSequence _unassignedCalledTokenRuleName = this.unassignedCalledTokenRuleName(rule);
       _builder.append(_unassignedCalledTokenRuleName, "");
       _builder.append("(EObject semanticObject, RuleCall ruleCall, INode node)");
       {
         if (isAbstract) {
           _builder.append(";");
         } else {
           _builder.append(" { return \"\"; }");
         }
       }
       _builder.newLineIfNotEmpty();
       return _builder.toString();
     }
   }
   StringConcatenation _builder_1 = new StringConcatenation();
   _builder_1.append("/**");
   _builder_1.newLine();
   _builder_1.append(" ");
   _builder_1.append("* ");
   ICompositeNode _node = NodeModelUtils.getNode(rule);
   String _textWithoutComments = this.textWithoutComments(_node);
   String _trim = _textWithoutComments.trim();
   String _replace = _trim.replace("\n", "\n* ");
   _builder_1.append(_replace, " ");
   _builder_1.newLineIfNotEmpty();
   _builder_1.append(" ");
   _builder_1.append("*/");
   _builder_1.newLine();
   _builder_1.append("protected String ");
   CharSequence _unassignedCalledTokenRuleName_1 = this.unassignedCalledTokenRuleName(rule);
   _builder_1.append(_unassignedCalledTokenRuleName_1, "");
   _builder_1.append("(EObject semanticObject, RuleCall ruleCall, INode node) {");
   _builder_1.newLineIfNotEmpty();
   _builder_1.append("\t");
   _builder_1.append("if (node != null)");
   _builder_1.newLine();
   _builder_1.append("\t\t");
   _builder_1.append("return getTokenText(node);");
   _builder_1.newLine();
   _builder_1.append("\t");
   _builder_1.append("return \"");
   AbstractElement _alternatives = rule.getAlternatives();
   HashSet<AbstractElement> _newHashSet = CollectionLiterals.<AbstractElement>newHashSet();
   String _defaultValue = this.defaultValue(_alternatives, _newHashSet);
   String _convertToJavaString = Strings.convertToJavaString(_defaultValue);
   _builder_1.append(_convertToJavaString, "\t");
   _builder_1.append("\";");
   _builder_1.newLineIfNotEmpty();
   _builder_1.append("}");
   _builder_1.newLine();
   return _builder_1.toString();
 }
예제 #30
0
 String text(PuppetManifest ele) {
   String s = ele.eResource().getURI().lastSegment();
   return Strings.isEmpty(s) ? "<unnamed>" : URI.decode(s);
 }