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
Resolving symbolic references in a CodeDOM.
Nova.0.6.exe.zip
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 Nova.CodeDOM;

namespace Nova.Resolving
{
    /// <summary>
    /// The resolve category is used to restrict <see cref="UnresolvedRef"/>s to a particular sub-category when resolving them.
    /// </summary>
    public enum ResolveCategory
    {
        Unspecified,
        Type,                // type, type parameter, type alias
        Namespace,           // namespace
        NamespaceOrType,     // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
        Interface,           // interface
        Method,              // method, local variable or field of delegate type, event
        Constructor,         // constructor
        Attribute,           // attribute
        OperatorOverload,    // overloaded operator
        Property,            // property
        Indexer,             // indexer
        Event,               // event
        TypeParameter,       // type parameter
        LocalTypeParameter,  // local type parameter (looks at current method/class only - used by constraints and doc comments)
        Parameter,           // parameter (looks at current method only - used by doc comments)
        GotoTarget,          // label, switch item (case, default)
        NamespaceAlias,      // namespace alias
        RootNamespace,       // root-level namespace
        Expression,          // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
        CodeObject           // used only as a placeholder while resolving a tree of code objects
    }

    #region /* STATIC HELPER CLASS */

    /// <summary>
    /// Static helper methods for ResolveCategory.
    /// </summary>
    public static class ResolveCategoryHelpers
    {
        #region /* STATIC FIELDS */

        /// <summary>
        /// Determines if a ResolveCategory is a method category (has parameters).
        /// </summary>
        public static bool[] IsMethod =
            {
                false,  // Unspecified,
                false,  // Type,               // type, type parameter, type alias
                false,  // Namespace,          // namespace
                false,  // NamespaceOrType,    // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
                false,  // Interface,          // interface
                true,   // Method,             // method, local variable or field of delegate type, event
                true,   // Constructor,        // constructor
                true,   // Attribute,          // attribute
                false,  // OperatorOverload,   // overloaded operator
                false,  // Property,           // property
                true,   // Indexer,            // indexer
                false,  // Event,              // event
                false,  // TypeParameter,      // type parameter
                false,  // LocalTypeParameter, // local type parameter (looks at current method/class only - used by constraints and doc comments)
                false,  // Parameter,          // parameter (looks at current method only - used by doc comments)
                false,  // GotoTarget,         // label, switch item (case, default)
                false,  // ExternAlias,        // external namespace alias
                false,  // RootNamespace,      // root-level namespace
                false,  // Expression,         // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
                false   // CodeObject          // used only as a placeholder while resolving a tree of code objects
            };

        /// <summary>
        /// Determines if a ResolveCategory is a constructor category.
        /// </summary>
        public static bool[] IsConstructor =
            {
                false,  // Unspecified,
                false,  // Type,               // type, type parameter, type alias
                false,  // Namespace,          // namespace
                false,  // NamespaceOrType,    // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
                false,  // Interface,          // interface
                false,  // Method,             // method, local variable or field of delegate type, event
                true,   // Constructor,        // constructor
                true,   // Attribute,          // attribute
                false,  // OperatorOverload,   // overloaded operator
                false,  // Property,           // property
                false,  // Indexer,            // indexer
                false,  // Event,              // event
                false,  // TypeParameter,      // type parameter
                false,  // LocalTypeParameter, // local type parameter (looks at current method/class only - used by constraints and doc comments)
                false,  // Parameter,          // parameter (looks at current method only - used by doc comments)
                false,  // GotoTarget,         // label, switch item (case, default)
                false,  // ExternAlias,        // external namespace alias
                false,  // RootNamespace,      // root-level namespace
                false,  // Expression,         // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
                false   // CodeObject          // used only as a placeholder while resolving a tree of code objects
            };

        /// <summary>
        /// Determines if a ResolveCategory is a type or constructor category.
        /// </summary>
        public static bool[] IsTypeOrConstructor =
            {
                false,  // Unspecified,
                true,   // Type,               // type, type parameter, type alias
                false,  // Namespace,          // namespace
                false,  // NamespaceOrType,    // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
                false,  // Interface,          // interface
                false,  // Method,             // method, local variable or field of delegate type, event
                true,   // Constructor,        // constructor
                true,   // Attribute,          // attribute
                false,  // OperatorOverload,   // overloaded operator
                false,  // Property,           // property
                false,  // Indexer,            // indexer
                false,  // Event,              // event
                false,  // TypeParameter,      // type parameter
                false,  // LocalTypeParameter, // local type parameter (looks at current method/class only - used by constraints and doc comments)
                false,  // Parameter,          // parameter (looks at current method only - used by doc comments)
                false,  // GotoTarget,         // label, switch item (case, default)
                false,  // ExternAlias,        // external namespace alias
                false,  // RootNamespace,      // root-level namespace
                false,  // Expression,         // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
                false   // CodeObject          // used only as a placeholder while resolving a tree of code objects
            };

