Skip to content

Commit 6fe0ca6

Browse files
committed
Add different error message for static / non-static.
Also github action cache
1 parent 72173a0 commit 6fe0ca6

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

.github/workflows/gradle.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
uses: actions/setup-java@v1
1616
with:
1717
java-version: 1.8
18+
- name: Cache Gradle
19+
uses: actions/cache@v2
20+
with:
21+
path: |
22+
~/.gradle/caches
23+
~/.gradle/wrapper
24+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
25+
restore-keys: ${{ runner.os }}-gradle
1826
- name: Grant execute permission for gradlew
1927
run: chmod +x gradlew
2028
- name: Build with Gradle

src/main/java/com/btk5h/skriptmirror/Descriptor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ public Class<?>[] getParameterTypes() {
5757

5858
@Override
5959
public String toString() {
60-
return String.format("%s#%s",
61-
javaClass == null ? "(unspecified)" : SkriptMirrorUtil.getDebugName(javaClass),
62-
name);
60+
return toString(false);
61+
}
62+
63+
public String toString(boolean isStatic) {
64+
return String.format("%s" + (isStatic ? "." : "#") + "%s",
65+
javaClass == null ? "(unspecified)" : SkriptMirrorUtil.getDebugName(javaClass),
66+
name);
6367
}
6468

6569
public Descriptor orDefaultClass(Class<?> cls) {

src/main/java/com/btk5h/skriptmirror/skript/reflect/ExprJavaCall.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ private T invoke(Object target, Object[] arguments, Descriptor baseDescriptor) {
426426
// Copy arguments so that the original array isn't modified by type conversions
427427
// For instance methods, the target of the call must be added to the start of the arguments array
428428
Object[] argumentsCopy;
429-
if (target instanceof JavaType) {
429+
boolean isStatic = target instanceof JavaType;
430+
if (isStatic) {
430431
argumentsCopy = createStaticArgumentsCopy(arguments);
431432
} else {
432433
argumentsCopy = createInstanceArgumentsCopy(target, arguments);
@@ -436,7 +437,7 @@ private T invoke(Object target, Object[] arguments, Descriptor baseDescriptor) {
436437

437438
if (!method.isPresent()) {
438439
error(String.format("No matching %s: %s%s",
439-
type, descriptor, argumentsMessage(arguments)));
440+
type, descriptor.toString(isStatic), argumentsMessage(arguments)));
440441

441442
suggestParameters(descriptor);
442443
suggestTypo(descriptor);

0 commit comments

Comments
 (0)