Skip to content

Commit b2c651a

Browse files
committed
Genericize LKQL: get rid of Libadalang.CompletionItemIterator reference
This is not required and do not exposed by LangkitSupport. TODO: why do we need those Truffle boundaries now?
1 parent c9e5ffb commit b2c651a

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

lkql_jit/language/src/main/java/com/adacore/lkql_jit/runtime/values/LKQLProperty.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.adacore.lkql_jit.exception.LKQLRuntimeException;
1010
import com.adacore.lkql_jit.nodes.arguments.ArgList;
1111
import com.adacore.lkql_jit.runtime.values.bases.BasicLKQLValue;
12-
import com.adacore.lkql_jit.utils.LKQLTypesHelper;
1312
import com.adacore.lkql_jit.utils.functions.ObjectUtils;
1413
import com.adacore.lkql_jit.utils.functions.ReflectionUtils;
1514
import com.oracle.truffle.api.CompilerDirectives;
@@ -73,6 +72,7 @@ public boolean isField() {
7372
* @param caller The locatable which called the execution.
7473
* @param arguments The argument for the property call.
7574
*/
75+
@CompilerDirectives.TruffleBoundary
7676
public Object executeAsProperty(Node caller, ArgList argList, Object... arguments) {
7777
try {
7878
return ReflectionUtils.callProperty(
@@ -83,10 +83,7 @@ public Object executeAsProperty(Node caller, ArgList argList, Object... argument
8383
arguments
8484
);
8585
} catch (com.adacore.lkql_jit.exception.utils.UnsupportedTypeException e) {
86-
throw LKQLRuntimeException.unsupportedType(
87-
LKQLTypesHelper.category(e.getType()),
88-
caller
89-
);
86+
throw LKQLRuntimeException.unsupportedType(e.getType().getSimpleName(), caller);
9087
}
9188
}
9289

@@ -95,14 +92,12 @@ public Object executeAsProperty(Node caller, ArgList argList, Object... argument
9592
*
9693
* @param caller The locatable which called the execution.
9794
*/
95+
@CompilerDirectives.TruffleBoundary
9896
public Object executeAsField(Node caller) {
9997
try {
10098
return ReflectionUtils.callProperty(this.node, this.description, caller, null);
10199
} catch (com.adacore.lkql_jit.exception.utils.UnsupportedTypeException e) {
102-
throw LKQLRuntimeException.unsupportedType(
103-
LKQLTypesHelper.category(e.getType()),
104-
caller
105-
);
100+
throw LKQLRuntimeException.unsupportedType(e.getType().getSimpleName(), caller);
106101
}
107102
}
108103

lkql_jit/language/src/main/java/com/adacore/lkql_jit/utils/LKQLTypesHelper.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,6 @@ public static String debugName(Class<?> type) {
216216
}
217217
}
218218

219-
/**
220-
* Get the category of value for the given Java type. This category represents a kind of value
221-
* from Libadalang which cannot be imported in the LKQL context.
222-
*
223-
* @param type The type to get the category for.
224-
* @return The type category.
225-
*/
226-
@CompilerDirectives.TruffleBoundary
227-
public static String category(Class<?> type) {
228-
if (type == Libadalang.CompletionItemIterator.class) {
229-
return "ITERATOR_CATEGORY";
230-
} else {
231-
return type.getSimpleName();
232-
}
233-
}
234-
235219
/**
236220
* Convert a Java value into a LKQL value.
237221
*
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
script.lkql:2:7: error: Unsupported value type from the introspection API: ITERATOR_CATEGORY
1+
script.lkql:2:7: error: Unsupported value type from the introspection API: CompletionItemIterator
22
2 | print(names[1].p_complete())
33
| ^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)