        /// <summary>
        /// Determines if a ResolveCategory is a method or property category.
        /// </summary>
        public static bool[] IsPropertyOrMethod =
            {
                false,  // Unspecified,
                false,  // Type,               // type, type parameter, type alias
                false,  // Namespace,          // namespace
                false,  // NamespaceOrType,    // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
                false,  // Interface,          // interface
                true,   // Method,             // method, local variable or field of delegate type, event
                true,   // Constructor,        // constructor
                true,   // Attribute,          // attribute
                false,  // OperatorOverload,   // overloaded operator
                true,   // Property,           // property
                true,   // Indexer,            // indexer
                true,   // Event,              // event
                false,  // TypeParameter,      // type parameter
                false,  // LocalTypeParameter, // local type parameter (looks at current method/class only - used by constraints and doc comments)
                false,  // Parameter,          // parameter (looks at current method only - used by doc comments)
                false,  // GotoTarget,         // label, switch item (case, default)
                false,  // ExternAlias,        // external namespace alias
                false,  // RootNamespace,      // root-level namespace
                true,   // Expression,         // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
                false   // CodeObject          // used only as a placeholder while resolving a tree of code objects
            };

        /// <summary>
        /// Determines if a ResolveCategory is a type-level category.
        /// </summary>
        /// <remarks>
        /// It's legal for the Expression category to include Type references, such as for "Type.StaticMember" (or enum members),
        /// so it's not included here - only categories that are members of types are included.  We can omit LocalTypeParameter,
        /// because searches will stop at the first TypeDecl regardless.
        /// </remarks>
        public static bool[] IsTypeLevel =
            {
                false,  // Unspecified,
                false,  // Type,               // type, type parameter, type alias
                false,  // Namespace,          // namespace
                false,  // NamespaceOrType,    // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
                false,  // Interface,          // interface
                true,   // Method,             // method, local variable or field of delegate type, event
                false,  // Constructor,        // constructor
                false,  // Attribute,          // attribute
                false,  // OperatorOverload,   // overloaded operator
                true,   // Property,           // property
                true,   // Indexer,            // indexer
                true,   // Event,              // event
                true,   // TypeParameter,      // type parameter
                false,  // LocalTypeParameter, // local type parameter (looks at current method/class only - used by constraints and doc comments)
                true,   // Parameter,          // parameter (looks at current method only - used by doc comments)
                true,   // GotoTarget,         // label, switch item (case, default)
                false,  // ExternAlias,        // external namespace alias
                false,  // RootNamespace,      // root-level namespace
                false,  // Expression,         // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
                false   // CodeObject          // used only as a placeholder while resolving a tree of code objects
            };

        /// <summary>
        /// Determines if a ResolveCategory is a method-level category.
        /// </summary>
        public static bool[] IsMethodLevel =
            {
                false,  // Unspecified,
                false,  // Type,               // type, type parameter, type alias
                false,  // Namespace,          // namespace
                false,  // NamespaceOrType,    // namespace or parent type (prefixed with a '.' before a Type, Interface, Constructor, or Attribute)
                false,  // Interface,          // interface
                false,  // Method,             // method, local variable or field of delegate type, event
                false,  // Constructor,        // constructor
                false,  // Attribute,          // attribute
                false,  // OperatorOverload,   // overloaded operator
                false,  // Property,           // property
                false,  // Indexer,            // indexer
                false,  // Event,              // event
                false,  // TypeParameter,      // type parameter
                false,  // LocalTypeParameter, // local type parameter (looks at current method/class only - used by constraints and doc comments)
                true,   // Parameter,          // parameter (looks at current method only - used by doc comments)
                true,   // GotoTarget,         // label, switch item (case, default)
                false,  // ExternAlias,        // external namespace alias
                false,  // RootNamespace,      // root-level namespace
                false,  // Expression,         // literal constant, local constant, local variable, parameter, field, field constant, enum value, property
                false   // CodeObject          // used only as a placeholder while resolving a tree of code objects
            };

        #endregion

        #region /* STATIC HELPER METHODS */

        #endregion
    }

    #endregion
}

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)

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 | Mobile
Web03 | 2.8.140721.1 | Last Updated 2 Dec 2012
Article Copyright 2012 by KenBeckett
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid