Skip to content

Commit

Permalink
[Haxe][CodeComplete] Improved completion for `var v:Typedef = <comple…
Browse files Browse the repository at this point in the history
…te>`. fixes #2669 (#2670)
  • Loading branch information
SlavaRa committed Jan 29, 2019
1 parent e6f14e8 commit 8ea0e80
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion External/Plugins/HaXeContext/Completion/CodeComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ bool HandleAssignCompletion(ScintillaControl sci, bool autoHide, char c, ClassMo
};
List<ICompletionListItem> list = null;
// for example: var v:Typedef = <complete>
if (type.Flags.HasFlag(FlagType.TypeDef) && (type.Members.Count > 0 || type.ExtendsType != null))
if (IsTypedef(type, ref type))
{
orders.Add("{}", 1);
list = new List<ICompletionListItem>
Expand Down Expand Up @@ -393,6 +393,37 @@ bool IsEnum(ClassModel t) => t.Flags.HasFlag(FlagType.Enum)
&& t.MetaDatas != null && t.MetaDatas.Any(it => it.Name == ":enum"));

bool IsFunction(MemberModel m) => m != null && m.Flags.HasFlag(FlagType.Function);

bool IsTypedef(ClassModel t, ref ClassModel realType)
{
if (t.Flags.HasFlag(FlagType.TypeDef))
{
// for example: typedef Typedef = {}
if (string.IsNullOrEmpty(t.ExtendsType)) return true;
/**
* for example:
* typedef Typedef = {
* > Type1,
* > Type2,
* }
*/
if (t.ExtendsTypes != null) return true;
t.ResolveExtends();
var extends = t.Extends;
while (!extends.IsVoid())
{
if (!extends.Flags.HasFlag(FlagType.TypeDef))
{
realType = extends;
return false;
}
extends = t.Extends;
}
return true;
}
realType = t;
return false;
}
}

bool HandleExpressionReificationCompletion(ScintillaControl sci, bool autoHide)
Expand Down

0 comments on commit 8ea0e80

Please sign in to comment.