Commits

Jan Lahoda  committed 1bafc3a

Use solely '\n' (not '\r\n') when parsing Java source files

  • Participants
  • Parent commits 8c9c565

Comments (0)

Files changed (2)

File remoting/server/web/resolve.web.api/src/org/netbeans/modules/jackpot30/resolve/api/Javac.java

         CompilationInfo result = path2CUT.get(relativePath);
 
         if (result == null) {
-            String content = org.netbeans.modules.jackpot30.source.api.API.readFileContent(sourceRoot.getCategory(), relativePath);
+            String content = org.netbeans.modules.jackpot30.source.api.API.readFileContent(sourceRoot.getCategory(), relativePath).replace("\r\n", "\n");
             Iterable<? extends CompilationUnitTree> cuts = javacTask.parse(new FileObjectImpl(relativePath, content));
             CompilationUnitTree cut = cuts.iterator().next();
 

File remoting/server/web/web.ui/src/org/netbeans/modules/jackpot30/backend/ui/UI.java

     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 {
         String urlBase = URL_BASE_OVERRIDE != null ? URL_BASE_OVERRIDE : uriInfo.getBaseUri().toString();
         URI u = new URI(urlBase + "index/source/cat?path=" + escapeForQuery(segment) + "&relative=" + escapeForQuery(relative));
-        String content = WebUtilities.requestStringResponse(u);
+        String content = WebUtilities.requestStringResponse(u).replace("\r\n", "\n");
         List<Long> highlightSpans = new ArrayList<Long>();
 
         if (signature != null) {
         }
 
         Map<String, Object> configurationData = new HashMap<String, Object>();
-        String[] highlights = colorTokens(segment, relative, content, highlightSpans);
+        String[] highlights = colorTokens(segment, relative, highlightSpans);
 
         configurationData.put("spans", highlights[0]);
         configurationData.put("categories", highlights[1]);
         return FreemarkerUtilities.processTemplate("org/netbeans/modules/jackpot30/backend/ui/showCode.html", configurationData);
     }
 
-    static String[] colorTokens(String segment, String relative, String content, List<Long> highlight) throws IOException, InterruptedException {
-        TokenSequence<?> ts = TokenHierarchy.create(content, JavaTokenId.language()).tokenSequence();
+    static String[] colorTokens(String segment, String relative, List<Long> highlight) throws IOException, InterruptedException {
         CompilationInfo info = ResolveService.parse(segment, relative);
+        TokenSequence<?> ts = info.getTokenHierarchy().tokenSequence(JavaTokenId.language());
         Map<Token, Coloring> semanticHighlights = SemanticHighlighter.computeHighlights(info, new TokenList(info, ts, new AtomicBoolean()));
         StringBuilder spans = new StringBuilder();
         StringBuilder cats  = new StringBuilder();