本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.EntityDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# EntityDeclaration类的具体用法?C# EntityDeclaration怎么用?C# EntityDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityDeclaration类属于ICSharpCode.NRefactory.CSharp命名空间,在下文中一共展示了EntityDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AdjustVisibilityForClassesInterfacesAndStructs
protected static ModelV2.Visibility AdjustVisibilityForClassesInterfacesAndStructs(EntityDeclaration ed)
{
VisibilityMode mode = VisibilityMapper.Map(ed.Modifiers);
mode = mode == [email protected] ? [email protected] : [email protected];
return new ModelV2.Visibility(mode);
}
示例2: AppendAttributes
/// <summary>
/// Appends node attributes.
/// </summary>
/// <param name="buffer">the buffer</param>
/// <param name="node">the node</param>
/// <param name="stack">the stack</param>
/// <example>
/// <code>
/// [XmlIgnore]
/// [ConditionalAttribute("CODE_ANALYSIS")]
/// int DoSomething();
/// </code>
/// </example>
public static void AppendAttributes(StringBuilder buffer, EntityDeclaration node, int stack)
{
foreach (var attribute in node.Attributes)
{
buffer.AppendLine(attribute.ToString().Trim(), stack);
}
}
示例3: CheckBody
static bool CheckBody(EntityDeclaration node)
{
var custom = node as CustomEventDeclaration;
if (custom != null && !(IsValidBody (custom.AddAccessor.Body) || IsValidBody (custom.RemoveAccessor.Body)))
return false;
if (node is PropertyDeclaration || node is IndexerDeclaration) {
var setter = node.GetChildByRole(PropertyDeclaration.SetterRole);
var getter = node.GetChildByRole(PropertyDeclaration.GetterRole);
return IsValidBody(setter.Body) && IsValidBody(getter.Body);
}
return IsValidBody(node.GetChildByRole(Roles.Body));
}
示例4: IsObsolete
static bool IsObsolete (EntityDeclaration entity)
{
if (entity == null)
return false;
foreach (var section in entity.Attributes) {
foreach (var attr in section.Attributes) {
var attrText = attr.Type.GetText ();
if (attrText == "Obsolete" || attrText == "ObsoleteAttribute" || attrText == "System.Obsolete" || attrText == "System.ObsoleteAttribute" )
return true;
}
}
return false;
}
示例5: ImplementStub
static ThrowStatement ImplementStub (RefactoringContext context, EntityDeclaration newNode)
{
ThrowStatement throwStatement = null;
if (newNode is PropertyDeclaration || newNode is IndexerDeclaration) {
var setter = newNode.GetChildByRole(PropertyDeclaration.SetterRole);
if (!setter.IsNull)
setter.AddChild(CreateNotImplementedBody(context, out throwStatement), Roles.Body);
var getter = newNode.GetChildByRole(PropertyDeclaration.GetterRole);
if (!getter.IsNull)
getter.AddChild(CreateNotImplementedBody(context, out throwStatement), Roles.Body);
} else {
newNode.AddChild(CreateNotImplementedBody(context, out throwStatement), Roles.Body);
}
return throwStatement;
}
示例6: TryGetAttribute
protected virtual bool TryGetAttribute(EntityDeclaration type, string attributeName, out NRAttribute attribute)
{
foreach (var i in type.Attributes)
{
foreach (var j in i.Attributes)
{
if (j.Type.ToString() == attributeName)
{
attribute = j;
return true;
}
// FIXME: Will not try to get the attribute via Resolver.ResolveNode() (see above): it returns a
// different type, without minimum information needed to make a full NRAttribute -fzm
}
}
attribute = default(NRAttribute);
return false;
}
示例7: HasAttribute
protected virtual bool HasAttribute(EntityDeclaration type, string name)
{
foreach (var i in type.Attributes)
{
foreach (var j in i.Attributes)
{
if (j.Type.ToString() == name)
{
return true;
}
var resolveResult = this.Resolver.ResolveNode(j, null);
if (resolveResult != null && resolveResult.Type != null && resolveResult.Type.FullName == (name + "Attribute"))
{
return true;
}
}
}
return false;
}
示例8: FixAttributesAndDocComment
void FixAttributesAndDocComment(EntityDeclaration entity)
{
var node = entity.FirstChild;
while (node != null && node.Role == Roles.Comment) {
node = node.GetNextSibling(NoWhitespacePredicate);
FixIndentation(node);
}
if (entity.Attributes.Count > 0) {
AstNode n = null;
foreach (var attr in entity.Attributes.Skip (1)) {
FixIndentation(attr);
n = attr;
}
if (n != null) {
FixIndentation(n.GetNextNode(NoWhitespacePredicate));
} else {
FixIndentation(entity.Attributes.First().GetNextNode(NoWhitespacePredicate));
}
}
}
示例9: GetCorrectFileName
internal static string GetCorrectFileName (MDRefactoringContext context, EntityDeclaration type)
{
if (type == null)
return context.Document.FileName;
return Path.Combine (Path.GetDirectoryName (context.Document.FileName), type.Name + Path.GetExtension (context.Document.FileName));
}
示例10: MaybeCompileAndAddMethodToType
private void MaybeCompileAndAddMethodToType(JsClass jsClass, EntityDeclaration node, BlockStatement body, IMethod method, MethodScriptSemantics options)
{
if (options.GenerateCode) {
var typeParamNames = options.IgnoreGenericArguments ? (IEnumerable<string>)new string[0] : method.TypeParameters.Select(tp => _namer.GetTypeParameterName(tp)).ToList();
JsMethod jsMethod;
if (method.IsAbstract) {
jsMethod = new JsMethod(method, options.Name, typeParamNames, null);
}
else {
var compiled = CompileMethod(node, body, method, options);
jsMethod = new JsMethod(method, options.Name, typeParamNames, compiled);
}
AddCompiledMethodToType(jsClass, method, options, jsMethod);
}
}
示例11: HasScript
protected virtual bool HasScript(EntityDeclaration declaration)
{
return this.HasAttribute(declaration, Translator.Bridge_ASSEMBLY + ".Script");
}
示例12: AddMethod
private void AddMethod(bool ctor, EntityDeclaration methodDeclaration, AstNodeCollection<ParameterDeclaration> parameters)
{
CLRType t = m_clrTypes.Value.Last.Value;
List<KeyValuePair<string, string>> args = parameters.Select(p =>
new KeyValuePair<string, string>(p.Name, p.Type.ToString())
)
.ToList();
Method m = new Method(
CheckFlag(methodDeclaration.Modifiers, Modifiers.Override),
ctor,
CheckFlag(methodDeclaration.Modifiers, Modifiers.Static),
new Visibility(VisibilityMapper.Map(methodDeclaration.Modifiers)),
CheckFlag(methodDeclaration.Modifiers, Modifiers.Virtual),
methodDeclaration.Name,
CheckFlag(methodDeclaration.Modifiers, Modifiers.Abstract),
args,
methodDeclaration.ReturnType.ToString()
);
t.Methods.Add(m); // connect
}
示例13: GetInline
public virtual string GetInline(EntityDeclaration method)
{
var attr = this.GetAttribute(method.Attributes, Bridge.Translator.Translator.Bridge_ASSEMBLY + ".Template");
return attr != null && attr.Arguments.Count > 0 ? ((string)((PrimitiveExpression)attr.Arguments.First()).Value) : null;
}
示例14: ConvertMember
string ConvertMember(EntityDeclaration entity)
{
return ConvertHelper(entity, (p,obj,w,opt) => p.GenerateCodeFromMember((CodeTypeMember)obj, w, opt));
}
示例15: MatchAttributesAndModifiers
protected bool MatchAttributesAndModifiers(EntityDeclaration o, PatternMatching.Match match)
{
return (this.Modifiers == Modifiers.Any || this.Modifiers == o.Modifiers) && this.Attributes.DoMatch (o.Attributes, match);
}