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/01 00:16:10 UTC

[GitHub] [netbeans] junichi11 opened a new pull request, #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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

   - https://github.com/apache/netbeans/issues/4609
   - PSR-12: https://www.php-fig.org/psr/psr-12/#3-declare-statements-namespace-and-import-statements
   - Fix the formatter
   - Fix the preview file
   
   ![nb-php-gh-4609-formatter](https://user-images.githubusercontent.com/738383/229252235-7d98a26d-3753-473d-9a23-67c132f84331.png)
   
   - Fix "Fix imports"
   - Add `FixImportsBottomPanel` as a bottom panel of `FixDuplicateImportsStmts`
   
   Example:
   ```php
   <?php
   class TestClass implements MyInterface {
       use MyTrait;
       public function test(): void {
           $a = new MyClass();
           CONSTANT_B;
       }
   }
   CONSTANT_A;
   MyEnum::Case1;
   functionA();
   ```
   Inserted (Checked "Put in PSR-12 order"):
   ```php
   <?php
   namespace Test;
   
   use Vendor\Package\{
       Classes\MyClass,
       Enums\MyEnum,
       Interfaces\MyInterface,
       Traits\MyTrait
   };
   
   use function Vendor\Package\Functions\functionA;
   
   use const Vendor\Package\Constants\{
       CONSTANT_A,
       CONSTANT_B
   };
   
   class TestClass implements MyInterface {
       use MyTrait;
       public function test(): void {
           $a = new MyClass();
           CONSTANT_B;
       }
   }
   CONSTANT_A;
   MyEnum::Case1;
   functionA();
   ```
   
   Before:
   ![nb-php-gh-4609-fix-imports-before](https://user-images.githubusercontent.com/738383/229252385-c1117831-4e56-49eb-be53-1f81b2c20d21.png)
   
   After:
   ![nb-php-gh-4609-fix-imports-after](https://user-images.githubusercontent.com/738383/229252613-43ec8e9d-aad4-476e-b137-ddb63c86e4d3.png)
   
   - Don't add a space before `{`
   - Don't generate full class names in the panel
   
   #### NOTE
   The following is not supported yet.
   
   ```
   Compound namespaces with a depth of more than two MUST NOT be used. Therefore the following is the maximum compounding depth allowed:
   ```
   ```php
   <?php
   
   use Vendor\Package\SomeNamespace\{
       SubnamespaceOne\ClassA,
       SubnamespaceOne\ClassB,
       SubnamespaceTwo\ClassY,
       ClassZ,
   };
   ```
   


-- 
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 merged pull request #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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


-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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


##########
php/php.editor/src/org/netbeans/modules/php/editor/actions/FixDuplicateImportStmts.java:
##########
@@ -121,12 +117,10 @@ public void focusLost(FocusEvent arg0) {
         // load localized text into widgets:
         lblTitle.setText(getBundleString("FixDupImportStmts_IntroLbl")); //NOI18N
         lblHeader.setText(getBundleString("FixDupImportStmts_Header")); //NOI18N
-
-        checkUnusedImports = new JCheckBox();
-        Mnemonics.setLocalizedText(checkUnusedImports, getBundleString("FixDupImportStmts_UnusedImports")); //NOI18N
-        bottomPanel.add(checkUnusedImports, BorderLayout.WEST);
-        checkUnusedImports.setEnabled(true);
-        checkUnusedImports.setSelected(removeUnusedImports);
+        fixImportsBottomPanel = new FixImportsBottomPanel(combos, importData);

Review Comment:
   Makes sense. We can more easily change it, if needed (e.g. more checkboxes to be added).
   



-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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


##########
php/php.editor/src/org/netbeans/modules/php/editor/actions/FixImportsBottomPanel.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * 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.actions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.GroupLayout;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JPanel;
+import javax.swing.LayoutStyle;
+import org.openide.awt.Mnemonics;
+import org.openide.util.NbBundle;
+
+class FixImportsBottomPanel extends JPanel {
+
+    private final JComboBox[] comboBoxes;
+    private final ImportData importData;
+    private ImportData.ItemVariant[] defaultVariants;
+    private ImportData.ItemVariant[] dontUseVariants;
+    private static final long serialVersionUID = 7771810767310773171L;
+

Review Comment:
   Nitpick: a static field, should be before the instance ones.
   



-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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

   @junichi11 Nothing to fix and nothing to thank for, of course :)


-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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


##########
php/php.editor/src/org/netbeans/modules/php/editor/actions/FixDuplicateImportStmts.java:
##########
@@ -121,12 +117,10 @@ public void focusLost(FocusEvent arg0) {
         // load localized text into widgets:
         lblTitle.setText(getBundleString("FixDupImportStmts_IntroLbl")); //NOI18N
         lblHeader.setText(getBundleString("FixDupImportStmts_Header")); //NOI18N
-
-        checkUnusedImports = new JCheckBox();
-        Mnemonics.setLocalizedText(checkUnusedImports, getBundleString("FixDupImportStmts_UnusedImports")); //NOI18N
-        bottomPanel.add(checkUnusedImports, BorderLayout.WEST);
-        checkUnusedImports.setEnabled(true);
-        checkUnusedImports.setSelected(removeUnusedImports);
+        fixImportsBottomPanel = new FixImportsBottomPanel(combos, importData);

Review Comment:
   I've moved the checkbox and buttons of the bottom panel to the new panel to fix them more easily.



-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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

   @tmysik I'll fix it when I change that file next time :) Thank you, Tomas!


-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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


##########
php/php.editor/src/org/netbeans/modules/php/editor/actions/FixDuplicateImportStmts.form:
##########
@@ -31,9 +31,10 @@
   </Properties>
   <AuxValues>
     <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
-    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="false"/>

Review Comment:
   We are changing the default value here - no problem, I think. If there are any complaints, we could store it in the userdir so it is kept between individual invocations (if we are not doing it already :)



-- 
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 #5758: Separate between class-based, function-based, and const-based use statements by a single blank line #4609

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

   @junichi11 I am merging, my comments are just nitpicks :)
   


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