Skip to content

Commit ea22dea

Browse files
committed
Misc completion improvements:
- Disabled completion after .< in Haxe. - Enabled completion for Haxe properties type. - Fixed GetFunctionContext in Haxe since there is no const keyword. - Enabled basic completion after < in generics.
1 parent 1b2434e commit ea22dea

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

External/Plugins/ASCompletion/Completion/ASComplete.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static public bool OnChar(ScintillaControl Sci, int Value, bool autoHide)
184184
if (features.hasGenerics && position > 2)
185185
{
186186
char c0 = (char)Sci.CharAt(position - 2);
187-
if (c0 == '.' /*|| Char.IsLetterOrDigit(c0)*/)
187+
//TODO: We should check if we are actually on a generic type
188+
if ((ASContext.Context.CurrentModel.Version == 3 && c0 == '.') || Char.IsLetterOrDigit(c0))
188189
return HandleColonCompletion(Sci, "", autoHide);
189190
return false;
190191
}
@@ -2219,6 +2220,7 @@ static private bool HandleColonCompletion(ScintillaControl Sci, string tail, boo
22192220

22202221
private static ComaExpression GetFunctionContext(ScintillaControl Sci, bool autoHide)
22212222
{
2223+
ContextFeatures features = ASContext.Context.Features;
22222224
ComaExpression coma = ComaExpression.None;
22232225
int position = Sci.CurrentPos - 1;
22242226
char c = ' ';
@@ -2235,7 +2237,7 @@ private static ComaExpression GetFunctionContext(ScintillaControl Sci, bool auto
22352237
// var declaration
22362238
GetWordLeft(Sci, ref position);
22372239
string keyword = (c == ':') ? GetWordLeft(Sci, ref position) : null;
2238-
if (keyword == ASContext.Context.Features.varKey || keyword == ASContext.Context.Features.constKey)
2240+
if (keyword == features.varKey || (features.constKey != null && keyword == features.constKey))
22392241
coma = ComaExpression.VarDeclaration;
22402242
// function return type
22412243
else if ((char)Sci.CharAt(position) == ')')
@@ -2257,7 +2259,6 @@ private static ComaExpression GetFunctionContext(ScintillaControl Sci, bool auto
22572259
}
22582260
}
22592261
keyword = GetWordLeft(Sci, ref position);
2260-
ContextFeatures features = ASContext.Context.Features;
22612262
if (keyword == "" && Sci.CharAt(position) == '>' && features.hasGenerics)
22622263
{
22632264
int groupCount = 1;
@@ -2280,6 +2281,9 @@ private static ComaExpression GetFunctionContext(ScintillaControl Sci, bool auto
22802281
keyword = GetWordLeft(Sci, ref position);
22812282
if (keyword == features.functionKey || keyword == features.getKey || keyword == features.setKey)
22822283
coma = ComaExpression.FunctionDeclaration;
2284+
else if (ASContext.Context.CurrentModel.haXe && keyword == features.varKey &&
2285+
(ASContext.Context.CurrentMember == null || (ASContext.Context.CurrentMember.Flags & FlagType.Function) == 0))
2286+
coma = ComaExpression.VarDeclaration; // Haxe Properties
22832287
}
22842288
}
22852289
// needs more guessing
@@ -3544,6 +3548,7 @@ internal static ComaExpression DisambiguateComa(ScintillaControl Sci, int positi
35443548
string word1 = GetWordLeft(Sci, ref position);
35453549
if (word1 == "" && Sci.CharAt(position) == '>' && features.hasGenerics)
35463550
{
3551+
// Generic function: function generic<K>(arg:K)
35473552
int groupCount = 1;
35483553
position--;
35493554
while (position >= 0 && groupCount > 0)

0 commit comments

Comments
 (0)