本文整理汇总了C#中ICSharpCode.NRefactory.Ast.TypeDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# TypeDeclaration类的具体用法?C# TypeDeclaration怎么用?C# TypeDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeDeclaration类属于ICSharpCode.NRefactory.Ast命名空间,在下文中一共展示了TypeDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TrackedVisitTypeDeclaration
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (IsDerivedFrom(typeDeclaration, "Comparator"))
{
IList methods = AstUtil.GetChildrenWithType(typeDeclaration, typeof(MethodDeclaration));
MethodDeclaration equalsMethod = new MethodDeclaration("equals",
Modifiers.Public, AstUtil.GetTypeReference("bool", typeDeclaration), new List<ParameterDeclarationExpression>(), null);
equalsMethod.Parent = typeDeclaration;
TypeReference argTypeReference = AstUtil.GetTypeReference("java.lang.Object", equalsMethod);
argTypeReference.RankSpecifier = new int[] {};
equalsMethod.Parameters.Add(new ParameterDeclarationExpression(argTypeReference, "obj"));
if (Contains(methods, equalsMethod))
{
int index = IndexOf(methods, equalsMethod);
MethodDeclaration method = (MethodDeclaration) methods[index];
AstUtil.RemoveModifierFrom(method, Modifiers.Abstract);
method.TypeReference.Type = "bool";
CreateMethodImplementation(method);
}
else
{
CreateMethodImplementation(equalsMethod);
typeDeclaration.Children.Add(equalsMethod);
equalsMethod.Parent = typeDeclaration;
}
}
return base.TrackedVisitTypeDeclaration(typeDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:31,代码来源:IKVMDifferencesTransformer.cs
示例2: GetMethodsInParents
private IList GetMethodsInParents(TypeDeclaration typeDeclaration, IList pmList, bool implemented)
{
ClassType classType;
if (implemented)
classType = ClassType.Class;
else
classType = ClassType.Interface;
if (typeDeclaration.BaseTypes.Count > 0)
{
foreach (TypeReference parentType in typeDeclaration.BaseTypes)
{
string baseType = GetFullName(parentType);
if (CodeBase.Types.Contains(baseType))
{
TypeDeclaration parentTypeDeclaration = (TypeDeclaration) CodeBase.Types[baseType];
if (parentTypeDeclaration.Type == classType)
{
pmList = GetMethods(parentTypeDeclaration, pmList);
pmList = GetMethodsInParents(parentTypeDeclaration, pmList, implemented);
}
}
}
}
return pmList;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:25,代码来源:AbstractClassTransformer.cs
示例3: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
currentClass = currentNamepace + "." + typeDeclaration.Name;
base.VisitTypeDeclaration(typeDeclaration, data);
currentClass = null;
return null;
}
开发者ID:almazik,项目名称:ILSpy,代码行数:7,代码来源:SimplifyTypeReferences.cs
示例4: TrackedVisitTypeDeclaration
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (IsAbstractClass(typeDeclaration))
{
IList currentClassMethods = AstUtil.GetChildrenWithType(typeDeclaration, typeof(MethodDeclaration));
currentClassMethods = GetMethodsInParents(typeDeclaration, currentClassMethods, true);
IList methodsInParents = new ArrayList();
methodsInParents = GetMethodsInParents(typeDeclaration, methodsInParents, false);
methodsInParents = FilterImplementedMethods(methodsInParents);
IList abstractMethods = GetDiffList(currentClassMethods, methodsInParents);
if (abstractMethods.Count > 0)
{
TypeDeclaration replacedTypeDeclaration = typeDeclaration;
foreach (MethodDeclaration method in abstractMethods)
{
MethodDeclaration newMethod;
newMethod = new MethodDeclaration(method.Name,
Modifiers.Public | Modifiers.Abstract,
method.TypeReference,
method.Parameters,
method.Attributes);
newMethod.Parent = replacedTypeDeclaration;
replacedTypeDeclaration.Children.Add(newMethod);
}
ReplaceCurrentNode(replacedTypeDeclaration);
}
}
return base.TrackedVisitTypeDeclaration(typeDeclaration, data);
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:30,代码来源:AbstractClassTransformer.cs
示例5: GenerateText
public static string GenerateText(TypeDeclaration type, OrderedPartCollection<AbstractDynamicCompilationExtension> extensions)
{
var unit = new CompilationUnit();
var namespaces = new HashSet<string>
{
typeof (SystemTime).Namespace,
typeof (AbstractViewGenerator).Namespace,
typeof (Enumerable).Namespace,
typeof (IEnumerable<>).Namespace,
typeof (IEnumerable).Namespace,
typeof (int).Namespace,
typeof (LinqOnDynamic).Namespace,
typeof(Field).Namespace,
};
foreach (var extension in extensions)
{
foreach (var ns in extension.Value.GetNamespacesToImport())
{
namespaces.Add(ns);
}
}
foreach (var ns in namespaces)
{
unit.AddChild(new Using(ns));
}
unit.AddChild(type);
var output = new CSharpOutputVisitor();
unit.AcceptVisitor(output, null);
return output.Text;
}
开发者ID:iamnilay3,项目名称:ravendb,代码行数:34,代码来源:QueryParsingUtils.cs
示例6: VerifyMethodCondition
protected override bool VerifyMethodCondition(TypeDeclaration typeDeclaration, MethodDeclaration methodDeclaration)
{
IList methods = AstUtil.GetChildrenWithType(typeDeclaration, typeof(MethodDeclaration));
string name = methodDeclaration.Name.Substring(3);
if (Contains(methods, methodDeclaration))
{
IList innerTypes = AstUtil.GetChildrenWithType(typeDeclaration, typeof(TypeDeclaration));
foreach (TypeDeclaration innerType in innerTypes)
{
if (innerType.Name == name)
return true;
}
IList constructors = AstUtil.GetChildrenWithType(typeDeclaration, typeof(ConstructorDeclaration));
foreach (ConstructorDeclaration constructorDeclaration in constructors)
{
if (constructorDeclaration.Name == name)
return true;
}
foreach (MethodDeclaration method in methods)
{
if (method.Name == name || char.ToUpper(method.Name[0]) + method.Name.Substring(1) == name)
return true;
}
}
else
{
IList properties = AstUtil.GetChildrenWithType(typeDeclaration, typeof(PropertyDeclaration));
return Contains(properties, name);
}
return false;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:32,代码来源:AccessorRefactoringHelper.cs
示例7: VisitTypeDeclaration
public override object VisitTypeDeclaration (TypeDeclaration node, object data)
{
if (CurrentType != null) {
Console.WriteLine ("Nested types are not supported");
//throw CreateException (node, "Nested types are not supported");
}
if (IsHiddenClass (node))
return null;
if ((node.Modifier & Modifiers.Partial) > 0) {
Console.WriteLine ("Partial classes are not supported: " + node);
//throw CreateException (node, "Partial classes are not supported");
}
CurrentType = new JsTypeInfo { Name = GenericsHelper.GetScriptName (node), ClassType = node.Type, Namespace = Namespace, Usings = new HashSet<string> (Usings) };
Usings = new HashSet<string> ();
CurrentType.IsStatic = node.Type == ClassType.Enum || HasModifier (node.Modifier, Modifiers.Static);
if (node.Type != ClassType.Interface)
node.AcceptChildren (this, null);
if (CachedCctor != null) {
if (!ProcessCctor ())
throw CreateException (node, "Static constructor may only contain primitive or array static field initializations");
CachedCctor = null;
}
CollectedTypes.Add (CurrentType);
CurrentType = null;
return null;
}
开发者ID:hallvar,项目名称:Joddes.CS,代码行数:33,代码来源:JsSourceInspector.cs
示例8: GetConstructorInfo
public static PythonConstructorInfo GetConstructorInfo(TypeDeclaration type)
{
PythonConstructorInfo pythonConstructorInfo;
List<FieldDeclaration> fieldDeclarations = new List<FieldDeclaration>();
ConstructorDeclaration constructorDeclaration = null;
foreach (INode child in type.Children)
{
ConstructorDeclaration constructorDeclaration1 = child as ConstructorDeclaration;
FieldDeclaration fieldDeclaration = child as FieldDeclaration;
if (constructorDeclaration1 != null)
{
constructorDeclaration = constructorDeclaration1;
}
else if (fieldDeclaration != null)
{
fieldDeclarations.Add(fieldDeclaration);
}
}
if ((fieldDeclarations.Count > 0 ? false : constructorDeclaration == null))
{
pythonConstructorInfo = null;
}
else
{
pythonConstructorInfo = new PythonConstructorInfo(constructorDeclaration, fieldDeclarations);
}
return pythonConstructorInfo;
}
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:28,代码来源:PythonConstructorInfo.cs
示例9: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
Push();
object result = base.VisitTypeDeclaration(typeDeclaration, data);
Pop();
return result;
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:PrefixFieldsVisitor.cs
示例10: Generate
internal static string Generate(ParametrizedNode methodToCall, TypeDeclaration parentType,
string returnVariableName)
{
var template = new MethodCallStub(methodToCall, parentType, returnVariableName);
var text = template.TransformText();
return text;
}
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:7,代码来源:MethodCallStub.cs
示例11: add_Type
// create
public static TypeDeclaration add_Type(this NamespaceDeclaration namespaceDeclaration, IClass iClass)
{
// move to method IClass.typeDeclaration();
var typeName = iClass.Name;
var newType = namespaceDeclaration.type(typeName); // check if already exists and if it does return it
if (newType != null)
return newType;
const Modifiers modifiers = Modifiers.None | Modifiers.Public;
newType = new TypeDeclaration(modifiers, new List<AttributeSection>());
newType.Name = typeName;
foreach (var baseType in iClass.BaseTypes)
{
if (baseType.FullyQualifiedName != "System.Object") // no need to include this one
newType.BaseTypes.Add(new TypeReference(baseType.FullyQualifiedName));
}
namespaceDeclaration.AddChild(newType);
return newType;
//return namespaceDeclaration.add_Type(iClass.Name);
}
开发者ID:njmube,项目名称:FluentSharp,代码行数:26,代码来源:TypeDeclaration_ExtensionMethods.cs
示例12: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (typeDeclaration.Type == ClassType.Class && typeDeclaration.Modifier.HasFlag(Modifiers.Abstract))
UnlockWith(typeDeclaration);
return base.VisitTypeDeclaration(typeDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:7,代码来源:AbstractClass.cs
示例13: CreateType
public TypeDeclaration CreateType(TypeDefinition typeDef)
{
TypeDeclaration astType = new TypeDeclaration(ConvertModifiers(typeDef), new List<AttributeSection>());
astType.Name = typeDef.Name;
if (typeDef.IsEnum) { // NB: Enum is value type
astType.Type = ClassType.Enum;
} else if (typeDef.IsValueType) {
astType.Type = ClassType.Struct;
} else if (typeDef.IsInterface) {
astType.Type = ClassType.Interface;
} else {
astType.Type = ClassType.Class;
}
// Nested types
foreach(TypeDefinition nestedTypeDef in typeDef.NestedTypes) {
astType.Children.Add(CreateType(nestedTypeDef));
}
// Base type
if (typeDef.BaseType != null && !typeDef.IsValueType && typeDef.BaseType.FullName != Constants.Object) {
astType.BaseTypes.Add(new Ast.TypeReference(typeDef.BaseType.FullName));
}
AddTypeMembers(astType, typeDef);
return astType;
}
开发者ID:almazik,项目名称:ILSpy,代码行数:29,代码来源:AstBuilder.cs
示例14: IsMethodInExternalTypes
protected bool IsMethodInExternalTypes(TypeDeclaration typeDeclaration, MethodDeclaration methodDeclaration)
{
bool found = false;
foreach (TypeReference baseType in typeDeclaration.BaseTypes)
{
string fullName = GetFullName(baseType);
if (!found && CodeBase.Types.Contains(fullName))
{
TypeDeclaration baseTypeDeclaration = (TypeDeclaration) CodeBase.Types[fullName];
if (IsInExternalLibraries(fullName) || fullName.StartsWith("Helpers."))
{
IList methods = AstUtil.GetChildrenWithType(baseTypeDeclaration, typeof(MethodDeclaration));
if (ContainsMethod(methods, methodDeclaration))
found = true;
else
found = IsMethodInExternalTypes(baseTypeDeclaration, methodDeclaration);
}
else
found = IsMethodInExternalTypes(baseTypeDeclaration, methodDeclaration);
if (found)
break;
}
}
return found;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:26,代码来源:Refactoring.cs
示例15: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if (typeDeclaration.Type == ClassType.Class || typeDeclaration.Type == ClassType.Struct)
Classes.Add(typeDeclaration.Name, typeDeclaration);
return base.VisitTypeDeclaration(typeDeclaration, data);
}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:7,代码来源:IndexableMethodFinderVisitor.cs
示例16: Check
void Check(TypeDeclaration td)
{
Assert.AreEqual("Lexer", td.Name);
Assert.AreEqual(2, td.Children.Count);
Assert.AreEqual(0, ((ConstructorDeclaration)td.Children[0]).Body.Children.Count);
Assert.AreEqual(0, ((MethodDeclaration)td.Children[1]).Body.Children.Count);
}
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:SkipMethodBodiesTest.cs
示例17: VisitTypeDeclaration
public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
if(typeDeclaration.Type == ClassType.Interface)
UnlockWith(typeDeclaration);
return base.VisitTypeDeclaration(typeDeclaration, data);
}
开发者ID:timdams,项目名称:strokes,代码行数:7,代码来源:CreateInterface.cs
示例18: TrackedVisitTypeDeclaration
public override object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
{
fields = AstUtil.GetChildrenWithType(typeDeclaration, typeof(FieldDeclaration));
base.TrackedVisitTypeDeclaration(typeDeclaration, data);
AddNotDeclaredAccessor(typeDeclaration);
return null;
}
开发者ID:sourcewarehouse,项目名称:janett,代码行数:8,代码来源:AccessorRefactoring.cs
示例19: VisitTypeDeclaration_NotWizardStepPage_DoesNothing
public void VisitTypeDeclaration_NotWizardStepPage_DoesNothing()
{
var type = new TypeDeclaration(Modifiers.Public, new List<AttributeSection>()) {Name = "SomeRandomType"};
mocks.ReplayAll();
visitor.VisitTypeDeclaration(type, null);
mocks.VerifyAll();
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:8,代码来源:WizardStepPageVisitorTests.cs
示例20: add_Property_To_Type_Constructor
public static API_ASMX_Proxy add_Property_To_Type_Constructor(this API_ASMX_Proxy asmxProxy, TypeDeclaration targetType, string propertyName, TypeDeclaration propertyType)
{
targetType.add_Property(propertyName,propertyType)
.add_Ctor()
.body()
.add_Assignment(propertyName, propertyType);
return asmxProxy;
}
开发者ID:paul-green,项目名称:O2.Platform.Scripts,代码行数:8,代码来源:API_ASMX_Proxy.cs
注:本文中的ICSharpCode.NRefactory.Ast.TypeDeclaration类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论