Skip to content

Conversation

@hexaredecimal
Copy link
Collaborator

@hexaredecimal hexaredecimal commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • Added dockable panels for file tree browsing, version control, and plugins.
    • Introduced a custom output stream with ANSI color support in the message pane.
    • Improved tab management and editor robustness.
  • Bug Fixes

    • Enhanced error handling for unsaved files during compilation.
    • Improved handling of null editor selections and tab creation.
  • Chores

    • Removed support for the Piccode scripting language, including its parser, runtime, standard library modules, and all related tests.
    • Updated build configuration and dependencies.
    • Cleaned up unused files and internal logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 31, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update removes the entire PiccodeScript language parsing, runtime, and AST infrastructure, including all ANTLR grammar, parser, and lexer files, as well as all Java code for AST nodes, runtime value types, modules, and native function modules. It also deletes all standard library .pics files and their associated modules. The editor's UI is restructured, with new dockable panels and improved output streaming. The build configuration is updated to use JitPack and a prebuilt PiccodeScript dependency, eliminating ANTLR plugin usage.

Changes

Cohort / File(s) Change Summary
PiccodeScript Grammar & ANTLR Artifacts
src/main/antlr4/PiccodeScript.g4, src/main/java/org/piccode/antlr4/PiccodeScript*.java, src/main/java/org/piccode/antlr4/PiccodeScript*.interp, src/main/java/org/piccode/antlr4/PiccodeScript*.tokens
Removed all ANTLR grammar, parser, lexer, listener, and visitor files for PiccodeScript, including generated artifacts and token definitions.
AST Implementation
src/main/java/org/piccode/ast/*
Deleted all AST node classes, visitor, and related test files, eliminating all code for parsing and representing PiccodeScript programs as ASTs.
Runtime Value Types & Context
src/main/java/org/piccode/rt/*
Removed all runtime value classes (arrays, numbers, booleans, objects, strings, tuples, units, closures), context management, native function infrastructure, exception classes, and related modules.
Native Function Modules
src/main/java/org/piccode/rt/modules/*
Deleted all modules for native functions (array, color, graphics, IO, math, resource, string, tuple), including factories and registration logic.
Standard Library Scripts
pkg/array/array.pics, pkg/color/color.pics, pkg/gfx/color.pics, pkg/gfx/image.pics, pkg/gfx/shapes.pics, pkg/io/io.pics, pkg/math/math.pics, pkg/res/resource.pics, pkg/string/string.pics, pkg/tuple/tuple.pics
Removed all .pics standard library modules for arrays, colors, graphics, IO, math, resources, strings, and tuples.
Compiler and Parsing Logic
src/main/java/org/piccode/backend/Compiler.java, src/main/java/org/editor/errors/EditorParser.java, src/main/java/org/editor/errors/IDEErrorListener.java
Deleted the PiccodeScript compiler, error listener, and disabled all parsing logic in the editor.
Editor Panels and UI
src/main/java/org/editor/panels/FileTreePanel.java, src/main/java/org/editor/panels/VCPanel.java, src/main/java/org/editor/panels/PluginsPanel.java, src/main/java/org/editor/EditorWindow.java, src/main/java/org/editor/CodeEditor.java
Added new dockable panels for file tree, version control, and plugins. Refactored editor window to use these panels, improved error handling, and updated tab logic.
Editor Output Handling
src/main/java/org/editor/AccessFrame.java
Introduced AccessFrameOutputStream for styled, thread-safe output with ANSI color support in the editor. Minor formatting adjustments.
CanvasFrame Execution Flow
src/main/java/org/editor/CanvasFrame.java
Replaced direct code execution with asynchronous compilation using new static fields and a compileFrame method.
Editor Actions and Events
src/main/java/org/editor/events/Actions.java, src/main/java/org/editor/events/MenuEvents.java, src/main/java/org/editor/events/AccessEvents.java
Updated action handlers, added "New File" logic, improved compile and render event handling, and integrated new output stream.
Icon Set
src/main/java/org/editor/icons/Icons.java
Added "markdown" to the set of available icons.
Syntax Highlighting
src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java
Updated keywords and reserved word highlighting to reflect language changes.
Build Configuration
pom.xml
Switched to JitPack for dependencies, added PiccodeScript as a dependency, and removed ANTLR Maven plugin.
Test Suites
src/test/java/org/piccode/ast/TopLevel.java, src/test/java/org/piccode/rt/Runtime.java
Deleted all AST and runtime test classes.
Main Application Entry
src/main/java/org/piccode/piccode/Piccode.java
Updated main method to configure the compiler and output stream before launching the editor.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EditorWindow
    participant CanvasFrame
    participant Compiler (external)
    participant AccessFrameOutputStream

    User->>EditorWindow: Triggers compile or render action
    EditorWindow->>CanvasFrame: Sets file, code, start=true
    CanvasFrame->>CanvasFrame: paintComponent() detects start==true
    CanvasFrame->>CanvasFrame: Schedules compileFrame() on new thread
    CanvasFrame->>Compiler: compile(file, code)
    Compiler-->>CanvasFrame: Compilation result
    Compiler->>AccessFrameOutputStream: Writes output/logs
    CanvasFrame->>CanvasFrame: Resets start=false
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~90+ minutes

Poem

In the warren deep, the code did sleep,
But now the old roots are cleared away—
No more PiccodeScript to keep,
The ASTs and runtimes hop astray.
New panels sprout and icons gleam,
Output streams with colors beam!
The garden’s fresh for future dreams.

((\
( -.-)
o_(")(")

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Sibusiso

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@hexaredecimal hexaredecimal merged commit bc2d80c into main Jul 31, 2025
1 check passed
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 22

🔭 Outside diff range comments (1)
src/main/java/org/editor/errors/EditorParser.java (1)

22-54: Critical functionality regression: Syntax error detection completely disabled.

The parse method now returns an empty result without performing any syntax analysis. This means:

  1. No syntax error highlighting in the editor
  2. No real-time feedback for developers
  3. Poor developer experience compared to before

The commented-out ANTLR code suggests this is temporary, but shipping without syntax error detection is a significant regression.

Consider one of these approaches:

  1. Implement new parsing logic to replace the removed ANTLR infrastructure
  2. Add a TODO comment explaining the temporary nature and timeline for restoration
  3. Add logging to indicate parsing is disabled
 public ParseResult parse(RSyntaxDocument doc, String style) {
   DefaultParseResult result = new DefaultParseResult(this);
+  // TODO: Syntax parsing temporarily disabled due to ANTLR removal
+  // Need to implement new parsing logic for error detection
   
   try {
     String code = doc.getText(0, doc.getLength());
   } catch (BadLocationException ex) {
     System.getLogger(EditorParser.class.getName()).log(System.Logger.Level.ERROR, (String) null, ex);
   }
🧹 Nitpick comments (16)
src/main/java/org/editor/events/MenuEvents.java (1)

136-139: Consider future implementation and method visibility.

The current implementation correctly delegates to EditorWindow.addTab(e) to create a new editor tab. The TODO comment indicates plans for a file creator dialog.

Two considerations:

  1. Would you like me to help design the file creator dialog mentioned in the TODO?
  2. Consider making this method public for consistency with other event handler methods in this class like gotoLineEvent, aboutDialog, closeTab, etc.
src/main/java/org/editor/CodeEditor.java (1)

136-143: Consider refactoring to reduce code duplication.

The method correctly creates and configures a new DockKey, but duplicates logic from the constructor (lines 105-120).

Consider extracting the common DockKey creation logic into a private helper method:

+	private DockKey createDockKey(String name) {
+		String tip = "Source code editor"; 
+		var icon = Icons.getIcon("code-file");
+		var key = new DockKey(name, name, tip, icon);
+		key.setCloseEnabled(true);
+		key.setAutoHideEnabled(true);
+		return key;
+	}
+
 	public void setKey(String name) {
-		String tip = "Source code editor"; 
-		var icon = Icons.getIcon("code-file");
-		key = new DockKey(name, name, tip, icon);
-		key.setCloseEnabled(true);
-		key.setAutoHideEnabled(true);
+		key = createDockKey(name);
 		this.putClientProperty("dockKey", key);
 	}

Then update the constructor to use the same helper method.

examples/factorial.pics (1)

8-12: Address variable name reuse and consider large computation implications.

Two issues to consider:

  1. Variable name reuse: The variable result is declared twice (lines 8 and 11). Depending on the language's scoping rules, this may cause shadowing or redeclaration issues.

  2. Large computation: factorial(100) produces an extremely large number (9.33 × 10^157). Ensure the runtime can handle such large integers without overflow or performance issues.

Consider using different variable names and potentially adding a comment about the large number:

 let result = factorial(5)
 IO.println(result)

-let result = factorial(100)
-IO.println(result)
+let large_result = factorial(100)  // Very large number: ~9.33 × 10^157
+IO.println(large_result)
src/main/java/org/editor/panels/PluginsPanel.java (1)

9-17: LGTM! Clean foundation for plugins panel.

The class structure follows the established pattern for dockable panels with appropriate parameters (title, tooltip, icon). The TODO comment clearly indicates future implementation is needed.

When you're ready to implement the plugins functionality, I can help design the UI components and plugin management logic.

src/main/java/org/editor/panels/VCPanel.java (1)

9-17: LGTM! Consistent pattern for version control panel.

The class follows the established dockable panel pattern with Git-focused parameters (title, tooltip, icon). The TODO comment appropriately indicates future implementation is needed.

When implementing the version control features, I can help design Git integration components and workflow UI elements.

examples/arrays.pics (1)

12-12: Fix typo in variable name.

The variable name has a spelling error.

-let collon_sep = Array.join(strings, ":")
+let colon_sep = Array.join(strings, ":")
examples/showcase.pics (1)

19-21: Potential variable shadowing issue.

The variable numbers is redefined from an array to a tuple, which might confuse readers about variable scoping and shadowing behavior.

Consider using different variable names to avoid confusion:

 // Arrays
 let numbers = [1,2,3]
 let first = numbers.0
 let joined = first:numbers

 // Tuples
-let numbers = (1,2,3)
-let first = numbers.0
+let tuple_nums = (1,2,3)
+let tuple_first = tuple_nums.0
pkg/math/math.pics (2)

32-33: Consider using a constant for PI value.

The hardcoded PI value 3.141592653589793 is duplicated between degToRad and radToDeg functions. Consider defining a module-level constant for better maintainability.

+  const PI = 3.141592653589793
+
-  function degToRad(deg=0) = deg * (3.141592653589793 / 180)
-  function radToDeg(rad=0) = rad * (180 / 3.141592653589793)
+  function degToRad(deg=0) = deg * (PI / 180)
+  function radToDeg(rad=0) = rad * (180 / PI)

35-36: Potential duplication with Number module.

The isEven and isOdd functions here duplicate the same functionality provided in the Number module. Consider whether these belong in both modules or if there should be a single canonical location.

pkg/number/number.pics (1)

6-7: Duplication between Math and Number modules.

The isEven and isOdd functions are duplicated between this module and the Math module. Consider establishing a clear separation of concerns - typically, basic numeric predicates belong in a Number module while mathematical functions belong in Math.

Also applies to: 35-36

src/main/java/org/editor/panels/FileTreePanel.java (2)

38-38: Fix typo in error message.

There's a typo in the error message: "extit" should be "exist".

-  System.err.println("error: " + file + " does not extit");
+  System.err.println("error: " + file + " does not exist");

30-30: Consider performance implications for large directory structures.

Loading the entire directory tree synchronously from the current working directory could cause UI blocking for large projects. Consider implementing lazy loading where subdirectories are loaded only when expanded.

Also applies to: 46-52

src/main/java/org/editor/AccessFrame.java (2)

224-248: Consider extending ANSI escape code support.

The current implementation only supports foreground colors. For more complete terminal emulation, consider supporting:

  • Background colors (40-47, 100-107)
  • Text styles (1=bold, 3=italic, 4=underline)
  • Proper reset handling for individual attributes

Would you like me to provide an enhanced implementation that supports these additional ANSI features?


150-150: Consider making the PrintStream configurable

The static PrintStream out is hardcoded. Consider making it configurable or providing a factory method for better testability.

-		public static final PrintStream out = new PrintStream(new AccessFrameOutputStream(), true, StandardCharsets.UTF_8);
+		private static PrintStream out = new PrintStream(new AccessFrameOutputStream(), true, StandardCharsets.UTF_8);
+		
+		public static PrintStream getOutputStream() {
+			return out;
+		}
+		
+		public static void setOutputStream(PrintStream stream) {
+			out = stream;
+		}
src/main/java/org/editor/CanvasFrame.java (1)

28-35: Remove unused imports

These imports appear to be unused after the refactoring and should be removed:

  • org.piccode.ast.Ast
  • org.piccode.rt.Context
  • org.piccode.rt.PiccodeException
  • org.piccode.rt.PiccodeNumber
  • org.piccode.rt.PiccodeReturnException
  • org.piccode.rt.PiccodeUnit
  • org.piccode.rt.PiccodeValue
src/main/java/org/editor/EditorWindow.java (1)

430-430: Fix typo in method name

The method name has a typo: "setSeletedTabTitle" should be "setSelectedTabTitle".

-	public static void setSeletedTabTitle(String title) {
+	public static void setSelectedTabTitle(String title) {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 311c4c8 and c8ab299.

⛔ Files ignored due to path filters (1)
  • src/main/resources/icons/markdown.png is excluded by !**/*.png
