Skip to content

Commit

Permalink
check if type has @:callable in CallExpression annotator
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Dec 30, 2023
1 parent 72a5590 commit c29771a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,31 @@ public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder hold

// handle Null<FunctionType>
if (type.getClassType() != null) {
if (type.getClassType().isNullType()) {
SpecificFunctionReference functionReference = getUnderlyingFunctionIfAbstractNull(type.getClassType());
SpecificHaxeClassReference classReference = type.getClassType();
if (classReference.isNullType()) {
SpecificFunctionReference functionReference = getUnderlyingFunctionIfAbstractNull(classReference);
if (functionReference != null) {
functionType = functionReference;
}
}

// resolve typedef of function
if (classReference.isTypeDefOfFunction()) {
SpecificFunctionReference functionReference = classReference.resolveTypeDefFunction();
functionType = functionReference;
}

if (classReference.isTypeDefOfClass()) {
classReference = classReference.fullyResolveTypeDefClass();
}
if (functionType == null) {
boolean callable = classReference.getHaxeClassModel().isCallable();
if (callable) {
type = SpecificTypeReference.getDynamic(classReference.getElementContext()).createHolder();
}
}
}
// resolve typedef of function
if (type.getType() instanceof SpecificHaxeClassReference classReference && classReference.isTypeDef()) {
SpecificFunctionReference functionReference = classReference.resolveTypeDefFunction();
functionType = functionReference;
}


if (functionType != null) {
if (functionType.functionType != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public interface HaxeMeta extends HaxePsiCompositeElement {
HaxeMetadataTypeName USING = new HaxeMetadataTypeName("using");
HaxeMetadataTypeName VALUE = new HaxeMetadataTypeName("value");

HaxeMetadataTypeName CALLABLE = new HaxeMetadataTypeName("callable");

// We need a token for things we don't know about (user meta). This name cannot be constructed in code.
// XXX: This needs to be thought through some more. CUSTOM should not match just any string.
HaxeMetadataTypeName CUSTOM = new HaxeMetadataTypeName("{custom}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.intellij.plugins.haxe.lang.psi.*;
import com.intellij.plugins.haxe.lang.psi.impl.AbstractHaxePsiClass;
import com.intellij.plugins.haxe.metadata.HaxeMetadataList;
import com.intellij.plugins.haxe.metadata.psi.HaxeMeta;
import com.intellij.plugins.haxe.metadata.psi.impl.HaxeMetadataTypeName;
import com.intellij.plugins.haxe.model.type.*;
Expand Down Expand Up @@ -142,6 +143,9 @@ public boolean isCoreType() {
public boolean hasCompileTimeMeta(@NotNull HaxeMetadataTypeName name) {
return haxeClass.hasCompileTimeMeta(name);
}
public boolean isCallable() {
return haxeClass.hasCompileTimeMeta(HaxeMeta.CALLABLE);
}

@Nullable
public HaxeModifiersModel getModifiers() {
Expand Down

0 comments on commit c29771a

Please sign in to comment.