Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ASComplete] Improved code completion. fixes #2415 #2416

Merged
merged 3 commits into from Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 2 additions & 7 deletions External/Plugins/ASCompletion/Completion/ASComplete.cs
Expand Up @@ -3575,7 +3575,7 @@ private static ASExpr GetExpression(ScintillaControl sci, int position, bool ign
}
}
// ignore sub-expressions (method calls' parameters)
else if (c == '(')
else if (c == '(' && arrCount == 0)
{
parCount--;
if (parCount == 0 && arrCount == 0)
Expand Down Expand Up @@ -3619,7 +3619,7 @@ private static ASExpr GetExpression(ScintillaControl sci, int position, bool ign
break;
}
}
else if (c == ')')
else if (c == ')' && arrCount == 0)
{
ignoreWhiteSpace = false;
if (!hadDot)
Expand Down Expand Up @@ -3741,11 +3741,6 @@ private static ASExpr GetExpression(ScintillaControl sci, int position, bool ign
}
if (parCount > 0 || arrCount > 0 || genCount > 0 || braCount > 0 || dQuotes > 0 || sQuotes > 0)
{
if (c == ';') // not expected: something's wrong
{
expression.Separator = ";";
break;
}
// build sub expression
sbSub.Insert(0, c);
continue;
Expand Down
Expand Up @@ -509,19 +509,52 @@ static IEnumerable<TestCaseData> OnCharAndReplaceText_enums2_TestCases
}
}

static IEnumerable<TestCaseData> OnCharAndReplaceTextIssue2415TestCases
{
get
{
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2415_1", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2415_1"))
.SetName("foo(function() {return null;}).| Issue 2415. Case 1")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2415");
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2415_2", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2415_2"))
.SetName("[function() {return null;}].| Issue 2415. Case 2")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2415");
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2415_3", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2415_3"))
.SetName("[function() return null].| Issue 2415. Case 3")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2415");
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2415_4", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2415_4"))
.SetName("[function():Void->Array<Void->Void> return null].| Issue 2415. Case 4")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2415");
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2415_5", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2415_5"))
.SetName("[function():{x:Int, y:Int} return null].| Issue 2415. Case 5")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2415");
yield return new TestCaseData("BeforeOnCharAndReplaceText_issue2415_6", '.', false)
.Returns(CodeCompleteTests.ReadAllText("AfterOnCharAndReplaceText_issue2415_6"))
.SetName("[function() return [], [function() return []].| Issue 2415. Case 6")
.SetDescription("https://github.com/fdorg/flashdevelop/issues/2415");
}
}

[
Test,
TestCaseSource(nameof(OnCharAndReplaceTextTestCases)),
TestCaseSource(nameof(OnCharAndReplaceTextIssue2134TestCases)),
TestCaseSource(nameof(OnCharAndReplaceTextIssue2320TestCases)),
TestCaseSource(nameof(OnCharAndReplaceText_enums_TestCases)),
//TestCaseSource(nameof(OnCharAndReplaceText_enums2_TestCases)), // TODO: That tests pass without other tests.
TestCaseSource(nameof(OnCharAndReplaceTextIssue2415TestCases)),
]
public string OnCharAndReplaceText(string fileName, char addedChar, bool autoHide)
{
ASContext.Context.ResolveDotContext(null, null, false).ReturnsForAnyArgs(it => null);
//{TODO slavara: quick hack
ASContext.Context.When(it => it.ResolveTopLevelElement(Arg.Any<string>(), Arg.Any<ASResult>()))
ASContext.Context
.When(it => it.ResolveTopLevelElement(Arg.Any<string>(), Arg.Any<ASResult>()))
.Do(it =>
{
var ctx = (Context) ASContext.GetLanguageContext("haxe");
Expand Down
12 changes: 12 additions & 0 deletions Tests/External/Plugins/HaxeContext.Tests/HaxeContext.Tests.csproj
Expand Up @@ -812,6 +812,18 @@
<EmbeddedResource Include="Test Files\generators\code\AfterContextualGeneratorTests_issue2409_1.hx" />
<EmbeddedResource Include="Test Files\generators\code\BeforeContextualGeneratorTests_issue2411_1.hx" />
<EmbeddedResource Include="Test Files\generators\code\BeforeContextualGeneratorTests_issue2411_2.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2415_1.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2415_1.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2415_2.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2415_2.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2415_3.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2415_3.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2415_4.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2415_4.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2415_5.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2415_5.hx" />
<EmbeddedResource Include="Test Files\completion\BeforeOnCharAndReplaceText_issue2415_6.hx" />
<EmbeddedResource Include="Test Files\completion\AfterOnCharAndReplaceText_issue2415_6.hx" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -1,6 +1,6 @@
package;
import js.html.BinaryType;
class Bar {
class Bar_enums_10 {
static function main() {
ARRAYBUFFER.charAt
}
Expand Down
@@ -1,6 +1,6 @@
package;
import js.html.BinaryType;
class Bar {
class Bar_enums_8 {
static function main() {
BinaryType.ARRAYBUFFER
}
Expand Down
@@ -1,6 +1,6 @@
package;
import js.html.BinaryType;
class Bar {
class Bar_enums_9 {
static function main() {
BinaryType.ARRAYBUFFER.charAt
}
Expand Down
@@ -0,0 +1,11 @@
package;
class Issue2415_1 {
static function main() {
function test(v:Void->String):String {
return v();
}
test(function() {
return "test";
}).charAt
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_2 {
static function main() {
[function() {return null;}].concat
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_3 {
static function main() {
[function() return null].concat
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_4 {
static function main() {
[function():Void->Array<Void->Void> return null].concat
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_5 {
static function main() {
[function():{x:Int, y:Int} return null].concat
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_6 {
static function main() {
[function() return [], function() return []].concat
}
}
@@ -1,6 +1,6 @@
package;
import js.html.BinaryType;
class Bar {
class Bar_enums_10 {
static function main() {
ARRAYBUFFER.$(EntryPoint)
}
Expand Down
@@ -1,6 +1,6 @@
package;
import js.html.BinaryType;
class Bar {
class Bar_enums_8 {
static function main() {
BinaryType.$(EntryPoint)
}
Expand Down
@@ -1,6 +1,6 @@
package;
import js.html.BinaryType;
class Bar {
class Bar_enums_9 {
static function main() {
BinaryType.ARRAYBUFFER.$(EntryPoint)
}
Expand Down
@@ -0,0 +1,11 @@
package;
class Issue2415_1 {
static function main() {
function test(v:Void->String):String {
return v();
}
test(function() {
return "test";
}).$(EntryPoint)
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_2 {
static function main() {
[function() {return null;}].$(EntryPoint)
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_3 {
static function main() {
[function() return null].$(EntryPoint)
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_4 {
static function main() {
[function():Void->Array<Void->Void> return null].$(EntryPoint)
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_5 {
static function main() {
[function():{x:Int, y:Int} return null].$(EntryPoint)
}
}
@@ -0,0 +1,6 @@
package;
class Issue2415_6 {
static function main() {
[function() return [], function() return []].$(EntryPoint)
}
}