-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing issue where untyped parameters in methods did not resolve type…
… correctly.
- Loading branch information
Showing
5 changed files
with
84 additions
and
3 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
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
38 changes: 38 additions & 0 deletions
38
src/test/java/com/intellij/plugins/haxe/ide/inlay/all/AllInlayHintsProvider.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,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)); | ||
}; | ||
|
||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/test/java/com/intellij/plugins/haxe/ide/inlay/all/HaxeAllInlayTest.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,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
12
src/test/resources/testData/inlay/all/ParameterMonomorph.hx
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,12 @@ | ||
class ParameterMonomorph { | ||
|
||
public function new() { | ||
var test/*<# :String #>*/ = testFunction(null); | ||
} | ||
function testFunction(?p)/*<# :String #>*/ { | ||
if (p == null) { | ||
p = "string"; | ||
} | ||
return p; | ||
} | ||
} |