You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2018/11/11 03:30:26 UTC

[GitHub] junichi11 closed pull request #1017: Don't add whitespaces to java guarded sections

junichi11 closed pull request #1017: Don't add whitespaces to java guarded sections
URL: https://github.com/apache/incubator-netbeans/pull/1017
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java b/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java
index 76ace08ea1..459924dc1b 100644
--- a/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java
+++ b/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java
@@ -173,8 +173,8 @@ public JavaGuardedReader(JavaGuardedSectionsProvider provider) {
                     charBuffPtr -= MAGICLEN;
                     i += match.length();
                     int toNl = toNewLine(i, readBuff);
-                    int sectionSize = MAGICLEN+match.length()+toNl;
-                    
+                    int sectionSize = KEEP_GUARD_COMMENTS ? MAGICLEN + match.length() + toNl : 0;
+
 //                    if (!justFilter) {
 //                        System.out.println("## MATCH: '" + match.substring(0, match.length() - 1) + "'");
                         SectionDescriptor desc = new SectionDescriptor(
@@ -194,8 +194,9 @@ public JavaGuardedReader(JavaGuardedSectionsProvider provider) {
                         charBuffPtr += MAGICLEN;
                     } else {
                         i += toNl;
-                        Arrays.fill(charBuff,charBuffPtr,charBuffPtr+sectionSize,' ');
-                        charBuffPtr+=sectionSize;
+                        char[] tmpCharBuff = new char[charBuff.length];
+                        System.arraycopy(charBuff, 0, tmpCharBuff, 0, charBuffPtr);
+                        charBuff = tmpCharBuff;
                     }
                 }
             }
diff --git a/java/java.guards/test/unit/src/org/netbeans/modules/java/guards/JavaGuardedReaderTest.java b/java/java.guards/test/unit/src/org/netbeans/modules/java/guards/JavaGuardedReaderTest.java
index cb121bc239..bd8961a6a2 100644
--- a/java/java.guards/test/unit/src/org/netbeans/modules/java/guards/JavaGuardedReaderTest.java
+++ b/java/java.guards/test/unit/src/org/netbeans/modules/java/guards/JavaGuardedReaderTest.java
@@ -87,7 +87,7 @@ public void testTranslateLINE() {
         
         String readStr = "\nclass A {//" + "GEN-LINE:hu\n}\n";
         editor.setStringContent(readStr);
-        String expStr =  "\nclass A {  " + "           \n}\n";
+        String expStr =  "\nclass A {\n}\n";
         char[] readBuff = readStr.toCharArray();
         
         char[] result = instance.translateToCharBuff(readBuff);
@@ -132,7 +132,7 @@ public void testTranslateBEGIN_END2() {
         
         String readStr = "\nclass A {//" + "GEN-BEGIN:hu\n\n}//" + "GEN-END:hu\n";
         editor.setStringContent(readStr);
-        String expStr =  "\nclass A {  " + "            \n\n}  " + "          \n";
+        String expStr =  "\nclass A {\n\n}\n";
         char[] readBuff = readStr.toCharArray();
         
         JavaGuardedReader.setKeepGuardCommentsForTest(false);
@@ -155,7 +155,7 @@ public void testTranslateFIRST_LAST() {
         
         String readStr = "\nclass A {//" + "GEN-FIRST:hu\n  statement;\n}//" + "GEN-LAST:hu\n";
         editor.setStringContent(readStr);
-        String expStr =  "\nclass A {  " + "            \n  statement;\n}  " + "           \n";
+        String expStr =  "\nclass A {\n  statement;\n}\n";
         char[] readBuff = readStr.toCharArray();
         
         char[] result = instance.translateToCharBuff(readBuff);
@@ -180,7 +180,7 @@ public void testTranslateFIRST_HEADEREND_LAST() {
         
         String readStr = "\nclass A //" + "GEN-FIRST:hu\n{//" + "GEN-HEADEREND:hu\n  statement;\n}//" + "GEN-LAST:hu\n";
         editor.setStringContent(readStr);
-        String expStr =  "\nclass A   " + "            \n{  " + "                \n  statement;\n}  " + "           \n";
+        String expStr =  "\nclass A \n{\n  statement;\n}\n";
         char[] readBuff = readStr.toCharArray();
         
         char[] result = instance.translateToCharBuff(readBuff);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists