Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Resolving Symbolic References in a CodeDOM (Part 7)

, 2 Dec 2012 CDDL
Resolving symbolic references in a CodeDOM.
Nova.0.6.exe.zip
Mono.Cecil.dll
Nova.CLI.exe
Nova.CodeDOM.dll
Nova.Examples.exe
Nova.Studio.exe
Nova.Test.exe
Nova.UI.dll
Nova.0.6.zip
Nova.CLI
Properties
Nova.CodeDOM
CodeDOM
Annotations
Base
Comments
Base
DocComments
CodeRef
Base
List
Name
Base
Other
Simple
CompilerDirectives
Base
Conditionals
Base
Messages
Base
Pragmas
Base
Symbols
Base
Base
Interfaces
Expressions
AnonymousMethods
Base
Operators
Base
Binary
Arithmetic
Base
Assignment
Base
Bitwise
Base
Conditional
Relational
Base
Shift
Base
Other
Base
Unary
Base
Other
References
Base
GotoTargets
Base
Methods
Namespaces
Other
Properties
Types
Base
Variables
Base
Projects
Assemblies
Namespaces
References
Base
Statements
Base
Conditionals
Base
Exceptions
Generics
Constraints
Base
Iterators
Base
Jumps
Loops
Methods
OperatorDecls
Miscellaneous
Namespaces
Properties
Base
Events
Types
Base
Variables
Base
Parsing
Base
Properties
Rendering
Resolving
Utilities
Mono.Cecil
Reflection
Nova.Examples
Properties
Nova.Studio
Images
About.png
Configuration.png
EditCopy.png
EditCut.png
EditDelete.png
EditPaste.png
EditRedo.png
EditUndo.png
Error.png
Exit.png
FileNew.png
FileOpen.png
FileSave.png
FileSaveAll.png
FileSaveAs.png
Find.png
Help.png
Info.png
Logo.png
Options.png
Print.png
PrintPreview.png
Properties.png
Todo.png
Warning.png
Objects.ico
Properties
Settings.settings
Nova.Test
Properties
Nova.UI
CodeDOM
Annotations
Base
Comments
Base
DocComments
CodeRef
Base
List
Name
Base
Other
Simple
CompilerDirectives
Base
Conditionals
Base
Messages
Base
Pragmas
Base
Symbols
Base
Base
Expressions
AnonymousMethods
Base
Operators
Base
Binary
Arithmetic
Base
Assignment
Base
Bitwise
Base
Conditional
Relational
Base
Shift
Base
Other
Base
Unary
Base
Other
References
Base
GotoTargets
Base
Methods
Namespaces
Other
Properties
Types
Base
Variables
Base
Projects
Namespaces
References
Base
Statements
Base
Conditionals
Base
Exceptions
Generics
Constraints
Base
Iterators
Base
Jumps
Loops
Methods
OperatorDecls
Miscellaneous
Namespaces
Properties
Base
Events
Types
Base
Variables
Base
Properties
Resolving
Utilties
// The Nova Project by Ken Beckett.
// Copyright (C) 2007-2012 Inevitable Software, all rights reserved.
// Released under the Common Development and Distribution License, CDDL-1.0: http://opensource.org/licenses/cddl1.php

using System.Collections;
using System.Collections.Generic;

using Nova.Resolving;

namespace Nova.CodeDOM
{
    /// <summary>
    /// This interface is implemented by all code objects that represent type declarations,
    /// which includes <see cref="TypeDecl"/>, <see cref="TypeParameter"/>, and <see cref="Alias"/>.
    /// </summary>
    public interface ITypeDecl : INamedCodeObject
    {
        /// <summary>
        /// The parent <see cref="CodeObject"/>.
        /// </summary>
        CodeObject Parent { get; }

        /// <summary>
        /// True if the type is abstract.
        /// </summary>
        bool IsAbstract { get; }

        /// <summary>
        /// True if the type is a class.
        /// </summary>
        bool IsClass { get; }

        /// <summary>
        /// True if the type is a delegate type.
        /// </summary>
        bool IsDelegateType { get; }

        /// <summary>
        /// True if the type is an enum.
        /// </summary>
        bool IsEnum { get; }

        /// <summary>
        /// True if the type is a generic parameter.
        /// </summary>
        bool IsGenericParameter { get; }

        /// <summary>
        /// True if the type is a generic type (meaning that either it or an enclosing type has type parameters,
        /// and it's not an enum).
        /// </summary>
        bool IsGenericType { get; }

        /// <summary>
        /// True if the type is an interface.
        /// </summary>
        bool IsInterface { get; }

        /// <summary>
        /// True if the type is a nested type.
        /// </summary>
        bool IsNested { get; }

        /// <summary>
        /// True if the type is a nullable type.
        /// </summary>
        bool IsNullableType { get; }

        /// <summary>
        /// True if the type is a partial type.
        /// </summary>
        bool IsPartial { get; }

        /// <summary>
        /// True if the type is a struct.
        /// </summary>
        bool IsStruct { get; }

        /// <summary>
        /// True if the type is a value type.
        /// </summary>
        bool IsValueType { get; }

