本文整理匯總了C#中ASResult.IsNull方法的典型用法代碼示例。如果您正苦於以下問題:C# ASResult.IsNull方法的具體用法?C# ASResult.IsNull怎麽用?C# ASResult.IsNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ASResult
的用法示例。
在下文中一共展示了ASResult.IsNull方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ShowGetSetList
private static void ShowGetSetList(FoundDeclaration found)
{
string name = GetPropertyNameFor(found.member);
ASResult result = new ASResult();
ClassModel curClass = ASContext.Context.CurrentClass;
ASComplete.FindMember(name, curClass, result, FlagType.Getter, 0);
bool hasGetter = !result.IsNull();
ASComplete.FindMember(name, curClass, result, FlagType.Setter, 0);
bool hasSetter = !result.IsNull();
if (hasGetter && hasSetter) return;
List<ICompletionListItem> known = new List<ICompletionListItem>();
if (!hasGetter && !hasSetter)
{
string label = TextHelper.GetString("ASCompletion.Label.GenerateGetSet");
known.Add(new GeneratorItem(label, GeneratorJobType.GetterSetter, found.member, found.inClass));
}
if (!hasGetter)
{
string label = TextHelper.GetString("ASCompletion.Label.GenerateGet");
known.Add(new GeneratorItem(label, GeneratorJobType.Getter, found.member, found.inClass));
}
if (!hasSetter)
{
string label = TextHelper.GetString("ASCompletion.Label.GenerateSet");
known.Add(new GeneratorItem(label, GeneratorJobType.Setter, found.member, found.inClass));
}
CompletionList.Show(known, false);
}
示例2: GenerateImplementation
private static void GenerateImplementation(ClassModel aType, int position)
{
List<string> typesUsed = new List<string>();
StringBuilder sb = new StringBuilder(TemplateUtils.ReplaceTemplateVariable(TemplateUtils.GetTemplate("ImplementHeader"), "Class", aType.Type));
sb.Append(NewLine);
bool entry = true;
ASResult result = new ASResult();
IASContext context = ASContext.Context;
ClassModel cClass = context.CurrentClass;
ContextFeatures features = context.Features;
bool canGenerate = false;
aType.ResolveExtends(); // resolve inheritance chain
while (!aType.IsVoid() && aType.QualifiedName != "Object")
{
foreach (MemberModel method in aType.Members)
{
if ((method.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) == 0
|| method.Name == aType.Name)
continue;
// check if method exists
ASComplete.FindMember(method.Name, cClass, result, method.Flags, 0);
if (!result.IsNull()) continue;
string decl = entry ? NewLine : "";
if ((method.Flags & FlagType.Getter) > 0)
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Getter"));
else if ((method.Flags & FlagType.Setter) > 0)
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Setter"));
else
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Function"));
decl = TemplateUtils.ReplaceTemplateVariable(decl, "Member", "_" + method.Name);
decl = TemplateUtils.ReplaceTemplateVariable(decl, "Void", features.voidKey);
decl = TemplateUtils.ReplaceTemplateVariable(decl, "Body", null);
decl = TemplateUtils.ReplaceTemplateVariable(decl, "BlankLine", NewLine);
if (!entry)
{
decl = TemplateUtils.ReplaceTemplateVariable(decl, "EntryPoint", null);
}
decl += NewLine;
entry = false;
sb.Append(decl);
canGenerate = true;
addTypeOnce(typesUsed, getQualifiedType(method.Type, aType));
if (method.Parameters != null && method.Parameters.Count > 0)
foreach (MemberModel param in method.Parameters)
addTypeOnce(typesUsed, getQualifiedType(param.Type, aType));
}
// interface inheritance
aType = aType.Extends;
}
if (!canGenerate)
return;
ScintillaNet.ScintillaControl Sci = ASContext.CurSciControl;
Sci.BeginUndoAction();
try
{
position = Sci.CurrentPos;
if (ASContext.Context.Settings.GenerateImports && typesUsed.Count > 0)
{
int offset = AddImportsByName(typesUsed, Sci.LineFromPosition(position));
position += offset;
Sci.SetSel(position, position);
}
InsertCode(position, sb.ToString());
}
finally { Sci.EndUndoAction(); }
}
示例3: GenerateImplementation
private static void GenerateImplementation(ClassModel iType, ClassModel inClass, ScintillaControl sci, bool detached)
{
List<string> typesUsed = new List<string>();
StringBuilder sb = new StringBuilder();
string header = TemplateUtils.ReplaceTemplateVariable(TemplateUtils.GetTemplate("ImplementHeader"), "Class",
iType.Type);
header = TemplateUtils.ReplaceTemplateVariable(header, "BlankLine", detached ? BlankLine : null);
sb.Append(header);
sb.Append(NewLine);
bool entry = true;
ASResult result = new ASResult();
IASContext context = ASContext.Context;
ContextFeatures features = context.Features;
bool canGenerate = false;
bool isHaxe = IsHaxe;
FlagType flags = (FlagType.Function | FlagType.Getter | FlagType.Setter);
if (isHaxe) flags |= FlagType.Variable;
iType.ResolveExtends(); // resolve inheritance chain
while (!iType.IsVoid() && iType.QualifiedName != "Object")
{
foreach (MemberModel method in iType.Members)
{
if ((method.Flags & flags) == 0
|| method.Name == iType.Name)
continue;
// check if method exists
ASComplete.FindMember(method.Name, inClass, result, method.Flags, 0);
if (!result.IsNull()) continue;
string decl;
if ((method.Flags & FlagType.Getter) > 0)
{
if (isHaxe)
{
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Property"));
string templateName = null;
string metadata = null;
if (method.Parameters[0].Name == "get")
{
if (method.Parameters[1].Name == "set")
{
templateName = "GetterSetter";
metadata = "@:isVar";
}
else
templateName = "Getter";
}
else if (method.Parameters[1].Name == "set")
{
templateName = "Setter";
}
decl = TemplateUtils.ReplaceTemplateVariable(decl, "MetaData", metadata);
if (templateName != null)
{
var accessor = NewLine + TemplateUtils.ToDeclarationString(method, TemplateUtils.GetTemplate(templateName));
accessor = TemplateUtils.ReplaceTemplateVariable(accessor, "Modifiers", null);
accessor = TemplateUtils.ReplaceTemplateVariable(accessor, "Member", method.Name);
decl += accessor;
}
}
else
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Getter"));
}
else if ((method.Flags & FlagType.Setter) > 0)
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Setter"));
else if ((method.Flags & FlagType.Function) > 0)
decl = TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Function"));
else
decl = NewLine + TemplateUtils.ToDeclarationWithModifiersString(method, TemplateUtils.GetTemplate("Variable"));
decl = TemplateUtils.ReplaceTemplateVariable(decl, "Member", "_" + method.Name);
decl = TemplateUtils.ReplaceTemplateVariable(decl, "Void", features.voidKey);
decl = TemplateUtils.ReplaceTemplateVariable(decl, "Body", null);
decl = TemplateUtils.ReplaceTemplateVariable(decl, "BlankLine", NewLine);
if (!entry)
{
decl = TemplateUtils.ReplaceTemplateVariable(decl, "EntryPoint", null);
}
decl += NewLine;
entry = false;
sb.Append(decl);
canGenerate = true;
AddTypeOnce(typesUsed, GetQualifiedType(method.Type, iType));
if (method.Parameters != null && method.Parameters.Count > 0)
foreach (MemberModel param in method.Parameters)
AddTypeOnce(typesUsed, GetQualifiedType(param.Type, iType));
//.........這裏部分代碼省略.........
示例4: ResolveTopLevelElement
/// <summary>
/// Top-level elements lookup
/// </summary>
/// <param name="token">Element to search</param>
/// <param name="result">Response structure</param>
public override void ResolveTopLevelElement(string token, ASResult result)
{
if (topLevel != null && topLevel.Members.Count > 0)
{
// current class
ClassModel inClass = ASContext.Context.CurrentClass;
if (token == "this")
{
result.Member = topLevel.Members.Search("this", 0, 0);
if (inClass.IsVoid())
inClass = ASContext.Context.ResolveType(result.Member.Type, null);
result.Type = inClass;
result.InFile = ASContext.Context.CurrentModel;
return;
}
else if (token == "super")
{
if (inClass.IsVoid())
{
MemberModel thisMember = topLevel.Members.Search("this", 0, 0);
inClass = ASContext.Context.ResolveType(thisMember.Type, null);
}
inClass.ResolveExtends();
ClassModel extends = inClass.Extends;
if (!extends.IsVoid())
{
result.Member = topLevel.Members.Search("super", 0, 0);
result.Type = extends;
result.InFile = extends.InFile;
return;
}
}
// other top-level elements
ASComplete.FindMember(token, topLevel, result, 0, 0);
if (!result.IsNull()) return;
// special _levelN
if (hasLevels && token.StartsWith("_") && re_level.IsMatch(token))
{
result.Member = new MemberModel();
result.Member.Name = token;
result.Member.Flags = FlagType.Variable;
result.Member.Type = "MovieClip";
result.Type = ResolveType("MovieClip", null);
result.InFile = topLevel;
}
}
}
示例5: GenerateImplementation
private static void GenerateImplementation(ClassModel aType, int position)
{
List<string> typesUsed = new List<string>();
StringBuilder sb = new StringBuilder(String.Format(GetTemplate("ImplementHeader"), aType.Type));
string entry = "$(EntryPoint)";
ASResult result = new ASResult();
IASContext context = ASContext.Context;
ClassModel cClass = context.CurrentClass;
ContextFeatures features = context.Features;
bool canGenerate = false;
string template = GetTemplate("ImplementPart");
aType.ResolveExtends(); // resolve inheritance chain
while (!aType.IsVoid() && aType.QualifiedName != "Object")
{
foreach (MemberModel method in aType.Members)
{
if ((method.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) == 0
|| method.Name == aType.Name)
continue;
// check if method exists
ASComplete.FindMember(method.Name, cClass, result, method.Flags, 0);
if (!result.IsNull()) continue;
string decl = String.Format(template, GetDeclaration(method), entry);
entry = "";
sb.Append(decl);
canGenerate = true;
addTypeOnce(typesUsed, getQualifiedType(method.Type, aType));
if (method.Parameters != null && method.Parameters.Count > 0)
foreach (MemberModel param in method.Parameters)
addTypeOnce(typesUsed, getQualifiedType(param.Type, aType));
}
// interface inheritance
aType = aType.Extends;
}
if (!canGenerate)
return;
ScintillaNet.ScintillaControl Sci = ASContext.CurSciControl;
Sci.BeginUndoAction();
try
{
position = Sci.CurrentPos;
if (ASContext.Context.Settings.GenerateImports && typesUsed.Count > 0)
{
int offset = AddImportsByName(typesUsed, Sci.LineFromPosition(position));
position += offset;
Sci.SetSel(position, position);
}
InsertCode(position, sb.ToString());
}
finally { Sci.EndUndoAction(); }
}
示例6: ShowSetterList
static void ShowSetterList(FoundDeclaration found, ICollection<ICompletionListItem> options)
{
var name = GetPropertyNameFor(found.member);
var result = new ASResult();
ASComplete.FindMember(name, ASContext.Context.CurrentClass, result, FlagType.Setter, 0);
if (!result.IsNull()) return;
var label = TextHelper.GetString("ASCompletion.Label.GenerateSet");
options.Add(new GeneratorItem(label, GeneratorJobType.Setter, found.member, found.inClass));
}