-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for symbol not found outside class
- Loading branch information
Showing
4 changed files
with
151 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
error_templates/java/test_files/symbol_not_found_error_missing_method_imported/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public class Test { | ||
public static void main(String[] args) { | ||
Triangle tri = new Triangle(); | ||
tri.getArea(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
error_templates/java/test_files/symbol_not_found_error_missing_method_imported/Triangle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
public class Triangle { | ||
public static int getSides() { | ||
return 3; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
error_templates/java/test_files/symbol_not_found_error_missing_method_imported/test.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "MissingMethodImported" | ||
template: "Java.SymbolNotFoundError" | ||
--- | ||
Test.java:4: error: cannot find symbol | ||
tri.getArea(); | ||
^ | ||
symbol: method getArea() | ||
location: variable tri of type Triangle | ||
1 error | ||
=== | ||
template: "Java.SymbolNotFoundError" | ||
--- | ||
# SymbolNotFoundError | ||
The error indicates that the compiler cannot find the method `getArea()` in the `Triangle` class. | ||
``` | ||
Triangle tri = new Triangle(); | ||
tri.getArea(); | ||
^^^^^^^^^^^^^^ | ||
} | ||
} | ||
``` | ||
## Steps to fix | ||
### Define the missing method. | ||
In `Triangle.java`, add the missing method `getArea` to the `Triangle` class. | ||
```diff | ||
public static int getSides() { | ||
return 3; | ||
} | ||
+ | ||
+ private static void getArea() { | ||
+ // Add code here | ||
+ } | ||
} | ||
|
||
``` |