You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "adparts (via GitHub)" <gi...@apache.org> on 2024/08/07 16:05:28 UTC

[I] Convert to text block hint does not work inside Annotations [netbeans]

adparts opened a new issue, #7643:
URL: https://github.com/apache/netbeans/issues/7643

   ### Apache NetBeans version
   
   Apache NetBeans 22
   
   ### What happened
   
   Clicking this code hint:
   ![image](https://github.com/user-attachments/assets/12ae7f30-5b88-464c-9743-7ce09cc9bf7b)
   
   Does not change anything in the editor. This hint does not work when the string is the **Annotation default value.** 
   
   
   ### Language / Project Type / NetBeans Component
   
   _No response_
   
   ### How to reproduce
   
   Use this (nonsense) code and click the convert to text block hint:
   
   ```java
       @SuppressWarnings("This is an example\n"
               + "that does not work\n"
               + "converting to a text block")
       public static void main(String[] args) {
   
       }
   ```
   
   ### Did this work correctly in an earlier version?
   
   No / Don't know
   
   ### Operating System
   
   Fedora Core 40
   
   ### JDK
   
   21
   
   ### Apache NetBeans packaging
   
   Apache NetBeans Snap Package
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   No


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


Re: [I] Convert to text block hint does not work inside Annotations [netbeans]

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on issue #7643:
URL: https://github.com/apache/netbeans/issues/7643#issuecomment-2401586228

   javac is likely inserting "value =" as synthetic tree which causes trouble in the diff.
   
   ```
   java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 24
   	at org.netbeans.modules.java.source.pretty.CharBuffer.append0(CharBuffer.java:110)
   	at org.netbeans.modules.java.source.pretty.CharBuffer.append(CharBuffer.java:128)
   	at org.netbeans.modules.java.source.pretty.VeryPretty.print(VeryPretty.java:265)
   	at org.netbeans.modules.java.source.pretty.VeryPretty.visitLiteral(VeryPretty.java:1907)
   	at com.sun.tools.javac.tree.JCTree$JCLiteral.accept(JCTree.java:2732)
   	at org.netbeans.modules.java.source.pretty.VeryPretty.doAccept(VeryPretty.java:415)
   	at org.netbeans.modules.java.source.pretty.VeryPretty.print(VeryPretty.java:284)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTreeImpl0(CasualDiff.java:5552)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTreeImpl(CasualDiff.java:5500)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:5427)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:5398)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffAssign(CasualDiff.java:2606)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTreeImpl0(CasualDiff.java:5690)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTreeImpl(CasualDiff.java:5500)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:5427)
   	at org.netbeans.modules.java.source.save.CasualDiff.diffTree(CasualDiff.java:5410)
   	at org.netbeans.modules.java.source.save.CasualDiff.diff(CasualDiff.java:353)
   	at org.netbeans.api.java.source.WorkingCopy.processCurrentCompilationUnit(WorkingCopy.java:907)
   	at org.netbeans.api.java.source.WorkingCopy.getChanges(WorkingCopy.java:1321)
   	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:672)
   	at org.netbeans.api.java.source.JavaSource$1.run(JavaSource.java:661)
   	at org.netbeans.api.java.source.JavaSource$MultiTask.run(JavaSource.java:504)
   	at org.netbeans.modules.parsing.impl.TaskProcessor.callUserTask(TaskProcessor.java:586)
   	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:197)
   	at org.netbeans.modules.parsing.api.ParserManager$UserTaskAction.run(ParserManager.java:180)
   	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:181)
   	at org.netbeans.modules.parsing.impl.TaskProcessor$2.call(TaskProcessor.java:178)
   	at org.netbeans.modules.masterfs.filebasedfs.utils.FileChangedManager.priorityIO(FileChangedManager.java:153)
   	at org.netbeans.modules.masterfs.providers.ProvidedExtensions.priorityIO(ProvidedExtensions.java:335)
   	at org.netbeans.modules.parsing.nb.DataObjectEnvFactory.runPriorityIO(DataObjectEnvFactory.java:118)
   	at org.netbeans.modules.parsing.impl.Utilities.runPriorityIO(Utilities.java:67)
   	at org.netbeans.modules.parsing.impl.TaskProcessor.runUserTask(TaskProcessor.java:178)
   	at org.netbeans.modules.parsing.api.ParserManager.parse(ParserManager.java:83)
   	at org.netbeans.api.java.source.JavaSource.runUserActionTaskImpl(JavaSource.java:454)
   	at org.netbeans.api.java.source.JavaSource.runUserActionTask(JavaSource.java:425)
   	at org.netbeans.api.java.source.JavaSource.runModificationTask(JavaSource.java:680)
   	at org.netbeans.modules.java.hints.spiimpl.JavaFixImpl.implement(JavaFixImpl.java:73)
   [catch] at org.netbeans.modules.editor.hints.HintsUI$1.run(HintsUI.java:810)
   	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
   	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
   	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
   	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)
   ```
   I checked where the -1 was coming from and its from here:
   
   ```
   	at org.netbeans.modules.java.source.pretty.CharBuffer.trimTo(CharBuffer.java:214)
   	at org.netbeans.modules.java.source.pretty.CharBuffer.eatAwayChars(CharBuffer.java:263)
   	at org.netbeans.modules.java.source.pretty.VeryPretty.eatChars(VeryPretty.java:2931)
   	at org.netbeans.modules.java.source.save.CasualDiff.copyTo(CasualDiff.java:6171)
   ```
   which brings us to this:
   https://github.com/apache/netbeans/blob/8cab2aeccdae1386d0383ac8eec91c8f9f3edbaa/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java#L6163-L6171
   
   and further down the stack:
   https://github.com/apache/netbeans/blob/8cab2aeccdae1386d0383ac8eec91c8f9f3edbaa/java/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java#L2587-L2605


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