本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.EntityDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# EntityDeclaration类的具体用法?C# EntityDeclaration怎么用?C# EntityDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityDeclaration类属于ICSharpCode.NRefactory.CSharp命名空间,在下文中一共展示了EntityDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:goncalod,项目名称:csharp,代码行数:7,代码来源:NRefactoryVisitorV2Helper.cs
示例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);
}
}
开发者ID:kenyamat,项目名称:ICGenerator,代码行数:20,代码来源:AppenderBase.cs
示例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));
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:12,代码来源:AbstractAndVirtualConversionAction.cs
示例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;
}
开发者ID:Osbourne,项目名称:monodevelop,代码行数:13,代码来源:AstAmbience.cs
示例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;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:16,代码来源:AbstractAndVirtualConversionAction.cs
示例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;
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:20,代码来源:Inspector.cs
示例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;
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:21,代码来源:Inspector.cs
示例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));
}
}
}
开发者ID:JoostK,项目名称:NRefactory,代码行数:20,代码来源:FormattingVisitor_Global.cs
示例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));
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:6,代码来源:MoveTypeToFile.cs
示例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);
}
}
开发者ID:jack128,项目名称:SaltarelleCompiler,代码行数:15,代码来源:Compiler.cs
示例11: HasScript
protected virtual bool HasScript(EntityDeclaration declaration)
{
return this.HasAttribute(declaration, Translator.Bridge_ASSEMBLY + ".Script");
}
开发者ID:yindongfei,项目名称:bridge.lua,代码行数:4,代码来源:Inspector.cs
示例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
}
开发者ID:goncalod,项目名称:csharp,代码行数:24,代码来源:NRefactoryVisitor.cs
示例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;
}
开发者ID:Cestbienmoi,项目名称:Bridge,代码行数:6,代码来源:Emitter.Helpers.cs
示例14: ConvertMember
string ConvertMember(EntityDeclaration entity)
{
return ConvertHelper(entity, (p,obj,w,opt) => p.GenerateCodeFromMember((CodeTypeMember)obj, w, opt));
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:4,代码来源:CodeDomConvertVisitorTests.cs
示例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);
}
开发者ID:CSRedRat,项目名称:NRefactory,代码行数:4,代码来源:EntityDeclaration.cs
示例16: WrapInType
static AstNode WrapInType(IUnresolvedTypeDefinition entity, EntityDeclaration decl)
{
if (entity == null)
return decl;
// Wrap decl in TypeDeclaration
decl = new TypeDeclaration {
ClassType = GetClassType(entity),
Modifiers = Modifiers.Partial,
Name = entity.Name,
Members = { decl }
};
if (entity.DeclaringTypeDefinition != null) {
// Handle nested types
return WrapInType(entity.DeclaringTypeDefinition, decl);
}
if (string.IsNullOrEmpty(entity.Namespace))
return decl;
return new NamespaceDeclaration(entity.Namespace) {
Members = {
decl
}
};
}
开发者ID:dgrunwald,项目名称:SharpDevelop,代码行数:23,代码来源:DebuggerDotCompletion.cs
示例17: UpdateMembers
void UpdateMembers(EntityDeclaration baseDeclaration, EntityDeclaration declaration)
{
if (declaration.Modifiers.HasFlag(Modifiers.Static)) {
declaration.Modifiers |= Modifiers.New;
} else {
declaration.Modifiers |= Modifiers.Override;
baseDeclaration.Modifiers |= Modifiers.Virtual;
}
}
开发者ID:corefan,项目名称:urho,代码行数:9,代码来源:CxxBinder.cs
示例18: NamespacedEntityDeclaration
public NamespacedEntityDeclaration(string @namespace, EntityDeclaration entityDeclaration)
{
Namespace = @namespace;
EntityDeclaration = entityDeclaration;
}
开发者ID:Saltarelle,项目名称:SaltarelleWeb,代码行数:5,代码来源:NamespacedEntityDeclaration.cs
示例19: UpdatePath
void UpdatePath (object sender, Mono.TextEditor.DocumentLocationEventArgs e)
{
var parsedDocument = Document.ParsedDocument;
if (parsedDocument == null || parsedDocument.ParsedFile == null)
return;
amb = new AstAmbience (document.GetFormattingOptions ());
var unit = parsedDocument.GetAst<SyntaxTree> ();
if (unit == null)
return;
var loc = Document.Editor.Caret.Location;
var curType = (EntityDeclaration)unit.GetNodeAt (loc, n => n is TypeDeclaration || n is DelegateDeclaration);
var curMember = unit.GetNodeAt<EntityDeclaration> (loc);
if (curType == curMember)
curMember = null;
if (isPathSet && curType == lastType && lastMember == curMember)
return;
var curTypeMakeup = GetEntityMarkup (curType);
var curMemberMarkup = GetEntityMarkup (curMember);
if (isPathSet && curType != null && lastType != null && curType.StartLocation == lastType.StartLocation && curTypeMakeup == lastTypeMarkup &&
curMember != null && lastMember != null && curMember.StartLocation == lastMember.StartLocation && curMemberMarkup == lastMemberMarkup)
return;
lastType = curType;
lastTypeMarkup = curTypeMakeup;
lastMember = curMember;
lastMemberMarkup = curMemberMarkup;
if (curType == null) {
if (CurrentPath != null && CurrentPath.Length == 1 && CurrentPath [0].Tag is IUnresolvedFile)
return;
var prevPath = CurrentPath;
CurrentPath = new PathEntry[] { new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit } };
OnPathChanged (new DocumentPathChangedEventArgs (prevPath));
return;
}
// ThreadPool.QueueUserWorkItem (delegate {
var result = new List<PathEntry> ();
if (curType != null) {
var type = curType;
while (type != null) {
var declaringType = type.Parent as TypeDeclaration;
result.Insert (0, new PathEntry (ImageService.GetPixbuf (type.GetStockIcon (false), Gtk.IconSize.Menu), GetEntityMarkup (type)) { Tag = (AstNode)declaringType ?? unit });
type = declaringType;
}
}
if (curMember != null) {
result.Add (new PathEntry (ImageService.GetPixbuf (curMember.GetStockIcon (true), Gtk.IconSize.Menu), curMemberMarkup) { Tag = curMember });
if (curMember is Accessor) {
var parent = curMember.Parent as EntityDeclaration;
if (parent != null)
result.Insert (result.Count - 1, new PathEntry (ImageService.GetPixbuf (parent.GetStockIcon (true), Gtk.IconSize.Menu), GetEntityMarkup (parent)) { Tag = parent });
}
}
var entry = GetRegionEntry (parsedDocument, loc);
if (entry != null)
result.Add (entry);
PathEntry noSelection = null;
if (curType == null) {
noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit };
} else if (curMember == null && !(curType is DelegateDeclaration)) {
noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = curType };
}
if (noSelection != null)
result.Add (noSelection);
var prev = CurrentPath;
if (prev != null && prev.Length == result.Count) {
bool equals = true;
for (int i = 0; i < prev.Length; i++) {
if (prev [i].Markup != result [i].Markup) {
equals = false;
break;
}
}
if (equals)
return;
}
// Gtk.Application.Invoke (delegate {
CurrentPath = result.ToArray ();
OnPathChanged (new DocumentPathChangedEventArgs (prev));
// });
// });
}
开发者ID:RainsSoft,项目名称:playscript-monodevelop,代码行数:94,代码来源:PathedDocumentTextEditorExtension.cs
示例20:
/// <summary>
/// Inserts the given EntityDeclaration with the given
/// script at the end of the type declaration under the
/// cursor (e.g. class / struct).
/// </summary>
/// <remarks>
/// Alters the given script. Returns its CurrentDocument
/// property. Alters the given memberDeclaration, adding
/// Modifiers.Override to its Modifiers as well as removing
/// Modifiers.Virtual.
/// </remarks>
IDocument runOverrideTargetWorker
( Request request
, OmniSharpRefactoringContext refactoringContext
, ParsedResult parsedContent
, EntityDeclaration memberDeclaration
, OmniSharpScript script) {
// Add override flag
memberDeclaration.Modifiers |= Modifiers.Override;
// Remove virtual flag
memberDeclaration.Modifiers &= ~ Modifiers.Virtual;
// The current type declaration, e.g. class, struct..
var typeDeclaration = parsedContent.SyntaxTree.GetNodeAt
( refactoringContext.Location
, n => n.NodeType == NodeType.TypeDeclaration);
// Even empty classes have nodes, so this works
var lastNode =
typeDeclaration.Children.Last();
script.InsertBefore
( node : lastNode
, newNode : memberDeclaration);
script.FormatText(memberDeclaration);
return script.CurrentDocument;
}
开发者ID:gamwang,项目名称:vimrc,代码行数:39,代码来源:OverrideHandler.cs
注:本文中的ICSharpCode.NRefactory.CSharp.EntityDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论