Replies: 2 comments 4 replies
-
I already had a look and found this function |
Beta Was this translation helpful? Give feedback.
-
Little example where the comments should always be part of the indentation, also if you see code with comments they are aligned to 99%. private void test2() {
// Erstellen Sie eine neue Instanz von JToolBar
JPanel toolBar2 = new JPanel();
// Setzen Sie die Größe und die Farbe der neuen Toolbar
toolBar2.setPreferredSize(new Dimension(100, 30));
toolBar2.setBackground(Color.LIGHT_GRAY);
toolBar2.add(new JLabel("dasdadsasd"));
// Holen Sie sich das Hauptfenster der Anwendung
JFrame mainWindow = (JFrame) WindowManager.getDefault().getMainWindow();
// Holen Sie sich das Container-Panel des Hauptfensters
Container contentPane = mainWindow.getContentPane();
// Fügen Sie das toolBar2-Panel dem Container-Panel hinzu
contentPane.add(toolBar2, BorderLayout.PAGE_START);
// Aktualisieren Sie das Fenster, um die Änderungen anzuzeigen
JToolBar mainToolBar = (JToolBar) mainWindow.getContentPane().getComponent(1);
// Fügen Sie die Toolbar dem Container-Panel hinzu
contentPane.add(mainToolBar, BorderLayout.PAGE_END);
// Aktualisieren Sie das Fenster, um die Änderungen anzuzeigen
mainWindow.revalidate();
} I copied the code within the test2 method from a ChatGPT example. So everything started at linestart. After formatting, it just formatted the code and not the comments and this looks very ugly and is really not useful IMHO. |
Beta Was this translation helpful? Give feedback.
-
As the title says, commenting code should respect the indentation of the code.
There are some excetptions but I will cover this later.
Atm the current comment logic for Java and CSL languages (w/o block comment) behaves like this:
it searches for the linestart and adds the comment prefix to the code. If I comment
the whole file, this is not a problem but if I just comment an inner code block, it will looks like this:
the problem here bevahes after formatting the code:
The code reformats because comments should be also part of the indentation and when I remove the comments
it needs to be reformatted again. So the wanted behaviour should be this:
This code doesn't needs to be reformatted because it is on the same indentation as a block.
Yes there are some other cases where it still needs to reformatted but this is ok:
After reformatting it looks like this:
For HTML and CSS/LESS/SCSS/SASS it looks like this and behaves a bit better:
But for multiline it looks like this then:
The code for CSL is somewhere around here:
netbeans/ide/csl.api/src/org/netbeans/modules/csl/api/ToggleBlockCommentAction.java
Line 507 in 4f8fbb4
For Java needs to look deeper.
Beta Was this translation helpful? Give feedback.
All reactions