Exemplo n.º 1
0
 public RewritableImportSection parse(XtextResource resource) {
   RewritableImportSection rewritableImportSection =
       new RewritableImportSection(
           resource,
           importsConfiguration,
           importsConfiguration.getImportSection(resource),
           whitespaceInformationProvider
               .getLineSeparatorInformation(resource.getURI())
               .getLineSeparator(),
           regionUtil,
           nameValueConverter);
   return rewritableImportSection;
 }
Exemplo n.º 2
0
 public RewritableImportSection createNewEmpty(XtextResource resource) {
   RewritableImportSection rewritableImportSection =
       new RewritableImportSection(
           resource,
           importsConfiguration,
           null,
           whitespaceInformationProvider
               .getLineSeparatorInformation(resource.getURI())
               .getLineSeparator(),
           regionUtil,
           nameValueConverter);
   rewritableImportSection.setSort(true);
   return rewritableImportSection;
 }
 public String getOrganizedImportSection(XtextResource xtextResource) {
   String lineSeparator =
       whitespaceInformationProvider
           .getLineSeparatorInformation(xtextResource.getURI())
           .getLineSeparator();
   StringBuilder importsSection = new StringBuilder();
   ArrayList<QualifiedName> importedNames = newArrayList(getImportedNames(xtextResource));
   Collections.sort(importedNames);
   if (!importedNames.isEmpty()) {
     importsSection.append(lineSeparator);
     IValueConverter<String> qualifiedNameValueConverter =
         valueConverterService.getQualifiedNameValueConverter();
     for (QualifiedName qualifiedName : importedNames) {
       String qualifiedNameValue =
           qualifiedNameValueConverter.toString(nameConverter.toString(qualifiedName));
       importsSection.append(lineSeparator).append("import ").append(qualifiedNameValue);
     }
   }
   return importsSection.toString();
 }