]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/parsing/declarations/DDocumentationAst.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / parsing / declarations / DDocumentationAst.java
index 203ea5c695854b3131105de147b36c148eb1b055..02c4e825fc5ae16a616a4ad6117f202a895c42fd 100644 (file)
@@ -1,77 +1,77 @@
-package org.simantics.scl.compiler.internal.parsing.declarations;\r
-\r
-\r
-public class DDocumentationAst extends DeclarationAst {\r
-    public final String documentation;\r
-    \r
-    public DDocumentationAst(String documentation) {\r
-        this.documentation = cleanUp(documentation);\r
-    }\r
-\r
-    @Override\r
-    public void toString(int indentation, StringBuilder b) {\r
-        for(int i=0;i<indentation;++i) b.append("    ");\r
-        b.append("\"\"\"\n");\r
-        b.append(documentation);\r
-        b.append("\"\"\"\n");\r
-        \r
-    }\r
-    \r
-    private static String cleanUp(String documentation) {\r
-        // Remove empty lines\r
-        int end = documentation.length();\r
-        while(end > 0) {\r
-            char c = documentation.charAt(end-1);\r
-            if(c != ' ' && c != '\n')\r
-                break;\r
-            --end;\r
-        }\r
-        \r
-        int begin = 0;\r
-        for(int i=0;i<end;++i) {\r
-            char c = documentation.charAt(i);\r
-            if(c == '\n')\r
-                begin = i+1;\r
-            else if(c != ' ')\r
-                break;\r
-        }\r
-            \r
-        // Calculate common indentation\r
-        int lineStart = begin;\r
-        int commonIndentation = Integer.MAX_VALUE;\r
-        for(int i=begin;i<end;++i) {\r
-            char c = documentation.charAt(i);\r
-            if(c == '\n') {\r
-                lineStart = i+1;\r
-            }\r
-            else if(lineStart >= 0 && c != ' ') {\r
-                int indentation = i - lineStart;\r
-                commonIndentation = Math.min(commonIndentation, indentation);\r
-                if(commonIndentation == 0) {\r
-                    if(begin == 0 && end == documentation.length())\r
-                        return documentation;\r
-                    else\r
-                        return documentation.substring(begin, end);\r
-                }\r
-                lineStart = -1;\r
-            }\r
-        }\r
-        \r
-        // Remove common indentation\r
-        StringBuilder result = new StringBuilder();\r
-        int charsToSkip = commonIndentation;\r
-        for(int i=begin;i<end;++i) {\r
-            char c = documentation.charAt(i);\r
-            if(c == '\n') {\r
-                result.append(c);\r
-                charsToSkip = commonIndentation;\r
-                continue;\r
-            }\r
-            if(charsToSkip > 0)\r
-                --charsToSkip;\r
-            else\r
-                result.append(c);\r
-        }\r
-        return result.toString();\r
-    }\r
-}\r
+package org.simantics.scl.compiler.internal.parsing.declarations;
+
+
+public class DDocumentationAst extends DeclarationAst {
+    public final String documentation;
+    
+    public DDocumentationAst(String documentation) {
+        this.documentation = cleanUp(documentation);
+    }
+
+    @Override
+    public void toString(int indentation, StringBuilder b) {
+        for(int i=0;i<indentation;++i) b.append("    ");
+        b.append("\"\"\"\n");
+        b.append(documentation);
+        b.append("\"\"\"\n");
+        
+    }
+    
+    private static String cleanUp(String documentation) {
+        // Remove empty lines
+        int end = documentation.length();
+        while(end > 0) {
+            char c = documentation.charAt(end-1);
+            if(c != ' ' && c != '\n')
+                break;
+            --end;
+        }
+        
+        int begin = 0;
+        for(int i=0;i<end;++i) {
+            char c = documentation.charAt(i);
+            if(c == '\n')
+                begin = i+1;
+            else if(c != ' ')
+                break;
+        }
+            
+        // Calculate common indentation
+        int lineStart = begin;
+        int commonIndentation = Integer.MAX_VALUE;
+        for(int i=begin;i<end;++i) {
+            char c = documentation.charAt(i);
+            if(c == '\n') {
+                lineStart = i+1;
+            }
+            else if(lineStart >= 0 && c != ' ') {
+                int indentation = i - lineStart;
+                commonIndentation = Math.min(commonIndentation, indentation);
+                if(commonIndentation == 0) {
+                    if(begin == 0 && end == documentation.length())
+                        return documentation;
+                    else
+                        return documentation.substring(begin, end);
+                }
+                lineStart = -1;
+            }
+        }
+        
+        // Remove common indentation
+        StringBuilder result = new StringBuilder();
+        int charsToSkip = commonIndentation;
+        for(int i=begin;i<end;++i) {
+            char c = documentation.charAt(i);
+            if(c == '\n') {
+                result.append(c);
+                charsToSkip = commonIndentation;
+                continue;
+            }
+            if(charsToSkip > 0)
+                --charsToSkip;
+            else
+                result.append(c);
+        }
+        return result.toString();
+    }
+}