You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "junichi11 (via GitHub)" <gi...@apache.org> on 2023/04/14 01:24:39 UTC

[GitHub] [netbeans] junichi11 opened a new pull request, #5824: Add the "End of File" blank line formatting option #4641

junichi11 opened a new pull request, #5824:
URL: https://github.com/apache/netbeans/pull/5824

   - https://github.com/apache/netbeans/issues/4641
   - Add the "End of File" blank line formatting option
   
   ![nb-php-gh-4641-formatting-options](https://user-images.githubusercontent.com/738383/231916752-555565e3-b6d8-4964-98c0-2c1b5f589a69.png)
   
   - Add the new hint for PSR-12 Files
   
   ![nb-php-psr12-hint-options](https://user-images.githubusercontent.com/738383/231916897-b4228554-57a0-4c9c-8085-66db1f76f68a.png)
   
   ![nb-php-psr12-hint-2](https://user-images.githubusercontent.com/738383/231916800-f87730a8-69a3-4647-afd7-2e99c5b93484.png)
   
   ![nb-php-psr12-hint-1](https://user-images.githubusercontent.com/738383/231916809-22275eb6-9db5-4950-ad69-77fef7499e36.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on a diff in pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#discussion_r1166184122


##########
php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterBlankLinesEOFTest.java:
##########
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.editor.indent;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Pattern;
+import static junit.framework.TestCase.fail;
+import org.netbeans.junit.NbTestCase;
+import static org.netbeans.modules.csl.api.test.CslTestBase.readFile;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+public class PHPFormatterBlankLinesEOFTest extends PHPFormatterTestBase {
+
+    public PHPFormatterBlankLinesEOFTest(String testName) {
+        super(testName);
+    }
+
+    public void testEOF_01a() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, false);
+        reformatFileContents("testfiles/formatting/blankLines/eof_01.php", options, false, true);
+    }
+
+    public void testEOF_01b() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, true);
+        reformatFileContents("testfiles/formatting/blankLines/eof_01.php", options, false, true);
+    }
+
+    public void testEOF_02a() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, false);
+        reformatFileContents("testfiles/formatting/blankLines/eof_02.php", options, false, true);
+    }
+
+    public void testEOF_02b() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, true);
+        reformatFileContents("testfiles/formatting/blankLines/eof_02.php", options, false, true);
+    }
+
+    @Override
+    protected void assertDescriptionMatches(String relFilePath,
+            String description, boolean includeTestName, boolean includeJavaVersion, String ext, boolean checkFileExistence, boolean skipMarkers) throws Exception {
+        File rubyFile = getDataFile(relFilePath);
+        if (checkFileExistence && !rubyFile.exists()) {
+            NbTestCase.fail("File " + rubyFile + " not found.");
+        }
+
+        File goldenFile = null;
+        if (includeJavaVersion) {
+            String version = System.getProperty("java.specification.version");
+            for (String variant : computeVersionVariantsFor(version)) {
+                goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + variant + ext);
+                if (goldenFile.exists()) {
+                    break;
+                }
+            }
+        }
+        if (goldenFile == null || !goldenFile.exists()) {
+            goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + ext);
+        }
+        if (!goldenFile.exists()) {
+            if (!goldenFile.createNewFile()) {
+                NbTestCase.fail("Cannot create file " + goldenFile);
+            }
+            FileWriter fw = new FileWriter(goldenFile);
+            try {
+                fw.write(description);
+            } finally {
+                fw.close();
+            }
+            if (failOnMissingGoldenFile()) {
+                NbTestCase.fail("Created generated golden file " + goldenFile + "\nPlease re-run the test.");
+            }
+            return;
+        }
+
+        String expected = readFile(goldenFile);
+
+        // don't trim in this EOF test
+        String expectedTrimmed = expected;
+        String actualTrimmed = description;

Review Comment:
   https://github.com/apache/netbeans/blob/2926b6df47f3bfcf9ce8ec3db048108cc536628d/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java#L925-L926
   
   Expected and actual results are trimmed in the original `assertDescriptionMatches()`. If there is a newline at EOF, we cannot test correctly.  So, I override this method and copy related methods.
   
   No other tests are affected because I created the new test class then, overrode the method and added unit tests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#issuecomment-1508301377

   @tmysik Thank you for your review!
   
   > Just one note - aren't we able to sort PSR hints in the dialog? I mean, currently, we have PSR-12 before PSR-4. It would be great, if we could sorry it "by PSR number".
   
   I was also wondering about it.
   They are sorted in `HintsPanel`. I have no ideas at the moment...
   
   https://github.com/apache/netbeans/blob/68621165502b00599adf4622e0e7a14fc0565cb1/ide/csl.api/src/org/netbeans/modules/csl/hints/infrastructure/HintsPanel.java#L106-L125


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on a diff in pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#discussion_r1166671760