📒 Files selected for processing (89)
  • examples/arrays.pics (1 hunks)
  • examples/factorial.pics (1 hunks)
  • examples/hello.pics (1 hunks)
  • examples/showcase.pics (1 hunks)
  • pkg/array/array.pics (1 hunks)
  • pkg/math/math.pics (1 hunks)
  • pkg/number/number.pics (1 hunks)
  • pkg/string/string.pics (1 hunks)
  • pkg/tuple/tuple.pics (1 hunks)
  • pom.xml (2 hunks)
  • src/main/antlr4/PiccodeScript.g4 (0 hunks)
  • src/main/java/org/editor/AccessFrame.java (8 hunks)
  • src/main/java/org/editor/CanvasFrame.java (5 hunks)
  • src/main/java/org/editor/CodeEditor.java (1 hunks)
  • src/main/java/org/editor/EditorWindow.java (7 hunks)
  • src/main/java/org/editor/errors/EditorParser.java (3 hunks)
  • src/main/java/org/editor/errors/IDEErrorListener.java (0 hunks)
  • src/main/java/org/editor/events/AccessEvents.java (2 hunks)
  • src/main/java/org/editor/events/Actions.java (1 hunks)
  • src/main/java/org/editor/events/MenuEvents.java (1 hunks)
  • src/main/java/org/editor/icons/Icons.java (1 hunks)
  • src/main/java/org/editor/panels/FileTreePanel.java (1 hunks)
  • src/main/java/org/editor/panels/PluginsPanel.java (1 hunks)
  • src/main/java/org/editor/panels/VCPanel.java (1 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScript.interp (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScript.tokens (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptBaseListener.java (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptBaseVisitor.java (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptLexer.interp (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptLexer.java (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptLexer.tokens (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptListener.java (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptParser.java (0 hunks)
  • src/main/java/org/piccode/antlr4/PiccodeScriptVisitor.java (0 hunks)
  • src/main/java/org/piccode/ast/Arg.java (0 hunks)
  • src/main/java/org/piccode/ast/ArrayAst.java (0 hunks)
  • src/main/java/org/piccode/ast/Ast.java (0 hunks)
  • src/main/java/org/piccode/ast/BinOpAst.java (0 hunks)
  • src/main/java/org/piccode/ast/CallAst.java (0 hunks)
  • src/main/java/org/piccode/ast/ClosureAst.java (0 hunks)
  • src/main/java/org/piccode/ast/DoExprAst.java (0 hunks)
  • src/main/java/org/piccode/ast/DotOperationAst.java (0 hunks)
  • src/main/java/org/piccode/ast/FunctionAst.java (0 hunks)
  • src/main/java/org/piccode/ast/IdentifierAst.java (0 hunks)
  • src/main/java/org/piccode/ast/IfExpression.java (0 hunks)
  • src/main/java/org/piccode/ast/ImportAst.java (0 hunks)
  • src/main/java/org/piccode/ast/ListConstAst.java (0 hunks)
  • src/main/java/org/piccode/ast/ModuleAst.java (0 hunks)
  • src/main/java/org/piccode/ast/NamedCallArg.java (0 hunks)
  • src/main/java/org/piccode/ast/NumberAst.java (0 hunks)
  • src/main/java/org/piccode/ast/ObjectAst.java (0 hunks)
  • src/main/java/org/piccode/ast/PiccodeVisitor.java (0 hunks)
  • src/main/java/org/piccode/ast/PipeAst.java (0 hunks)
  • src/main/java/org/piccode/ast/StatementList.java (0 hunks)
  • src/main/java/org/piccode/ast/StringAst.java (0 hunks)
  • src/main/java/org/piccode/ast/TupleAst.java (0 hunks)
  • src/main/java/org/piccode/ast/UnaryAst.java (0 hunks)
  • src/main/java/org/piccode/ast/UnitAst.java (0 hunks)
  • src/main/java/org/piccode/ast/VarDecl.java (0 hunks)
  • src/main/java/org/piccode/ast/WhenAst.java (0 hunks)
  • src/main/java/org/piccode/ast/WhenCase.java (0 hunks)
  • src/main/java/org/piccode/backend/Compiler.java (0 hunks)
  • src/main/java/org/piccode/piccode/Piccode.java (1 hunks)
  • src/main/java/org/piccode/rt/Context.java (0 hunks)
  • src/main/java/org/piccode/rt/Evaluator.java (0 hunks)
  • src/main/java/org/piccode/rt/NativeFunction.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeArray.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeBoolean.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeClosure.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeException.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeModule.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeNumber.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeObject.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeString.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeTuple.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeUnit.java (0 hunks)
  • src/main/java/org/piccode/rt/PiccodeValue.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/NativeFunctionFactory.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeArrayModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeColorModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeGfxModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeIOModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeMathModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeResourceModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeStringModule.java (0 hunks)
  • src/main/java/org/piccode/rt/modules/PiccodeTupleModule.java (0 hunks)
  • src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java (4 hunks)
  • src/test/java/org/piccode/ast/TopLevel.java (0 hunks)
  • src/test/java/org/piccode/rt/Runtime.java (0 hunks)
💤 Files with no reviewable changes (65)
  • src/main/java/org/piccode/rt/PiccodeValue.java
  • src/main/java/org/piccode/ast/Ast.java
  • src/main/java/org/piccode/rt/modules/PiccodeTupleModule.java
  • src/main/java/org/piccode/ast/UnitAst.java
  • src/main/java/org/piccode/ast/Arg.java
  • src/main/java/org/piccode/rt/PiccodeException.java
  • src/main/java/org/piccode/rt/Evaluator.java
  • src/main/java/org/piccode/rt/PiccodeString.java
  • src/main/java/org/piccode/antlr4/PiccodeScript.tokens
  • src/main/java/org/piccode/ast/ObjectAst.java
  • src/main/java/org/piccode/ast/VarDecl.java
  • src/main/java/org/piccode/rt/modules/PiccodeResourceModule.java
  • src/main/java/org/piccode/ast/TupleAst.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptBaseListener.java
  • src/main/java/org/piccode/ast/WhenCase.java
  • src/main/java/org/piccode/rt/modules/PiccodeStringModule.java
  • src/main/java/org/piccode/rt/modules/PiccodeArrayModule.java
  • src/main/java/org/piccode/ast/NumberAst.java
  • src/main/java/org/piccode/ast/IdentifierAst.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptListener.java
  • src/main/java/org/piccode/ast/StringAst.java
  • src/main/java/org/piccode/ast/PipeAst.java
  • src/main/java/org/piccode/rt/modules/PiccodeGfxModule.java
  • src/main/java/org/piccode/ast/DoExprAst.java
  • src/main/java/org/piccode/ast/StatementList.java
  • src/main/java/org/piccode/rt/modules/PiccodeColorModule.java
  • src/main/antlr4/PiccodeScript.g4
  • src/main/java/org/piccode/ast/ClosureAst.java
  • src/main/java/org/piccode/rt/modules/PiccodeMathModule.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptBaseVisitor.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptVisitor.java
  • src/main/java/org/piccode/rt/PiccodeTuple.java
  • src/main/java/org/piccode/ast/ModuleAst.java
  • src/main/java/org/piccode/ast/FunctionAst.java
  • src/main/java/org/piccode/ast/ArrayAst.java
  • src/main/java/org/piccode/ast/UnaryAst.java
  • src/main/java/org/piccode/rt/PiccodeModule.java
  • src/main/java/org/piccode/rt/PiccodeBoolean.java
  • src/main/java/org/piccode/ast/NamedCallArg.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptLexer.tokens
  • src/main/java/org/piccode/ast/ListConstAst.java
  • src/main/java/org/piccode/backend/Compiler.java
  • src/main/java/org/piccode/rt/PiccodeNumber.java
  • src/main/java/org/piccode/ast/CallAst.java
  • src/main/java/org/piccode/rt/modules/NativeFunctionFactory.java
  • src/main/java/org/piccode/rt/PiccodeArray.java
  • src/main/java/org/piccode/ast/BinOpAst.java
  • src/main/java/org/piccode/rt/PiccodeUnit.java
  • src/main/java/org/piccode/ast/IfExpression.java
  • src/main/java/org/piccode/rt/PiccodeClosure.java
  • src/test/java/org/piccode/ast/TopLevel.java
  • src/main/java/org/piccode/rt/modules/PiccodeIOModule.java
  • src/main/java/org/editor/errors/IDEErrorListener.java
  • src/main/java/org/piccode/ast/ImportAst.java
  • src/main/java/org/piccode/rt/PiccodeObject.java
  • src/test/java/org/piccode/rt/Runtime.java
  • src/main/java/org/piccode/rt/Context.java
  • src/main/java/org/piccode/rt/NativeFunction.java
  • src/main/java/org/piccode/antlr4/PiccodeScript.interp
  • src/main/java/org/piccode/ast/PiccodeVisitor.java
  • src/main/java/org/piccode/ast/WhenAst.java
  • src/main/java/org/piccode/ast/DotOperationAst.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptLexer.java
  • src/main/java/org/piccode/antlr4/PiccodeScriptLexer.interp
  • src/main/java/org/piccode/antlr4/PiccodeScriptParser.java
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: the vldocking library (com.vlsolutions.swing.docking) has a distinct component management model wher...
Learnt from: hexaredecimal
PR: Glimmr-Lang/PicassoCode#1
File: src/main/java/org/editor/EditorWindow.java:204-209
Timestamp: 2025-05-14T10:49:23.453Z
Learning: The VLDocking library (com.vlsolutions.swing.docking) has a distinct component management model where UI components are added to both the frame's content pane AND registered with the DockingDesktop. Unlike standard Swing where components can only have one parent, VLDocking expects dockables to be owned by the frame while being managed by the docking desktop for layout, docking states, and behaviors.

Applied to files:

  • src/main/java/org/editor/panels/PluginsPanel.java
  • src/main/java/org/editor/panels/VCPanel.java
  • src/main/java/org/editor/panels/FileTreePanel.java
  • src/main/java/org/editor/CanvasFrame.java
  • src/main/java/org/editor/EditorWindow.java
📚 Learning: the vldocking library (com.vlsolutions.swing.docking) expects dockable components to be owned by the...
Learnt from: hexaredecimal
PR: Glimmr-Lang/PicassoCode#1
File: src/main/java/org/editor/EditorWindow.java:204-209
Timestamp: 2025-05-14T10:49:23.453Z
Learning: The VLDocking library (com.vlsolutions.swing.docking) expects dockable components to be owned by the frame while being managed by the docking desktop. Unlike standard Swing components that can only have one parent, the DockingDesktop acts as a manager for dockable components rather than being their parent in the component hierarchy.

Applied to files:

  • src/main/java/org/editor/panels/PluginsPanel.java
  • src/main/java/org/editor/panels/VCPanel.java
  • src/main/java/org/editor/panels/FileTreePanel.java
  • src/main/java/org/editor/CanvasFrame.java
  • src/main/java/org/editor/EditorWindow.java
🧬 Code Graph Analysis (6)
src/main/java/org/editor/CodeEditor.java (1)
src/main/java/org/editor/icons/Icons.java (1)
  • Icons (10-133)
src/main/java/org/piccode/piccode/Piccode.java (2)
src/main/java/org/editor/AccessFrame.java (2)
  • AccessFrame (40-279)
  • AccessFrameOutputStream (148-277)
src/main/java/org/editor/EditorWindow.java (1)
  • EditorWindow (61-562)
src/main/java/org/editor/events/Actions.java (1)
src/main/java/org/editor/events/MenuEvents.java (1)
  • MenuEvents (24-140)
src/main/java/org/editor/events/MenuEvents.java (1)
src/main/java/org/editor/EditorWindow.java (1)
  • EditorWindow (61-562)
src/main/java/org/editor/panels/FileTreePanel.java (1)
src/main/java/org/editor/icons/Icons.java (1)
  • Icons (10-133)
src/main/java/org/editor/CanvasFrame.java (1)
src/main/java/org/editor/AccessFrame.java (1)
  • AccessFrame (40-279)
🔇 Additional comments (33)
examples/hello.pics (1)

1-5: LGTM!

This is a clean, simple example demonstrating basic I/O functionality in the PiccodeScript language. The import syntax and function call structure look appropriate for a hello world example.

src/main/java/org/editor/icons/Icons.java (1)

57-57: LGTM!

The addition of the "markdown" icon to the icons array is straightforward and follows the existing pattern. This supports the UI enhancements mentioned in the PR.

src/main/java/org/editor/events/Actions.java (1)

122-122: Good refactoring to improve code organization.

Replacing the inline lambda with a method reference to MenuEvents::newFile improves maintainability by centralizing event handling logic in dedicated methods.

pom.xml (1)

14-19: LGTM! JitPack repository addition is appropriate.

Adding JitPack.io repository is the correct approach for consuming GitHub-based Maven artifacts.

examples/arrays.pics (1)

1-17: Well-structured example demonstrating array operations.

The example effectively showcases key array functionality including concatenation, length access, and joining operations. Good use of IO.println for output demonstration.

src/main/java/org/piccode/piccode/Piccode.java (1)

14-20: LGTM! Clean compiler configuration setup.

The compiler configuration is well-structured for an IDE environment:

  • exitOnError = false prevents the compiler from terminating the IDE on errors
  • ErrorAsciiKind.EMACS_COMP_STYLE provides consistent error formatting
  • Output redirection to AccessFrame.AccessFrameOutputStream.out enables styled output in the UI

The order of operations is correct - configure the compiler before launching the editor window.

src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java (2)

60-61: LGTM! Token mapping additions are consistent.

The addition of USE and IN tokens to the reserved words mapping aligns with the updated keyword list in getWordsToHighlight.


93-93: Keywords list updated to match new language features.

The keywords list now includes "in" and "use" while removing "function". This appears consistent with the language evolution shown in the example files.

examples/showcase.pics (1)

34-41: LGTM! Great demonstration of modern language features.

The function definition with default parameters, named arguments, and pipeline operator usage effectively showcases advanced language capabilities.

pkg/math/math.pics (2)

22-27: LGTM! Nested structure improves readability.

The refactored clamp function maintains the same logic while using a cleaner nested if-else structure that's easier to follow than the previous chained approach.


29-30: LGTM! Consistent formatting.

The max and min functions are now properly formatted with consistent spacing.

pkg/number/number.pics (4)

1-8: LGTM! Well-designed predicate functions.

The numeric predicate functions (isZero, isPositive, isNegative, isEven, isOdd) are correctly implemented with appropriate default parameters.


9-9: LGTM! Clever string conversion approach.

Using string concatenation (n + "") for toString is a clean way to convert numbers to strings without requiring a native function call.


11-16: Good defensive defaults for arithmetic operations.

The arithmetic functions are well-implemented with safe defaults. Particularly good that div and mod default the divisor to 1 to prevent division by zero errors.


21-25: LGTM! Complete bitwise operation coverage.

The bitwise operations (and, or, shl, shr) provide good coverage of common bit manipulation needs with consistent naming and defaults.

src/main/java/org/editor/panels/FileTreePanel.java (2)

17-33: LGTM! Well-structured panel initialization.

The constructor properly extends DockablePanel and sets up the JTree with appropriate properties including angled lines for better visual hierarchy. The integration with the Icons system is clean.


81-94: LGTM! Well-implemented file type detection.

The custom cell renderer properly handles different file types with appropriate icons. The logic correctly distinguishes between directories (with special handling for "src" folders), .pics files, .md files, and generic files. The use of pattern matching with instanceof File file is modern and clean.

pkg/tuple/tuple.pics (5)

8-11: LGTM! Clean tuple mapping implementation.

The map function correctly uses pattern matching to destructure the tuple and apply the function to both elements. The syntax is clean and idiomatic.


13-16: LGTM! Elegant zipWith implementation.

The zipWith function cleverly uses pattern matching on an array of tuples to destructure both input tuples simultaneously, then applies the function element-wise. This is a sophisticated and clean approach.


18-21: LGTM! Simple and correct swap implementation.

The swap function is straightforward and correctly swaps the tuple elements using pattern matching.


23-26: LGTM! Comprehensive equality comparison.

The equals function properly compares both elements of the tuples using the same pattern matching approach as zipWith. The logic correctly uses and to ensure both elements match.


28-31: LGTM! Consistent string representation.

The toString function provides a standard tuple representation format with parentheses and comma separation, consistent with mathematical notation.

pkg/string/string.pics (4)

8-8: LGTM! Simplified length implementation.

Refactoring to use the .len property directly instead of calling a native function is cleaner and more efficient.


15-19: LGTM! Well-implemented left padding.

The padLeft function correctly calculates the padding needed and handles edge cases where no padding is required. The use of a do block for the let binding is appropriate.


21-25: LGTM! Consistent right padding implementation.

The padRight function mirrors the padLeft logic appropriately, with the only difference being the concatenation order. Good consistency in implementation approach.


16-16: Verify module self-reference syntax for String.length

Ensure the new compiler API supports self-referencing calls to String.length(str) within the same module. If it does not, update these to the correct local invocation (e.g. length(str) or appropriate import).

Occurrences to check:

  • pkg/string/string.pics:16
  • pkg/string/string.pics:22
src/main/java/org/editor/AccessFrame.java (2)

148-178: Well-implemented output stream with proper buffering.

The AccessFrameOutputStream implementation correctly handles buffering, UTF-8 encoding, and thread safety through SwingUtilities.invokeLater.


148-277: Well-implemented ANSI output stream handler

The AccessFrameOutputStream implementation is well-designed with proper thread safety, ANSI escape code handling, and styled text output. The use of SwingUtilities.invokeLater ensures UI updates happen on the EDT.

src/main/java/org/editor/EditorWindow.java (3)

200-225: Correct implementation of VLDocking pattern.

The panels are properly added to both the frame's content pane and the DockingDesktop, following VLDocking's component management model. The auto-hide configuration is appropriate for auxiliary panels.


208-210: Multiple components added to the same BorderLayout position

Adding multiple components to BorderLayout.EAST will cause only the last one to be visible. Based on the VLDocking library usage pattern, this appears intentional for dockable registration.


303-305: Good defensive programming for null safety

The addition of null check when no editors exist prevents potential NPE.

pkg/array/array.pics (2)

4-17: Well-implemented recursive array operations.

The concat and join functions correctly use pattern matching and handle all edge cases properly. The recursive implementations are clean and efficient.


26-85: Excellent functional programming implementations.

The higher-order functions (map, filter, reduce, etc.) are implemented correctly with proper pattern matching and edge case handling. The functional style is consistent and the code is readable.


IO.println(collon_sep)

let new = collon_sep:concat
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Consider renaming variable and verify concatenation syntax.

Using new as a variable name may conflict with reserved keywords in some contexts. Also ensure the : concatenation operator syntax is correct for PiccodeScript.

-let new = collon_sep:concat
+let combined = colon_sep:concat

🏁 Script executed:

#!/bin/bash
# Description: Verify PiccodeScript language syntax for string concatenation and reserved keywords

# Search for concatenation operator usage in other example files
echo "Checking concatenation operator usage in examples..."
fd -e pics -x grep -H ":" {} \; | grep -v "import\|//"

# Search for 'new' keyword usage as variable name
echo "Checking 'new' keyword usage..."
fd -e pics -x grep -H "let new\|var new" {} \;

Length of output: 1374


Rename the new variable and correct the diff

The : operator for method references is used consistently across examples, so the syntax is valid. To avoid a reserved-word conflict and reference the existing collon_sep binding, update line 16 in examples/arrays.pics:

-let new = collon_sep:concat
+let combined = collon_sep:concat
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let new = collon_sep:concat
let combined = collon_sep:concat
🤖 Prompt for AI Agents
In examples/arrays.pics at line 16, the variable named `new` conflicts with a
reserved word. Rename this variable to a valid identifier that does not clash
with reserved keywords, and ensure the method reference using the `:` operator
with `collon_sep` remains unchanged and correctly references the existing
binding.

Comment on lines 29 to 31
is (a, b, c) -> a + " " + b + " " + c
else -> "Not a match""
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix syntax error in pattern matching.

There's a syntax error in the when expression - missing closing quote.

 when numbers {
   is (a, b, c) -> a + " " + b + " " + c
-  else -> "Not a match""
+  else -> "Not a match"
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
is (a, b, c) -> a + " " + b + " " + c
else -> "Not a match""
}
when numbers {
is (a, b, c) -> a + " " + b + " " + c
else -> "Not a match"
}
🤖 Prompt for AI Agents
In examples/showcase.pics around lines 29 to 31, there is a syntax error in the
when expression due to an extra or missing quote in the else branch string "Not
a match"". Remove the extra quote so that the string is properly closed,
ensuring correct syntax for the pattern matching expression.

is x:rest -> x : concat(rest, b)
}

function toString(arr=[]) = pic_nat_array_tostring(arr)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Native function call may fail - implement toString recursively.

The pic_nat_array_tostring native function may not exist since the runtime modules were removed. Consider implementing this recursively like the other functions.

-	function toString(arr=[]) = pic_nat_array_tostring(arr)
+	function toString(arr=[]) = "[" + join(map(arr, |x| -> x.toString()), ", ") + "]"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function toString(arr=[]) = pic_nat_array_tostring(arr)
function toString(arr=[]) = "[" + join(map(arr, |x| -> x.toString()), ", ") + "]"
🤖 Prompt for AI Agents
In pkg/array/array.pics at line 10, the toString function currently calls the
native function pic_nat_array_tostring, which may not exist due to removed
runtime modules. Replace this native call by implementing toString recursively:
define the function to handle an array by converting each element to a string
(recursively if elements are arrays) and concatenating them appropriately to
produce the full string representation.

Comment on lines 38 to 40
function factorial(n=0) =
if n <= 1 { 1 }
else { n * factorial(n - 1) }
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add safeguards for factorial function.

The recursive factorial implementation lacks protection against stack overflow for large inputs and doesn't handle negative numbers appropriately.

  function factorial(n=0) =
+   if n < 0 { 0 }  // or throw error for negative input
    if n <= 1 { 1 }
    else { n * factorial(n - 1) }

Consider adding documentation about the practical limits (typically n < 1000 to avoid stack overflow) or implementing an iterative version for better performance.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In pkg/math/math.pics around lines 38 to 40, the factorial function lacks
safeguards against negative inputs and potential stack overflow from deep
recursion. Add a check to handle negative numbers by returning an error or a
defined value. Consider rewriting the function iteratively to avoid recursion
depth issues, or document the practical input limits (e.g., n < 1000) to inform
users about performance and safety constraints.

Comment on lines 11 to 13
function repeat(str="", n=0) =
if n <= 0 { "" }
else { str + repeat(str, n - 1) }
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add safeguards for repeat function.

The recursive repeat implementation lacks protection against stack overflow for large n values and doesn't handle negative inputs.

  function repeat(str="", n=0) =
+   if n < 0 { "" }  // Handle negative input
    if n <= 0 { "" }
    else { str + repeat(str, n - 1) }

Consider implementing an iterative version for better performance with large repeat counts to avoid stack overflow.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In pkg/string/string.pics around lines 11 to 13, the recursive repeat function
risks stack overflow with large n and does not handle negative inputs properly.
Replace the recursive implementation with an iterative approach that uses a loop
to concatenate the string n times, and add a check to return an empty string if
n is negative or zero to safeguard against invalid inputs and improve
performance.

Comment on lines +32 to +34
CanvasFrame.file = file;
CanvasFrame.code = code;
CanvasFrame.start = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify thread safety of static field approach.

Using static fields (CanvasFrame.file, CanvasFrame.code, CanvasFrame.start) for inter-component communication raises concurrency concerns:

  1. Race conditions if multiple compile requests occur simultaneously
  2. State consistency issues if compilation is interrupted
  3. Memory visibility problems without proper synchronization

🏁 Script executed:

#!/bin/bash
# Check how CanvasFrame handles these static fields and thread safety
echo "Searching for CanvasFrame static field usage..."
rg -A 10 -B 2 "CanvasFrame\.(file|code|start)" . --type=java
echo "Searching for thread/synchronization in CanvasFrame..."
rg -A 5 -B 2 "Thread|synchronized|volatile|AtomicReference" . --type=java | grep -i canvas

Length of output: 2027


🏁 Script executed:

#!/bin/bash
# List all static field declarations in CanvasFrame.java
echo "=== Static field declarations ==="
rg -n "static " src/main/java/org/editor/CanvasFrame.java

# Show the compileFrame method to see how it consumes the static fields
echo -e "\n=== compileFrame() implementation ==="
rg -A 20 -B 2 "void compileFrame" src/main/java/org/editor/CanvasFrame.java

Length of output: 715


Thread-safety risk: avoid mutable static fields for compile data

Using

CanvasFrame.file = file;  
CanvasFrame.code = code;  
CanvasFrame.start = true;  

to shuttle data into a newly‐spawned thread (via SwingUtilities.invokeLater(…new Thread(() -> compileFrame())…)) exposes you to:

  • Race conditions when two compile actions fire in quick succession—one request can clobber the other’s file/code before it’s read
  • Memory‐visibility issues: no volatile or synchronization guarantees that the worker thread ever sees the latest values
  • Hard-to-trace state consistency bugs when compilation aborts or errors occur

Please refactor to eliminate these statics. For example:

  • Change compileFrame() to accept (String file, String code) parameters
  • Pass the data directly into the new thread rather than mutating globals
  • Or encapsulate requests in a thread-safe queue or use Java’s concurrency primitives (volatile, synchronized, locks) if shared state is unavoidable

Locations to update:

  • src/main/java/org/editor/events/AccessEvents.java (lines 32–34)
  • src/main/java/org/editor/CanvasFrame.java (static fields file, code, start and the new Thread(() -> compileFrame())… invocation)
🤖 Prompt for AI Agents
In src/main/java/org/editor/events/AccessEvents.java around lines 32 to 34,
avoid using mutable static fields CanvasFrame.file, CanvasFrame.code, and
CanvasFrame.start to pass data to the compile thread, as this causes
thread-safety issues. Refactor compileFrame() to accept file and code as
parameters, then pass these directly into the new thread or
SwingUtilities.invokeLater call instead of setting static fields. Also update
src/main/java/org/editor/CanvasFrame.java to remove the static fields and modify
the thread invocation accordingly to ensure data is passed safely without shared
mutable state.

Comment on lines 38 to 52
public static void compile(ActionEvent e) {
var ed = EditorWindow.getSelectedEditor();
if (ed == null) {
return;
}
var code = ed.textArea.getText();

if (ed.file == null) {
EditorWindow.current_file.setText("Cannot compiler unsaved code");
return;
}

var code = ed.textArea.getText();
AccessFrame.writeSuccess("Compilation started: ");
Compiler.compile(code, false);
Compiler.out = AccessFrame.AccessFrameOutputStream.out;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incomplete implementation: compile method doesn't actually compile.

The compile method only redirects the output stream but doesn't trigger any actual compilation. This seems incomplete compared to compileAndRender which sets the CanvasFrame fields to trigger compilation.

Either:

  1. Complete the implementation by adding compilation trigger logic
  2. Remove the method if it's no longer needed
  3. Add a TODO comment explaining the intended behavior
 public static void compile(ActionEvent e) {
   // ... null checks ...
   
   var code = ed.textArea.getText();
   AccessFrame.writeSuccess("Compilation started: ");
   Compiler.out = AccessFrame.AccessFrameOutputStream.out;
+  
+  // TODO: Add actual compilation logic or remove this method
+  // Currently only redirects output but doesn't compile
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static void compile(ActionEvent e) {
var ed = EditorWindow.getSelectedEditor();
if (ed == null) {
return;
}
var code = ed.textArea.getText();
if (ed.file == null) {
EditorWindow.current_file.setText("Cannot compiler unsaved code");
return;
}
var code = ed.textArea.getText();
AccessFrame.writeSuccess("Compilation started: ");
Compiler.compile(code, false);
Compiler.out = AccessFrame.AccessFrameOutputStream.out;
}
public static void compile(ActionEvent e) {
var ed = EditorWindow.getSelectedEditor();
if (ed == null) {
return;
}
if (ed.file == null) {
EditorWindow.current_file.setText("Cannot compiler unsaved code");
return;
}
var code = ed.textArea.getText();
AccessFrame.writeSuccess("Compilation started: ");
Compiler.out = AccessFrame.AccessFrameOutputStream.out;
// TODO: Add actual compilation logic or remove this method
// Currently only redirects output but doesn't compile
}
🤖 Prompt for AI Agents
In src/main/java/org/editor/events/AccessEvents.java between lines 38 and 52,
the compile method sets up output redirection but does not actually trigger any
compilation process, making it incomplete. To fix this, either implement the
compilation logic similar to compileAndRender by invoking the necessary compiler
methods and updating CanvasFrame fields, or if this method is obsolete, remove
it entirely. Alternatively, add a clear TODO comment explaining that the
compilation trigger logic needs to be implemented later.

Comment on lines +44 to +47
if (ed.file == null) {
EditorWindow.current_file.setText("Cannot compiler unsaved code");
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo in error message (duplicate issue).

Same typo appears in the compile method.

-    EditorWindow.current_file.setText("Cannot compiler unsaved code");
+    EditorWindow.current_file.setText("Cannot compile unsaved code");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (ed.file == null) {
EditorWindow.current_file.setText("Cannot compiler unsaved code");
return;
}
if (ed.file == null) {
EditorWindow.current_file.setText("Cannot compile unsaved code");
return;
}
🤖 Prompt for AI Agents
In src/main/java/org/editor/events/AccessEvents.java around lines 44 to 47, the
error message "Cannot compiler unsaved code" contains a typo. Change "compiler"
to "compile" in the string passed to EditorWindow.current_file.setText. Also,
locate the similar typo in the compile method and correct it the same way to
maintain consistency.

Comment on lines +55 to +68
private void createNodes(DefaultMutableTreeNode top, File fp) {
File[] files = fp.listFiles();

for (File file : files) {
if (file.isFile()) {
DefaultMutableTreeNode f = new DefaultMutableTreeNode(file);
top.add(f);
} else {
DefaultMutableTreeNode dir = new DefaultMutableTreeNode(file);
createNodes(dir, file);
top.add(dir);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add null check for listFiles() result.

The createNodes method doesn't handle the case where fp.listFiles() returns null, which can happen due to I/O errors or permission issues.

  private void createNodes(DefaultMutableTreeNode top, File fp) {
    File[] files = fp.listFiles();
+   if (files == null) {
+     return; // Handle case where listFiles() returns null
+   }

    for (File file : files) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void createNodes(DefaultMutableTreeNode top, File fp) {
File[] files = fp.listFiles();
for (File file : files) {
if (file.isFile()) {
DefaultMutableTreeNode f = new DefaultMutableTreeNode(file);
top.add(f);
} else {
DefaultMutableTreeNode dir = new DefaultMutableTreeNode(file);
createNodes(dir, file);
top.add(dir);
}
}
}
private void createNodes(DefaultMutableTreeNode top, File fp) {
File[] files = fp.listFiles();
if (files == null) {
return; // Handle case where listFiles() returns null
}
for (File file : files) {
if (file.isFile()) {
DefaultMutableTreeNode f = new DefaultMutableTreeNode(file);
top.add(f);
} else {
DefaultMutableTreeNode dir = new DefaultMutableTreeNode(file);
createNodes(dir, file);
top.add(dir);
}
}
}
🤖 Prompt for AI Agents
In src/main/java/org/editor/panels/FileTreePanel.java around lines 55 to 68, the
createNodes method calls fp.listFiles() without checking if the result is null,
which can cause a NullPointerException if listFiles() fails due to I/O errors or
permission issues. Add a null check after calling listFiles() and only proceed
with the for loop if the files array is not null.


public class PiccodeScriptTokenMaker extends AbstractTokenMaker {
private static List<String> importants = List.of("pkg", "remote", "super", "true", "false");
private static List<String> importants = List.of("true", "false", "await");
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify keyword consistency with language specification.

The keywords list has been significantly changed from ["pkg", "remote", "super", "true", "false"] to ["true", "false", "await"]. This removes several keywords that might still be in use.


🏁 Script executed:

#!/bin/bash
# Search for usage of removed keywords in example files and source code
echo "Searching for removed keywords usage..."
rg -n "pkg|remote|super" examples/ --type=pics 2>/dev/null || echo "No .pics files found"
rg -n "pkg|remote|super" . --type=java -A 2

Length of output: 5130


Remove outdated ‘pkg’ shorthand completion to align with updated keywords

All removed keywords (pkg, remote, super) no longer appear in any .pics examples or in the token‐maker grammar. However, the editor still registers a shorthand completion for pkg, which is now invalid:

• src/main/java/org/editor/CodeEditor.java:245

- provider.addCompletion(new ShorthandCompletion(provider, "pkg", "input pkg:"));

Please remove (or update) this line so the editor’s completions match the new language specification.

🤖 Prompt for AI Agents
In src/main/java/org/piccode/tokenmaker/PiccodeScriptTokenMaker.java at line 20,
remove the outdated keyword "pkg" from the list of important keywords to ensure
the editor's shorthand completions align with the updated language specification
and no longer include invalid completions.

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.

2 participants