Skip to content

Commit

Permalink
[Haxe][CodeComplete] Added completion for 'using haxe.EnumTools'. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
slavara committed Apr 15, 2019
1 parent d69e630 commit d9fcd1f
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
24 changes: 23 additions & 1 deletion External/Plugins/HaXeContext/Completion/CodeComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,29 @@ protected override void GetInstanceMembers(bool autoHide, ASResult expr, ClassMo
return;
}
}
Context.TryResolveStaticExtensions(exprType, ASContext.Context.CurrentModel, out exprType);
if ((exprType.Flags & FlagType.Enum) != 0 && (exprType.Flags & FlagType.Abstract) == 0 && expr.IsStatic)
{
/**
* for example:
* using haxe.EnumTools;
* enum ETest {
* A;
* B;
* }
* class Test {
* function test() {
* ETest.<complete>
* }
* }
*/
var type = ResolveType("Enum", ASContext.Context.CurrentModel);
if (!type.IsVoid() && Context.TryResolveStaticExtensions(type, ASContext.Context.CurrentModel, out var tmpExprType))
{
exprType = tmpExprType;
mask &= ~FlagType.Static;
}
}
else Context.TryResolveStaticExtensions(exprType, ASContext.Context.CurrentModel, out exprType);
base.GetInstanceMembers(autoHide, expr, exprType, mask, dotIndex, result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,18 @@ static IEnumerable<TestCaseData> OnCharAndReplaceTextIssue2757TestCases
}
}

static IEnumerable<TestCaseData> OnCharAndReplaceTextIssue2759TestCases
{
get
{
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2759_1", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2759_1"))
.SetName("ConcreteEnum.<complete> Issue 2759. Case 1")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2759");

}
}

[
Test,
TestCaseSource(nameof(OnCharAndReplaceTextTestCases)),
Expand All @@ -1263,6 +1275,7 @@ static IEnumerable<TestCaseData> OnCharAndReplaceTextIssue2757TestCases
TestCaseSource(nameof(OnCharAndReplaceTextIssue2726TestCases)),
TestCaseSource(nameof(OnCharAndReplaceTextIssue2750TestCases)),
TestCaseSource(nameof(OnCharAndReplaceTextIssue2757TestCases)),
TestCaseSource(nameof(OnCharAndReplaceTextIssue2759TestCases)),
]
public string OnCharAndReplaceText(string fileName, char addedChar, bool autoHide)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,8 @@
<EmbeddedResource Include="Test Files\parser\WrongSyntaxCompilerMetaAfterVarWithNoType.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2757_1.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2757_1.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2759_1.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2759_1.hx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package;
using haxe.EnumTools;
private enum PIssue2759 {}
class Issue2759_1 {
function foo() {
PIssue2759.createAll
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package;
using haxe.EnumTools;
private enum PIssue2759 {}
class Issue2759_1 {
function foo() {
PIssue2759.$(EntryPoint)
}
}

0 comments on commit d9fcd1f

Please sign in to comment.