##########
php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java:
##########
@@ -3113,6 +3118,36 @@ private String createWhitespace(DocumentOptions docOptions, int lines, int space
         return sb.toString();
     }
 
+    private void resolveNoNewlineAtEOF(BaseDocument document) {

Review Comment:
   Fixed. Thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] tmysik commented on pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#issuecomment-1508394730

   @junichi11 I see. Hmm, up to you to decide. Personally, I don't like the extra space but like the sorting 😅 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on a diff in pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#discussion_r1166184122


##########
php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterBlankLinesEOFTest.java:
##########
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.editor.indent;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Pattern;
+import static junit.framework.TestCase.fail;
+import org.netbeans.junit.NbTestCase;
+import static org.netbeans.modules.csl.api.test.CslTestBase.readFile;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+public class PHPFormatterBlankLinesEOFTest extends PHPFormatterTestBase {
+
+    public PHPFormatterBlankLinesEOFTest(String testName) {
+        super(testName);
+    }
+
+    public void testEOF_01a() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, false);
+        reformatFileContents("testfiles/formatting/blankLines/eof_01.php", options, false, true);
+    }
+
+    public void testEOF_01b() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, true);
+        reformatFileContents("testfiles/formatting/blankLines/eof_01.php", options, false, true);
+    }
+
+    public void testEOF_02a() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, false);
+        reformatFileContents("testfiles/formatting/blankLines/eof_02.php", options, false, true);
+    }
+
+    public void testEOF_02b() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, true);
+        reformatFileContents("testfiles/formatting/blankLines/eof_02.php", options, false, true);
+    }
+
+    @Override
+    protected void assertDescriptionMatches(String relFilePath,
+            String description, boolean includeTestName, boolean includeJavaVersion, String ext, boolean checkFileExistence, boolean skipMarkers) throws Exception {
+        File rubyFile = getDataFile(relFilePath);
+        if (checkFileExistence && !rubyFile.exists()) {
+            NbTestCase.fail("File " + rubyFile + " not found.");
+        }
+
+        File goldenFile = null;
+        if (includeJavaVersion) {
+            String version = System.getProperty("java.specification.version");
+            for (String variant : computeVersionVariantsFor(version)) {
+                goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + variant + ext);
+                if (goldenFile.exists()) {
+                    break;
+                }
+            }
+        }
+        if (goldenFile == null || !goldenFile.exists()) {
+            goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + ext);
+        }
+        if (!goldenFile.exists()) {
+            if (!goldenFile.createNewFile()) {
+                NbTestCase.fail("Cannot create file " + goldenFile);
+            }
+            FileWriter fw = new FileWriter(goldenFile);
+            try {
+                fw.write(description);
+            } finally {
+                fw.close();
+            }
+            if (failOnMissingGoldenFile()) {
+                NbTestCase.fail("Created generated golden file " + goldenFile + "\nPlease re-run the test.");
+            }
+            return;
+        }
+
+        String expected = readFile(goldenFile);
+
+        // don't trim in this EOF test
+        String expectedTrimmed = expected;
+        String actualTrimmed = description;

Review Comment:
   https://github.com/apache/netbeans/blob/2926b6df47f3bfcf9ce8ec3db048108cc536628d/ide/csl.api/test/unit/src/org/netbeans/modules/csl/api/test/CslTestBase.java#L925-L926
   
   Expected and actual results are trimmed in the original `assertDescriptionMatches()`. If there is a newline at EOF, we cannot test correctly.  So, I override this method and copy related methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] tmysik commented on pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#issuecomment-1508113564

   @junichi11 Just one note - aren't we able to sort PSR hints in the dialog? I mean, currently, we have PSR-12 before PSR-4. It would be great, if we could sorry it "by PSR number".
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on a diff in pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#discussion_r1166660635


##########
php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java:
##########
@@ -3113,6 +3118,36 @@ private String createWhitespace(DocumentOptions docOptions, int lines, int space
         return sb.toString();
     }
 
+    private void resolveNoNewlineAtEOF(BaseDocument document) {

Review Comment:
   Will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 merged pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 merged PR #5824:
URL: https://github.com/apache/netbeans/pull/5824


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] tmysik commented on a diff in pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "tmysik (via GitHub)" <gi...@apache.org>.
tmysik commented on code in PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#discussion_r1166454448


