Skip to content

Basic indenter for RARS - #116

Open
ElTitoDG wants to merge 4 commits into
rarsm:masterfrom
ElTitoDG:indenter
Open

Basic indenter for RARS#116
ElTitoDG wants to merge 4 commits into
rarsm:masterfrom
ElTitoDG:indenter

Conversation

@ElTitoDG

Copy link
Copy Markdown

Implemented basic indenter for RARS
Solution to #23

@github-actions

github-actions Bot commented May 19, 2025

Copy link
Copy Markdown

Test Results

12 files  ±0  12 suites  ±0   37s ⏱️ -10s
 8 tests ±0   8 ✅ ±0  0 💤 ±0  0 ❌ ±0 
24 runs  ±0  24 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit ccec0be. ± Comparison against base commit 814d573.

♻️ This comment has been updated with latest results.

@privat privat left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have exception that pop

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: 2 > 1
	at java.base/java.util.Arrays.copyOfRange(Arrays.java:3804)
	at java.base/java.util.Arrays.copyOfRange(Arrays.java:3764)
	at rars.util.Indenter.indent(Indenter.java:57)
	at rars.util.Indenter.indentAssembly(Indenter.java:107)
	at rars.venus.VenusUI$24.actionPerformed(VenusUI.java:511)

it seems to fail when there is a loce label for instance

foo:
        bar

Comment thread src/rars/venus/VenusUI.java
Comment thread src/rars/venus/VenusUI.java Outdated
Comment thread src/rars/venus/VenusUI.java Outdated
Comment thread src/rars/util/Indenter.java Outdated
Comment thread src/rars/util/Indenter.java
Comment thread src/rars/util/Indenter.java Outdated
Comment thread src/rars/venus/VenusUI.java Outdated
@ElTitoDG

ElTitoDG commented Jul 9, 2025

Copy link
Copy Markdown
Author

Resolve all the request by @privat
Before:
Screenshot 2025-07-09 at 19 24 49
After:
Screenshot 2025-07-09 at 19 25 16


// Handle empty lines and comments/directives
if (trimmedLine.isEmpty() || trimmedLine.startsWith("#")) {
if (trimmedLine.isEmpty() || trimmedLine.startsWith("#") || trimmedLine.startsWith("//")) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"//" is an invalid language element, there should not be a special case for it.

Comment thread src/rars/util/Indenter.java Outdated
*/
public class Indenter {
// Column positions for alignment
private static final int LABEL_COLUMN = 0; // Column for labels

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All labels should be aligned the same way, starting at 0 made sense. Now we can have inconsistency in the indentation of the labels.

@@ -502,7 +466,7 @@ public void handler(boolean value) {
"Information about Rars", null, null, mainUI);

// Nueva acción para el indentador

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments here are still in Spanish

for (int i = 0; i < line.length(); i++) {
char c = line.charAt(i);

if (!inQuotes && (c == '"' || c == '\'')) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The single quotes are invalid language element, you can remove it from here.

quoteChar = c;
} else if (inQuotes && c == quoteChar) {
// Check if it's escaped
if (i == 0 || line.charAt(i - 1) != '\\') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i == 0 is always false here, you can remove it

if (codePart.isEmpty() && !commentPart.isEmpty()) {
indentedLines.add(line);
continue;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants