Skip to content

Commit

Permalink
fixing issue where untyped parameters in methods did not resolve type…
Browse files Browse the repository at this point in the history
… correctly.
  • Loading branch information
m0rkeulv committed Jan 15, 2025
1 parent a36339f commit 978c5be
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ private static ResultHolder checkSearchResult(HaxeExpressionEvaluatorContext con
}
return null;
});
if(result != null) return result;
return result;
}
}
}
Expand Down Expand Up @@ -715,7 +715,7 @@ private static ResultHolder checkSearchResult(HaxeExpressionEvaluatorContext con
}
}
}
return null;
return createUnknown(reference.getElement());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ static ResultHolder handleReferenceExpression( HaxeExpressionEvaluatorContext co
}

}
if (access != null) typeHolder = access;
if (access != null){
typeHolder = access;
}else {
typeHolder = createUnknown(child);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.intellij.plugins.haxe.ide.inlay.all;

import com.intellij.codeInsight.hints.declarative.InlayHintsCollector;
import com.intellij.codeInsight.hints.declarative.InlayHintsProvider;
import com.intellij.codeInsight.hints.declarative.SharedBypassCollector;
import com.intellij.openapi.editor.Editor;
import com.intellij.plugins.haxe.ide.hint.types.*;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

public class AllInlayHintsProvider implements InlayHintsProvider {

List<InlayHintsProvider> inlayHintsProviders = List.of(
new HaxeInlayCaptureVariableHintsProvider(),
new HaxeInlayEnumExtractorHintsProvider(),
new HaxeInlayFieldHintsProvider(),
new HaxeInlayForLoopHintsProvider(),
new HaxeInlayLocalVariableHintsProvider(),
new HaxeInlayReturnTypeHintsProvider(),
new HaxeInlayUntypedParameterHintsProvider()
);

@Override
public @Nullable InlayHintsCollector createCollector(@NotNull PsiFile psiFile, @NotNull Editor editor) {
List<HaxeSharedBypassCollector> inlayHintsCollectors = inlayHintsProviders.stream()
.map(inlayHintsProvider -> inlayHintsProvider.createCollector(psiFile, editor))
.map(HaxeSharedBypassCollector.class::cast)
.toList();

return (SharedBypassCollector) (psiElement, inlayTreeSink) -> {
inlayHintsCollectors.forEach(collector -> collector.collectFromElement(psiElement, inlayTreeSink));
};

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.intellij.plugins.haxe.ide.inlay.all;

import com.intellij.codeInsight.hints.declarative.InlayHintsProvider;
import com.intellij.plugins.haxe.ide.inlay.HaxeInlayTestBase;
import org.junit.Test;

public class HaxeAllInlayTest extends HaxeInlayTestBase {

InlayHintsProvider hintsProvider = new AllInlayHintsProvider();

@Override
protected String getBasePath() {
return "/inlay/all/";
}

@Override
public void setUp() throws Exception {
useHaxeToolkit();
super.setUp();
setTestStyleSettings(2);
}

@Test
public void testParameterMonomorph() throws Exception {
doTest(hintsProvider);
}
}
12 changes: 12 additions & 0 deletions src/test/resources/testData/inlay/all/ParameterMonomorph.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ParameterMonomorph {

public function new() {
var test/*<# :String #>*/ = testFunction(null);
}
function testFunction(?p)/*<# :String #>*/ {
if (p == null) {
p = "string";
}
return p;
}
}

0 comments on commit 978c5be

Please sign in to comment.