        /// <summary>
        /// The number of <see cref="TypeParameter"/>s the type has.
        /// </summary>
        int TypeParameterCount { get; }

        /// <summary>
        /// Create a reference to the type.
        /// </summary>
        TypeRef CreateRef(bool isFirstOnLine, ChildList<Expression> typeArguments, List<int> arrayRanks);

        /// <summary>
        /// Create a reference to the type.
        /// </summary>
        TypeRef CreateRef(bool isFirstOnLine, ChildList<Expression> typeArguments);

        /// <summary>
        /// Create a reference to the type.
        /// </summary>
        TypeRef CreateRef(ChildList<Expression> typeArguments, List<int> arrayRanks);

        /// <summary>
        /// Create a reference to the type.
        /// </summary>
        TypeRef CreateRef(ChildList<Expression> typeArguments);

        /// <summary>
        /// Create an array reference to the type.
        /// </summary>
        TypeRef CreateArrayRef(bool isFirstOnLine, params int[] ranks);

        /// <summary>
        /// Create an array reference to the type.
        /// </summary>
        TypeRef CreateArrayRef(params int[] ranks);

        /// <summary>
        /// Create a nullable reference to the type.
        /// </summary>
        TypeRef CreateNullableRef(bool isFirstOnLine);

        /// <summary>
        /// Create a nullable reference to the type.
        /// </summary>
        TypeRef CreateNullableRef();

        /// <summary>
        /// Resolve child code objects that match the specified name.
        /// </summary>
        void ResolveRef(string name, Resolver resolver);

        /// <summary>
        /// Resolve indexers.
        /// </summary>
        void ResolveIndexerRef(Resolver resolver);

        /// <summary>
        /// Find a type argument in a base class for the specified type parameter.
        /// </summary>
        TypeRefBase FindTypeArgumentInBase(TypeParameterRef typeParameterRef);

        /// <summary>
        /// Returns the first attribute expression (<see cref="Call"/> or <see cref="ConstructorRef"/>) with the specified name on the <see cref="CodeObject"/>.
        /// </summary>
        Expression GetAttribute(string attributeName);

        /// <summary>
        /// Get the base type.
        /// </summary>
        TypeRef GetBaseType();

        /// <summary>
        /// Get the <see cref="Namespace"/> for this <see cref="CodeObject"/>.
        /// </summary>
        Namespace GetNamespace();

        /// <summary>
        /// Get the non-static constructor with the specified parameters.
        /// </summary>
        ConstructorRef GetConstructor(params TypeRefBase[] parameterTypes);

        /// <summary>
        /// Get all non-static constructors for this type.
        /// </summary>
        NamedCodeObjectGroup GetConstructors(bool currentPartOnly);

        /// <summary>
        /// Get all non-static constructors for this type.
        /// </summary>
        NamedCodeObjectGroup GetConstructors();

        /// <summary>
        /// Get the method with the specified name and parameter types.
        /// </summary>
        MethodRef GetMethod(string name, params TypeRefBase[] parameterTypes);

        /// <summary>
        /// Get all methods with the specified name.
        /// </summary>
        /// <param name="name">The method name.</param>
        /// <param name="searchBaseClasses">Pass <c>false</c> to NOT search base classes.</param>
        List<MethodRef> GetMethods(string name, bool searchBaseClasses);

        /// <summary>
        /// Get all methods with the specified name.
        /// </summary>
        /// <param name="name">The method name.</param>
        List<MethodRef> GetMethods(string name);

        /// <summary>
        /// Get all methods with the specified name.
        /// </summary>
        void GetMethods(string name, bool searchBaseClasses, NamedCodeObjectGroup results);

        /// <summary>
        /// Get the property with the specified name.
        /// </summary>
        PropertyRef GetProperty(string name);

        /// <summary>
        /// Get the field with the specified name.
        /// </summary>
        FieldRef GetField(string name);

        /// <summary>
        /// Get the nested type with the specified name.
        /// </summary>
        TypeRef GetNestedType(string name);

        /// <summary>
        /// Get the delegate parameters of the type (if any).
        /// </summary>
        ICollection GetDelegateParameters();

        /// <summary>
        /// Get the delegate return type of the type (if any).
        /// </summary>
        TypeRefBase GetDelegateReturnType();

        /// <summary>
        /// Determine if the type is assignable from the specified type.
        /// </summary>
        bool IsAssignableFrom(TypeRef typeRef);

        /// <summary>
        /// Determine if the type is a subclass of the specified type.
        /// </summary>
        bool IsSubclassOf(TypeRef classTypeRef);

        /// <summary>
        /// Determine if the type implements the specified interface type.
        /// </summary>
        bool IsImplementationOf(TypeRef interfaceTypeRef);

#if TYPE_BUILDING
        Type GetRuntimeType(bool complete);
#endif
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)

Share

About the Author

KenBeckett
Software Developer (Senior)
United States United States
I've been writing software since the late 70's, currently focusing mainly on C#.NET. I also like to travel around the world, and I own a Chocolate Factory (sadly, none of my employees are oompa loompas).

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 2 Dec 2012
Article Copyright 2012 by KenBeckett
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid