Use solely '\n' (not '\r\n') when parsing Java source files
authorJan Lahoda <jlahoda@netbeans.org>
Tue, 11 Dec 2012 15:10:16 +0100
changeset 916f50f893daa88
parent 915 63ec548c746d
child 917 f17fbf567e39
Use solely '\n' (not '\r\n') when parsing Java source files
remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java
remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java
     1.1 --- a/remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java	Sat Dec 08 23:48:13 2012 +0100
     1.2 +++ b/remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java	Tue Dec 11 15:10:16 2012 +0100
     1.3 @@ -108,7 +108,7 @@
     1.4          CompilationInfo result = path2CUT.get(relativePath);
     1.5  
     1.6          if (result == null) {
     1.7 -            String content = org.netbeans.modules.jackpot30.source.api.API.readFileContent(sourceRoot.getCategory(), relativePath);
     1.8 +            String content = org.netbeans.modules.jackpot30.source.api.API.readFileContent(sourceRoot.getCategory(), relativePath).replace("\r\n", "\n");
     1.9              Iterable<? extends CompilationUnitTree> cuts = javacTask.parse(new FileObjectImpl(relativePath, content));
    1.10              CompilationUnitTree cut = cuts.iterator().next();
    1.11  
     2.1 --- a/remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java	Sat Dec 08 23:48:13 2012 +0100
     2.2 +++ b/remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java	Tue Dec 11 15:10:16 2012 +0100
     2.3 @@ -204,7 +204,7 @@
     2.4      public String show(@Context UriInfo uriInfo, @QueryParam("path") String segment, @QueryParam("relative") String relative, @QueryParam("highlight") String highlightSpec, @QueryParam("signature") String signature) throws URISyntaxException, IOException, TemplateException, InterruptedException {
     2.5          String urlBase = URL_BASE_OVERRIDE != null ? URL_BASE_OVERRIDE : uriInfo.getBaseUri().toString();
     2.6          URI u = new URI(urlBase + "index/source/cat?path=" + escapeForQuery(segment) + "&relative=" + escapeForQuery(relative));
     2.7 -        String content = WebUtilities.requestStringResponse(u);
     2.8 +        String content = WebUtilities.requestStringResponse(u).replace("\r\n", "\n");
     2.9          List<Long> highlightSpans = new ArrayList<Long>();
    2.10  
    2.11          if (signature != null) {
    2.12 @@ -222,7 +222,7 @@
    2.13          }
    2.14  
    2.15          Map<String, Object> configurationData = new HashMap<String, Object>();
    2.16 -        String[] highlights = colorTokens(segment, relative, content, highlightSpans);
    2.17 +        String[] highlights = colorTokens(segment, relative, highlightSpans);
    2.18  
    2.19          configurationData.put("spans", highlights[0]);
    2.20          configurationData.put("categories", highlights[1]);
    2.21 @@ -233,9 +233,9 @@
    2.22          return FreemarkerUtilities.processTemplate("org/netbeans/modules/jackpot30/backend/ui/showCode.html", configurationData);
    2.23      }
    2.24  
    2.25 -    static String[] colorTokens(String segment, String relative, String content, List<Long> highlight) throws IOException, InterruptedException {
    2.26 -        TokenSequence<?> ts = TokenHierarchy.create(content, JavaTokenId.language()).tokenSequence();
    2.27 +    static String[] colorTokens(String segment, String relative, List<Long> highlight) throws IOException, InterruptedException {
    2.28          CompilationInfo info = ResolveService.parse(segment, relative);
    2.29 +        TokenSequence<?> ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());
    2.30          Map<Token, Coloring> semanticHighlights = SemanticHighlighter.computeHighlights(info, new TokenList(info, ts, new AtomicBoolean()));
    2.31          StringBuilder spans = new StringBuilder();
    2.32          StringBuilder cats  = new StringBuilder();