##########
php/php.editor/src/org/netbeans/modules/php/editor/indent/TokenFormatter.java:
##########
@@ -3113,6 +3118,36 @@ private String createWhitespace(DocumentOptions docOptions, int lines, int space
         return sb.toString();
     }
 
+    private void resolveNoNewlineAtEOF(BaseDocument document) {

Review Comment:
   Nitpick:
   
   ```suggestion
       private void resolveNoNewLineAtEOF(BaseDocument document) {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on a diff in pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on code in PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#discussion_r1166184122


##########
php/php.editor/test/unit/src/org/netbeans/modules/php/editor/indent/PHPFormatterBlankLinesEOFTest.java:
##########
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.php.editor.indent;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.regex.Pattern;
+import static junit.framework.TestCase.fail;
+import org.netbeans.junit.NbTestCase;
+import static org.netbeans.modules.csl.api.test.CslTestBase.readFile;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+public class PHPFormatterBlankLinesEOFTest extends PHPFormatterTestBase {
+
+    public PHPFormatterBlankLinesEOFTest(String testName) {
+        super(testName);
+    }
+
+    public void testEOF_01a() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, false);
+        reformatFileContents("testfiles/formatting/blankLines/eof_01.php", options, false, true);
+    }
+
+    public void testEOF_01b() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, true);
+        reformatFileContents("testfiles/formatting/blankLines/eof_01.php", options, false, true);
+    }
+
+    public void testEOF_02a() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, false);
+        reformatFileContents("testfiles/formatting/blankLines/eof_02.php", options, false, true);
+    }
+
+    public void testEOF_02b() throws Exception {
+        HashMap<String, Object> options = new HashMap<>(FmtOptions.getDefaults());
+        options.put(FmtOptions.BLANK_LINES_EOF, true);
+        reformatFileContents("testfiles/formatting/blankLines/eof_02.php", options, false, true);
+    }
+
+    @Override
+    protected void assertDescriptionMatches(String relFilePath,
+            String description, boolean includeTestName, boolean includeJavaVersion, String ext, boolean checkFileExistence, boolean skipMarkers) throws Exception {
+        File rubyFile = getDataFile(relFilePath);
+        if (checkFileExistence && !rubyFile.exists()) {
+            NbTestCase.fail("File " + rubyFile + " not found.");
+        }
+
+        File goldenFile = null;
+        if (includeJavaVersion) {
+            String version = System.getProperty("java.specification.version");
+            for (String variant : computeVersionVariantsFor(version)) {
+                goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + variant + ext);
+                if (goldenFile.exists()) {
+                    break;
+                }
+            }
+        }
+        if (goldenFile == null || !goldenFile.exists()) {
+            goldenFile = getDataFile(relFilePath + (includeTestName ? ("." + getName()) : "") + ext);
+        }
+        if (!goldenFile.exists()) {
+            if (!goldenFile.createNewFile()) {
+                NbTestCase.fail("Cannot create file " + goldenFile);
+            }
+            FileWriter fw = new FileWriter(goldenFile);
+            try {
+                fw.write(description);
+            } finally {
+                fw.close();
+            }
+            if (failOnMissingGoldenFile()) {
+                NbTestCase.fail("Created generated golden file " + goldenFile + "\nPlease re-run the test.");
+            }
+            return;
+        }
+
+        String expected = readFile(goldenFile);
+
+        // don't trim in this EOF test
+        String expectedTrimmed = expected;
+        String actualTrimmed = description;

Review Comment:
   Expected and actual results are trimmed in the original `assertDescriptionMatches()`. If there is a newline at EOF, we cannot test correctly.  So, I override this method and copy related methods.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#issuecomment-1508319126

   Or, add space after `-`
   
   ```
   csl-hints/text/x-php5/hints/psr0=PSR- 0: Autoloading Standard
   csl-hints/text/x-php5/hints/psr1=PSR- 1: Basic Coding Standard
   csl-hints/text/x-php5/hints/psr4=PSR- 4: Autoloader
   csl-hints/text/x-php5/hints/psr12=PSR-12: Extended Coding Style
   ```
   ![nb-php-gh-4641-sort-psrs](https://user-images.githubusercontent.com/738383/232024534-f6e27097-f0fb-4349-9c00-d13a49de6bf5.png)
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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


[GitHub] [netbeans] junichi11 commented on pull request #5824: Add the "End of File" blank line formatting option #4641

Posted by "junichi11 (via GitHub)" <gi...@apache.org>.
junichi11 commented on PR #5824:
URL: https://github.com/apache/netbeans/pull/5824#issuecomment-1508437016

   @tmysik 
   
   > Personally, I don't like the extra space but like the sorting
   
   Me, too...
   I'll merge this as it is :) Thanks!
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
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