Exemplo n.º 1
0
 public ValuedDeclaration(QualifiedMemberName qualifiedName, string parentScope,
     string asTypeName, Accessibility accessibility, DeclarationType declarationType, string value, 
     ParserRuleContext context, Selection selection, bool isBuiltIn = false)
     :base(qualifiedName, parentScope, asTypeName, true, false, accessibility, declarationType, context, selection, isBuiltIn)
 {
     _value = value;
 }
        /// <summary>Common method for adding declaration with some default values</summary>
        private void AddDeclarationItem(IMock<ParserRuleContext> context,
            Selection selection,
            QualifiedMemberName? qualifiedName = null,
            DeclarationType declarationType = DeclarationType.Project,
            string identifierName = "identifierName")
        {
            Declaration declarationItem = null;
            var qualName = qualifiedName ?? new QualifiedMemberName(_module, "fakeModule");

            declarationItem = new Declaration(
                qualifiedName: qualName,
                parentScope: "module.proc",
                asTypeName: "asTypeName",
                isSelfAssigned: false,
                isWithEvents: false,
                accessibility: Accessibility.Public,
                declarationType: declarationType,
                context: context.Object,
                selection: selection
                );

            _declarations.Add(declarationItem);
            if (_listDeclarations == null) _listDeclarations = new List<Declaration>();
            _listDeclarations.Add(declarationItem);
        }
 public Declaration(string shortcut, string title, DeclarationType type, string description)
 {
     this.Type = type;
     this.shortcut = shortcut;
     this.title = title;
     this.description = description;
 }
Exemplo n.º 4
0
 public StreamDataType(short id, int numValues, int dataSize, DeclarationType declarationType, DeclarationUsage declarationUsage, byte usageIndex)
 {
     this.Id = id;
     this.NumValues = numValues;
     this.DataSize = dataSize;
     this.DeclarationType = declarationType;
     this.DeclarationUsage = declarationUsage;
     this.UsageIndex = usageIndex;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexElement"/> struct.
 /// </summary>
 /// <param name="stream">The stream.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="type">The type.</param>
 /// <param name="method">The method.</param>
 /// <param name="usage">The usage.</param>
 /// <param name="usageIndex">Index of the usage.</param>
 public VertexElement(short stream, short offset, DeclarationType type, DeclarationMethod method, DeclarationUsage usage, byte usageIndex)
 {
     Stream = stream;
     Offset = offset;
     Type = type;
     Method = method;
     Usage = usage;
     UsageIndex = usageIndex;
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new declaration with the specified filename, line and column.
        /// </summary>
        /// <param name="line">Line.</param>
        /// <param name="column">Column.</param>
        /// <param name="filename">Filename.</param>
        public Declaration(int line, int column, string filename, Uri relativeURI, DeclarationType declarationType)
        {
            this.Line = line;
            this.Col = column;

            Type = declarationType;

            if (relativeURI != null && filename != null)
                this.Filename = relativeURI.MakeRelativeUri (new Uri(Path.GetFullPath (filename))).ToString ();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a declaration for an Identifier node.
        /// </summary>
        /// <param name="declarationType">The type of the declaration.</param>
        /// <param name="identifier">The Identifier node to use.</param>
        /// <returns>An instance of the <see cref="Declaration"/> class.</returns>
        public static Declaration CreateDeclaration(DeclarationType declarationType, Identifier identifier)
        {
            if (identifier == null)
                throw new ArgumentNullException("identifier");

            return new Declaration
                    {
                        DeclarationType = declarationType,
                        Name = identifier.Name
                    };
        }
Exemplo n.º 8
0
 public Declaration(QualifiedMemberName qualifiedName, string parentScope,
     string asTypeName, bool isSelfAssigned, bool isWithEvents,
     Accessibility accessibility, DeclarationType declarationType, ParserRuleContext context, Selection selection, bool isBuiltIn = false)
 {
     _qualifiedName = qualifiedName;
     _parentScope = parentScope;
     _identifierName = qualifiedName.MemberName;
     _asTypeName = asTypeName;
     _isSelfAssigned = isSelfAssigned;
     _isWithEvents = isWithEvents;
     _accessibility = accessibility;
     _declarationType = declarationType;
     _selection = selection;
     _context = context;
     _isBuiltIn = isBuiltIn;
 }
            public AddVDataArguments(OpsParsedStatement statement)
            {
                OpsParsedArgument typeArg = statement.FindArgument("type");
                if(typeArg == null)
                {
                    typeArg = statement.FindArgument("");
                    if(typeArg == null)
                        throw new OpsException("'type' argument argument");
                }
                type = MeshDeclarationHelper.DecodeType(typeArg.Value);

                OpsParsedArgument usageArg = statement.FindArgument("usage");
                if(usageArg != null)
                    usage = MeshDeclarationHelper.DecodeUsage(usageArg.Value);

                OpsParsedArgument usageIdxArg = statement.FindArgument("usageIdx");
                if(usageIdxArg != null)
                    usageIdx = int.Parse( usageIdxArg.Value );

            }
Exemplo n.º 10
0
 public Declaration(
     QualifiedMemberName qualifiedName,
     Declaration parentDeclaration,
     Declaration parentScope,
     string asTypeName,
     string typeHint,
     bool isSelfAssigned,
     bool isWithEvents,
     Accessibility accessibility,
     DeclarationType declarationType,
     ParserRuleContext context,
     ParserRuleContext attributesPassContext,
     Selection selection,
     bool isArray,
     VBAParser.AsTypeClauseContext asTypeContext,
     bool isUserDefined = true,
     IEnumerable <IParseTreeAnnotation> annotations = null,
     Attributes attributes = null,
     bool undeclared       = false)
     : this(
         qualifiedName,
         parentDeclaration,
         parentScope?.Scope,
         asTypeName,
         typeHint,
         isSelfAssigned,
         isWithEvents,
         accessibility,
         declarationType,
         context,
         attributesPassContext,
         selection,
         isArray,
         asTypeContext,
         isUserDefined,
         annotations,
         attributes)
 {
     ParentScopeDeclaration = parentScope;
     IsUndeclared           = undeclared;
 }
Exemplo n.º 11
0
 public Declaration(
     QualifiedMemberName qualifiedName,
     Declaration parentDeclaration,
     Declaration parentScope,
     string asTypeName,
     bool isSelfAssigned,
     bool isWithEvents,
     Accessibility accessibility,
     DeclarationType declarationType,
     ParserRuleContext context,
     Selection selection,
     bool isBuiltIn = true,
     IEnumerable <IAnnotation> annotations = null,
     Attributes attributes = null)
     : this(
         qualifiedName, parentDeclaration, parentScope == null ? null : parentScope.Scope, asTypeName,
         isSelfAssigned, isWithEvents,
         accessibility, declarationType, context, selection, isBuiltIn, annotations, attributes)
 {
     _parentScopeDeclaration = parentScope;
 }
Exemplo n.º 12
0
 public MemberAccessDefaultBinding(
     DeclarationFinder declarationFinder,
     Declaration project,
     Declaration module,
     Declaration parent,
     ParserRuleContext expression,
     IBoundExpression lExpression,
     string name,
     StatementResolutionContext statementContext,
     ParserRuleContext unrestrictedNameContext)
 {
     _declarationFinder = declarationFinder;
     _project           = project;
     _module            = module;
     _parent            = parent;
     _context           = expression;
     _lExpression       = lExpression;
     _name = name;
     _propertySearchType      = StatementContext.GetSearchDeclarationType(statementContext);
     _unrestrictedNameContext = unrestrictedNameContext;
 }
        private static IEnumerable <IAnnotation> AnnotationsForDeclarationType(DeclarationType declarationType, IEnumerable <IAnnotation> annotations)
        {
            if (declarationType.HasFlag(DeclarationType.Module))
            {
                return(annotations.Where(annotation => annotation.Target.HasFlag(AnnotationTarget.Module)));
            }

            if (declarationType.HasFlag(DeclarationType.Member) &&
                declarationType != DeclarationType.LibraryProcedure &&
                declarationType != DeclarationType.LibraryFunction)
            {
                return(annotations.Where(annotation => annotation.Target.HasFlag(AnnotationTarget.Member)));
            }

            if (declarationType.HasFlag(DeclarationType.Variable))
            {
                return(annotations.Where(annotation => annotation.Target.HasFlag(AnnotationTarget.Variable)));
            }

            return(Enumerable.Empty <IAnnotation>());
        }
Exemplo n.º 14
0
        public void ImprovedArgumentList_AppliesByVal(DeclarationType declarationType)
        {
            var procedureIdentifier = "TestProperty";
            var procType            = ProcedureTypeIdentifier(declarationType);

            string inputCode =
                $@"
Public {procType.procType} {procedureIdentifier}(arg1 As Long, arg2 As String)
End {procType.endStmt}
";
            var result = ParseAndTest <ModuleBodyElementDeclaration>(inputCode,
                                                                     procedureIdentifier,
                                                                     declarationType,
                                                                     ImprovedArgumentListTest);

            var expected = declarationType.HasFlag(DeclarationType.Property)
                ? "arg1 As Long, ByVal arg2 As String"
                : "arg1 As Long, arg2 As String";

            StringAssert.AreEqualIgnoringCase(expected, result);
        }
Exemplo n.º 15
0
        public void AddSingleMember(string prototypeDeclaration, DeclarationType declarationType)
        {
            var inputCode =
                $@"
Option Explicit

Private Type TestType
    FirstValue As String
End Type

{prototypeDeclaration}
";
            var expectedUDT =
                $@"
Private Type TestType
    FirstValue As String
    Test As Long
End Type
";

            ExecuteTest(inputCode, "TestType", expectedUDT, ("mTest", "Test", declarationType));
        }
Exemplo n.º 16
0
        public void PropertyBlockFromPrototype_PropertySet(string targetIdentifier, DeclarationType declarationType, string typeName)
        {
            var    testParams = new PropertyBlockFromPrototypeParams("Bazz", DeclarationType.PropertySet);
            string inputCode  =
                $@"

Private Type TTestType
    FirstValue As Long
    SecondValue As Variant
End Type

Private fizz As Variant

";
            var result = ParseAndTest <Declaration>(inputCode,
                                                    targetIdentifier,
                                                    declarationType,
                                                    testParams,
                                                    PropertySetBlockFromPrototypeTest);

            StringAssert.Contains($"Property Set {testParams.Identifier}(ByVal {_rhsIdentifier} As {typeName})", result);
        }
Exemplo n.º 17
0
        public ComField(string name, VARDESC varDesc, int index, DeclarationType type)
        {
            Name  = name;
            Index = index;
            Type  = type;

            Flags = (VARFLAGS)varDesc.wVarFlags;

            if (Type == DeclarationType.Constant)
            {
                var value = new ComVariant(varDesc.desc.lpvarValue);
                DefaultValue = value.Value;
                string typeName;
                ValueType = ComVariant.TypeNames.TryGetValue(value.VariantType, out typeName) ? typeName : "Object";
            }
            else
            {
                Debug.Assert(varDesc.varkind == VARKIND.VAR_PERINSTANCE);
                string typeName;
                ValueType = ComVariant.TypeNames.TryGetValue((VarEnum)varDesc.elemdescVar.tdesc.vt, out typeName) ? typeName : "Object";
            }
        }
Exemplo n.º 18
0
        public void MemberBlockFromPrototype_AppliesByVal(DeclarationType declarationType)
        {
            var procedureIdentifier = "TestProcedure";
            var procType            = ProcedureTypeIdentifier(declarationType);

            string inputCode =
                $@"
Public {procType.procType} {procedureIdentifier}(arg1 As Long, arg2 As String)
End {procType.endStmt}
";
            var result = ParseAndTest <ModuleBodyElementDeclaration>(inputCode,
                                                                     procedureIdentifier,
                                                                     declarationType,
                                                                     new MemberBlockFromPrototypeTestParams(),
                                                                     MemberBlockFromPrototypeTest);

            var expected = declarationType.HasFlag(DeclarationType.Property)
                ? "(arg1 As Long, ByVal arg2 As String)"
                : "(arg1 As Long, arg2 As String)";

            StringAssert.Contains($"{procType.procType} {procedureIdentifier}{expected}", result);
        }
Exemplo n.º 19
0
        public bool HasTypeHint(out string token)
        {
            if (Context == null || _neverHinted.Any(item => DeclarationType.HasFlag(item)))
            {
                token        = null;
                _hasTypeHint = false;
                return(_hasTypeHint.Value);
            }

            try
            {
                var hint = ((dynamic)Context).typeHint();
                token        = hint == null ? null : hint.GetText();
                _hasTypeHint = hint != null;
                return(_hasTypeHint.Value);
            }
            catch (RuntimeBinderException)
            {
                token        = null;
                _hasTypeHint = false;
                return(_hasTypeHint.Value);
            }
        }
Exemplo n.º 20
0
        private static string ProcedureTypeStatement(DeclarationType declarationType)
        {
            switch (declarationType)
            {
            case DeclarationType.Function:
                return(Tokens.Function);

            case DeclarationType.Procedure:
                return(Tokens.Sub);

            case DeclarationType.PropertyGet:
                return($"{Tokens.Property} {Tokens.Get}");

            case DeclarationType.PropertyLet:
                return($"{Tokens.Property} {Tokens.Let}");

            case DeclarationType.PropertySet:
                return($"{Tokens.Property} {Tokens.Set}");

            default:
                throw new ArgumentException();
            }
        }
Exemplo n.º 21
0
        private (string procType, string endStmt) ProcedureTypeIdentifier(DeclarationType declarationType)
        {
            switch (declarationType)
            {
            case DeclarationType.Function:
                return("Function", "Function");

            case DeclarationType.Procedure:
                return("Sub", "Sub");

            case DeclarationType.PropertyGet:
                return("Property Get", "Property");

            case DeclarationType.PropertyLet:
                return("Property Let", "Property");

            case DeclarationType.PropertySet:
                return("Property Set", "Property");

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void Synchronize_RemovesMember(string removed, DeclarationType type = DeclarationType.Member)
        {
            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations
                          .TestProjectWithMemberRemoved(removed, out var componentDeclaration, type)
                          .TestComponentDeclarations(componentDeclaration.IdentifierName);

            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations
                               .TestComponentDeclarations(componentDeclaration.IdentifierName);

            var component = new CodeExplorerComponentViewModel(null, componentDeclaration, ref declarations, null);

            var expected = updates.Select(declaration => declaration.QualifiedName.ToString())
                           .OrderBy(_ => _)
                           .ToList();

            component.Synchronize(ref updates);

            var actual = component.GetAllChildDeclarations()
                         .Select(declaration => declaration.QualifiedName.ToString())
                         .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
        /// <inheritdoc/>
        protected override void HandleTypeDeclaration(CodeTypeDeclaration obj, DeclarationType type, Context ctx)
        {
            if (obj.CustomAttributes.Count > 0)
            {
                GeneralUtils.HandleCollection(obj.CustomAttributes.Cast<CodeAttributeDeclaration>(),
                    ctx.HandlerProvider.AttributeDeclarationHandler, ctx,
                    postAction: (c) =>
                    {
                        c.Writer.NewLine();
                        c.Writer.Indent(c);
                    }, doPostActionOnLast: true);
            }

            ctx.HandlerProvider.TypeAttributesHandler.Handle(obj.TypeAttributes, ctx);

            switch (type)
            {
                case DeclarationType.Class:
                    HandleClass(obj, ctx);
                    break;
                case DeclarationType.Struct:
                    HandleStruct(obj, ctx);
                    break;
                case DeclarationType.Interface:
                    HandleInterface(obj, ctx);
                    break;
                case DeclarationType.Enum:
                    HandleEnum(obj, ctx);
                    break;
                case DeclarationType.Delegate:
                    HandleDelegate((CodeTypeDelegate) obj, ctx);
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 24
0
        public void GetDeclarations(LuaBlockNode block, LuaModel model)
        {
            for (int i = 0; i < VariableList.Count; ++i)
            {
                LuaNode variable = VariableList[i];
                Declaration namespaces, sibling = null; 
                bool isDeclarationAssign = false;
                if (i < ExpressionList.Count)
                    isDeclarationAssign = DeclarationHelper.TryGetExpressionDeclaration(ExpressionList[i], block, model, out sibling);

                DeclarationType type = GetDeclarationType(variable, block, out namespaces);

                if (type == DeclarationType.Global && variable is LuaIdentifierNode)
                {
                    Declaration declaration = new Declaration(variable.AsString, String.Empty, model.FilePath, new ScopeSpan(variable.Span.EndPosition, variable.EndLine, int.MaxValue, int.MaxValue));
                    if (isDeclarationAssign) sibling.AddSibling(declaration);
                    block.Globals.Add(declaration);
                }
                else if (type == DeclarationType.Global && variable is LuaTableAccessNode)
                {
                    string[] names = variable.AsString.Split('.');
                    Declaration declaration = new Declaration(names[names.Length - 1], String.Empty, model.FilePath, new ScopeSpan(variable.Span.EndPosition, variable.EndLine,
                        int.MaxValue, int.MaxValue), namespaces);
                    if (isDeclarationAssign) sibling.AddSibling(declaration);
                    block.Globals.Add(declaration);
                }
                else if (type == DeclarationType.Local)
                {
                    string[] names = variable.AsString.Split('.');
                    Declaration declaration = new Declaration(names[names.Length - 1], String.Empty, model.FilePath, new ScopeSpan(variable.Span.EndPosition, variable.EndLine,
                        block.Span.EndPosition, block.EndLine), namespaces);
                    if (isDeclarationAssign) sibling.AddSibling(declaration);
                    block.Locals.Add(declaration);
                }
            }
        }
Exemplo n.º 25
0
 public Declaration(QualifiedMemberName qualifiedName, string parentScope,
     string asTypeName, bool isSelfAssigned, bool isWithEvents,
     Accessibility accessibility, DeclarationType declarationType, bool isBuiltIn = true)
     :this(qualifiedName, parentScope, asTypeName, isSelfAssigned, isWithEvents, accessibility, declarationType, null, Selection.Home, isBuiltIn)
 {}
Exemplo n.º 26
0
        /// <summary>
        /// Returns the declaration contained in a qualified selection.
        /// To get the selection of a variable or field, use FindVariable(QualifiedSelection)
        /// </summary>
        /// <param name="declarations"></param>
        /// <param name="selection"></param>
        /// <param name="validDeclarationTypes"></param>
        /// <returns></returns>
        public static Declaration FindTarget(this IEnumerable<Declaration> declarations, QualifiedSelection selection, DeclarationType[] validDeclarationTypes)
        {
            var items = declarations.ToList();

            var target = items
                .Where(item => !item.IsBuiltIn && validDeclarationTypes.Contains(item.DeclarationType))
                .SingleOrDefault(item => item.IsSelected(selection)
                                     || item.References.Any(r => r.IsSelected(selection)));

            if (target != null)
            {
                return target;
            }

            var targets = items
                .Where(item => !item.IsBuiltIn
                               && item.ComponentName == selection.QualifiedName.ComponentName
                               && validDeclarationTypes.Contains(item.DeclarationType));

            var currentSelection = new Selection(0, 0, int.MaxValue, int.MaxValue);

            foreach (var declaration in targets.Where(item => item.Context != null))
            {
                var activeSelection = new Selection(declaration.Context.Start.Line,
                                                    declaration.Context.Start.Column,
                                                    declaration.Context.Stop.Line,
                                                    declaration.Context.Stop.Column);

                if (currentSelection.Contains(activeSelection) && activeSelection.Contains(selection.Selection))
                {
                    target = declaration;
                    currentSelection = activeSelection;
                }

                foreach (var reference in declaration.References)
                {
                    var proc = (dynamic)reference.Context.Parent;
                    var paramList = proc ;

                    // This is to prevent throws when this statement fails:
                    // (VBAParser.ArgsCallContext)proc.argsCall();
                    var method = ((Type) proc.GetType()).GetMethod("argsCall");
                    if (method != null)
                    {
                        try { paramList = method.Invoke(proc, null); }
                        catch { continue; }
                    }

                    if (paramList == null) { continue; }

                    activeSelection = new Selection(paramList.Start.Line,
                                                    paramList.Start.Column,
                                                    paramList.Stop.Line,
                                                    paramList.Stop.Column + paramList.Stop.Text.Length + 1);

                    if (currentSelection.Contains(activeSelection) && activeSelection.Contains(selection.Selection))
                    {
                        target = reference.Declaration;
                        currentSelection = activeSelection;
                    }
                }
            }
            return target;
        }
Exemplo n.º 27
0
        public static List <Declaration> TestMemberDeclarations(this List <Declaration> declarations,
                                                                string memberName, out Declaration memberDeclaration, DeclarationType type = DeclarationType.Member)
        {
            var member = declarations.Single(declaration =>
                                             declaration.IdentifierName.Equals(memberName) &&
                                             (type == DeclarationType.Member || declaration.DeclarationType == type));

            var projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project);

            memberDeclaration = member;

            var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations);

            return(candidates.Where(declaration =>
                                    ReferenceEquals(declaration, member) ||
                                    ReferenceEquals(declaration.ParentDeclaration, member)).ToList());
        }
Exemplo n.º 28
0
 /// <summary>
 /// Gets the <see cref="Declaration"/> of the specified <see cref="type"/>, 
 /// at the specified <see cref="selection"/>.
 /// Returns the declaration if selection is on an identifier reference.
 /// </summary>
 public Declaration FindSelectedDeclaration(QualifiedSelection selection, DeclarationType type, Func<Declaration, Selection> selector = null)
 {
     return FindSelectedDeclaration(selection, new[] {type}, selector);
 }
Exemplo n.º 29
0
 public VectorDataType(short id, int numValues, int dataSize, DeclarationType declarationType, DeclarationUsage declarationUsage, byte usageIndex)
     : base(id, numValues, dataSize, declarationType, declarationUsage, usageIndex)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="VertexElementAttribute"/> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="usage">The vertex element usage.</param>
 public VertexElementAttribute(DeclarationType type, DeclarationUsage usage)
 {
     Type = type;
     Usage = usage;
 }
Exemplo n.º 31
0
 private void ResetToken()
 {
     _tokenIndex++;
     _name = null;
     _content = null;
     _attributes.Clear();
     _tokenType = TokenType.Usual;
     _declarationType = DeclarationType.Comment;
 }
Exemplo n.º 32
0
 /// <summary>
 /// Gets the <see cref="Declaration"/> of the specified <see cref="type"/>, 
 /// at the specified <see cref="selection"/>.
 /// Returns the declaration if selection is on an identifier reference.
 /// </summary>
 public static Declaration FindSelectedDeclaration(this IEnumerable<Declaration> declarations, QualifiedSelection selection, DeclarationType type, Func<Declaration, Selection> selector = null)
 {
     return FindSelectedDeclaration(declarations, selection, new[] { type }, selector);
 }
Exemplo n.º 33
0
        private static Uri GetIconUri(DeclarationType declarationType, Accessibility accessibility)
        {
            const string baseUri = @"../../Resources/Microsoft/PNG/";

            string path;
            switch (declarationType)
            {
                case DeclarationType.Module:
                    path = "VSObject_Module.png";
                    break;

                case DeclarationType.Document | DeclarationType.Class: 
                    path = "document.png";
                    break;
                
                case DeclarationType.UserForm | DeclarationType.Class | DeclarationType.Control:
                    path = "VSProject_Form.png";
                    break;

                case DeclarationType.Class | DeclarationType.Module:
                    path = "VSProject_Class.png";
                    break;

                case DeclarationType.Procedure | DeclarationType.Member:
                case DeclarationType.Function | DeclarationType.Member:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_Method_Private.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_Method_Friend.png";
                        break;
                    }

                    path = "VSObject_Method.png";
                    break;

                case DeclarationType.PropertyGet | DeclarationType.Property | DeclarationType.Function:
                case DeclarationType.PropertyLet | DeclarationType.Property | DeclarationType.Procedure:
                case DeclarationType.PropertySet | DeclarationType.Property | DeclarationType.Procedure:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_Properties_Private.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_Properties_Friend.png";
                        break;
                    }

                    path = "VSObject_Properties.png";
                    break;

                case DeclarationType.Parameter:
                    path = "VSObject_Field_Shortcut.png";
                    break;

                case DeclarationType.Variable:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_Field_Private.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_Field_Friend.png";
                        break;
                    }

                    path = "VSObject_Field.png";
                    break;

                case DeclarationType.Constant:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_Constant_Private.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_Constant_Friend.png";
                        break;
                    }

                    path = "VSObject_Constant.png";
                    break;

                case DeclarationType.Enumeration:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_Enum_Private.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_Enum_Friend.png";
                        break;
                    }

                    path = "VSObject_Enum.png";
                    break;

                case DeclarationType.EnumerationMember | DeclarationType.Constant:
                    path = "VSObject_EnumItem.png";
                    break;

                case DeclarationType.Event:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_Event_Private.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_Event_Friend.png";
                        break;
                    }

                    path = "VSObject_Event.png";
                    break;

                case DeclarationType.UserDefinedType:
                    if (accessibility == Accessibility.Private)
                    {
                        path = "VSObject_ValueTypePrivate.png";
                        break;
                    }
                    if (accessibility == Accessibility.Friend)
                    {
                        path = "VSObject_ValueType_Friend.png";
                        break;
                    }

                    path = "VSObject_ValueType.png";
                    break;

                case DeclarationType.UserDefinedTypeMember | DeclarationType.Variable:
                    path = "VSObject_Field.png";
                    break;

                case DeclarationType.LibraryProcedure | DeclarationType.Procedure:
                case DeclarationType.LibraryFunction | DeclarationType.Function:
                    path = "VSObject_Method_Shortcut.png";
                    break;

                case DeclarationType.LineLabel:
                    path = "VSObject_Constant_Shortcut.png";
                    break;

                case DeclarationType.Project:
                    path = "VSObject_Library.png";
                    break;

                default:
                    path = "VSObject_Structure.png";
                    break;
            }

            return new Uri(baseUri + path, UriKind.Relative);
        }
        private Declaration CreateDeclaration(string identifierName, string asTypeName, Accessibility accessibility, DeclarationType declarationType, ParserRuleContext context, Selection selection, bool selfAssigned = false, bool withEvents = false)
        {
            Declaration result;
            if (declarationType == DeclarationType.Parameter)
            {
                var argContext = (VBAParser.ArgContext)context;
                var isOptional = argContext.OPTIONAL() != null;
                var isByRef = argContext.BYREF() != null;
                var isParamArray = argContext.PARAMARRAY() != null;
                var isArray = argContext.LPAREN() != null;
                result = new ParameterDeclaration(new QualifiedMemberName(_qualifiedName, identifierName), _parentDeclaration, context, selection, asTypeName, isOptional, isByRef, isArray, isParamArray);
            }
            else
            {
                var key = Tuple.Create(identifierName, declarationType);
                Attributes attributes = null;
                if (_attributes.ContainsKey(key))
                {
                    attributes = _attributes[key];
                }

                var annotations = FindAnnotations(selection.StartLine);
                result = new Declaration(new QualifiedMemberName(_qualifiedName, identifierName), _parentDeclaration, _currentScopeDeclaration, asTypeName, selfAssigned, withEvents, accessibility, declarationType, context, selection, false, annotations, attributes);
            }

            OnNewDeclaration(result);
            return result;
        }
Exemplo n.º 35
0
        public static bool ExtractUsage(VertexElement[] elements, DeclarationUsage usage, int index, out DeclarationType format, out int offset)
        {
            format = (DeclarationType)0;
            offset = 0;

            for (int i = 0; i < elements.Length; i++)
            {
                if (elements[i].Usage == usage &&
                    elements[i].UsageIndex == index)
                {
                    format = elements[i].Type;
                    offset = elements[i].Offset;
                    return true;
                }
            }
            return false;
        }
Exemplo n.º 36
0
 public Declaration(DeclarationType type, ParsingException token)
 {
     DeclarationType = type;
     DeclarationToken = token;
 }
Exemplo n.º 37
0
        public Declaration FindMemberEnclosingProcedure(Declaration enclosingProcedure, string memberName, DeclarationType memberType)
        {
            var allMatches    = MatchName(memberName);
            var memberMatches = allMatches.Where(m =>
                                                 m.DeclarationType.HasFlag(memberType) &&
                                                 enclosingProcedure.Equals(m.ParentDeclaration));
            var match = memberMatches.FirstOrDefault();

            return(match);
        }
Exemplo n.º 38
0
 private static bool IsInstanceSensitive(DeclarationType memberType)
 {
     return(memberType.HasFlag(DeclarationType.Variable) || memberType == DeclarationType.Constant || memberType.HasFlag(DeclarationType.Procedure) || memberType.HasFlag(DeclarationType.Function));
 }
Exemplo n.º 39
0
        private void MarkupDeclarationAction()
        {
            Match result = _doctype.Match(_document.OriginalText, _pos);
            if (result.Success)
            {
                _pos += result.Length;
                _declarationType = DeclarationType.Document;
                SwitchState(TokenStage.BeforeDoctype);
                return;
            }

            result = _cddata.Match(_document.OriginalText, _pos);
            if (result.Success)
            {
                _pos += result.Length;
                _declarationType = DeclarationType.CDDATA;
                SwitchState(TokenStage.CDDATA);
                return;
            }

            result = _commentStart.Match(_document.OriginalText, _pos);
            if (result.Success)
            {
                _pos += result.Length;
                SwitchState(TokenStage.Comment);
                return;
            }

            SwitchState(TokenStage.OpenMarkupDeclaration);
        }
Exemplo n.º 40
0
        public Declaration FindMemberReferencedProjectInGlobalClassModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType)
        {
            var memberMatches     = FindAllInReferencedProjectByPriority(callingProject, memberName, p => p.DeclarationType.HasFlag(memberType) && (Declaration.GetModuleParent(p) == null || Declaration.GetModuleParent(p).DeclarationType == DeclarationType.ClassModule) && ((ClassModuleDeclaration)Declaration.GetModuleParent(p)).IsGlobalClassModule);
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            return(match);
        }
Exemplo n.º 41
0
 /// <summary>
 /// Creates a new valued built-in declaration.
 /// </summary>
 public ValuedDeclaration(QualifiedMemberName qualifiedName, string parentScope,
     string asTypeName, Accessibility accessibility, DeclarationType declarationType, string value)
     : this(qualifiedName, parentScope, asTypeName, accessibility, declarationType, value, null, Selection.Home, true)
 {
 }
Exemplo n.º 42
0
        public Declaration FindMemberReferencedProject(Declaration callingProject, Declaration callingModule, Declaration callingParent, Declaration referencedProject, string memberName, DeclarationType memberType)
        {
            var memberMatches     = FindAllInReferencedProjectByPriority(callingProject, memberName, p => p.DeclarationType.HasFlag(memberType) && referencedProject.Equals(Declaration.GetProjectParent(p)));
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            return(match);
        }
Exemplo n.º 43
0
        public Declaration FindMemberEnclosingModule(Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType)
        {
            // We do not explicitly pass the callingProject here because we have to walk up the type hierarchy
            // and thus the project differs depending on the callingModule.
            var callingProject = Declaration.GetProjectParent(callingModule);
            var allMatches     = MatchName(memberName);
            var memberMatches  = allMatches.Where(m =>
                                                  m.DeclarationType.HasFlag(memberType) &&
                                                  Declaration.GetProjectParent(m).Equals(callingProject) &&
                                                  callingModule.Equals(Declaration.GetModuleParent(m)));
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            if (match != null)
            {
                return(match);
            }
            // Classes such as Worksheet have properties such as Range that can be access in a user defined class such as Sheet1,
            // that's why we have to walk the type hierarchy and find these implementations.
            foreach (var supertype in ClassModuleDeclaration.GetSupertypes(callingModule))
            {
                // Only built-in classes such as Worksheet can be considered "real base classes".
                // User created interfaces work differently and don't allow accessing accessing implementations.
                if (!supertype.IsBuiltIn)
                {
                    continue;
                }
                var supertypeMatch = FindMemberEnclosingModule(supertype, callingParent, memberName, memberType);
                if (supertypeMatch != null)
                {
                    return(supertypeMatch);
                }
            }
            return(match);
        }
Exemplo n.º 44
0
        public Declaration FindSelection(QualifiedSelection selection, DeclarationType[] validDeclarationTypes)
        {
            var target = Items
                .Where(item => !item.IsBuiltIn)
                .FirstOrDefault(item => item.IsSelectedDeclaration(selection)
                                     || item.References.Any(r => r.IsSelectedReference(selection)));

            if (target != null && validDeclarationTypes.Contains(target.DeclarationType))
            {
                return target;
            }

            target = null;

            var targets = Items
                .Where(item => !item.IsBuiltIn
                               && item.ComponentName == selection.QualifiedName.ComponentName
                               && validDeclarationTypes.Contains(item.DeclarationType));

            var currentSelection = new Selection(0, 0, int.MaxValue, int.MaxValue);

            foreach (var declaration in targets)
            {
                var activeSelection = new Selection(declaration.Context.Start.Line,
                                                    declaration.Context.Start.Column,
                                                    declaration.Context.Stop.Line,
                                                    declaration.Context.Stop.Column);

                if (currentSelection.Contains(activeSelection) && activeSelection.Contains(selection.Selection))
                {
                    target = declaration;
                    currentSelection = activeSelection;
                }

                foreach (var reference in declaration.References)
                {
                    var proc = (dynamic)reference.Context.Parent;
                    VBAParser.ArgsCallContext paramList;

                    // This is to prevent throws when this statement fails:
                    // (VBAParser.ArgsCallContext)proc.argsCall();
                    try { paramList = (VBAParser.ArgsCallContext)proc.argsCall(); }
                    catch { continue; }

                    if (paramList == null) { continue; }

                    activeSelection = new Selection(paramList.Start.Line,
                                                    paramList.Start.Column,
                                                    paramList.Stop.Line,
                                                    paramList.Stop.Column + paramList.Stop.Text.Length + 1);

                    if (currentSelection.Contains(activeSelection) && activeSelection.Contains(selection.Selection))
                    {
                        target = reference.Declaration;
                        currentSelection = activeSelection;
                    }
                }
            }
            return target;
        }
Exemplo n.º 45
0
        public Declaration FindMemberEnclosedProjectWithoutEnclosingModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType)
        {
            var project = callingProject;
            var module  = callingModule;
            var parent  = callingParent;

            var allMatches    = MatchName(memberName);
            var memberMatches = allMatches.Where(m =>
                                                 m.DeclarationType.HasFlag(memberType) &&
                                                 Declaration.GetModuleParent(m).DeclarationType == DeclarationType.ProceduralModule &&
                                                 Declaration.GetProjectParent(m).Equals(callingProject) &&
                                                 !callingModule.Equals(Declaration.GetModuleParent(m)));
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            return(match);
        }
Exemplo n.º 46
0
 protected Declaration(DeclarationType declarationType)
 {
     DeclarationType = declarationType;
 }
Exemplo n.º 47
0
        public Declaration FindMemberReferencedProject(Declaration callingProject, Declaration callingModule, Declaration callingParent, string memberName, DeclarationType memberType)
        {
            bool isInstanceSensitive = IsInstanceSensitive(memberType);
            var  memberMatches       = FindAllInReferencedProjectByPriority(callingProject, memberName, p => (!isInstanceSensitive || Declaration.GetModuleParent(p) == null || Declaration.GetModuleParent(p).DeclarationType != DeclarationType.ClassModule) && p.DeclarationType.HasFlag(memberType));
            var  accessibleMembers   = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var  match = accessibleMembers.FirstOrDefault();

            return(match);
        }
Exemplo n.º 48
0
 /// <summary>
 /// Add the given type, scriptgetter and the typeName string to the respective dictionaries
 /// </summary>
 private void AddSupportedType(DeclarationType type, ScriptGetter scriptGetter, string typeName)
 {
     sqlScriptGetters.Add(type, scriptGetter);
     sqlObjectTypes.Add(type, typeName);
 }
Exemplo n.º 49
0
        public Declaration FindMemberReferencedProjectInModule(Declaration callingProject, Declaration callingModule, Declaration callingParent, Declaration memberModule, string memberName, DeclarationType memberType)
        {
            var memberMatches     = FindAllInReferencedProjectByPriority(callingProject, memberName, p => p.DeclarationType.HasFlag(memberType) && memberModule.Equals(Declaration.GetModuleParent(p)));
            var accessibleMembers = memberMatches.Where(m => AccessibilityCheck.IsMemberAccessible(callingProject, callingModule, callingParent, m));
            var match             = accessibleMembers.FirstOrDefault();

            if (match != null)
            {
                return(match);
            }
            foreach (var supertype in ClassModuleDeclaration.GetSupertypes(memberModule))
            {
                var supertypeMember = FindMemberReferencedProjectInModule(callingProject, callingModule, callingParent, supertype, memberName, memberType);
                if (supertypeMember != null)
                {
                    return(supertypeMember);
                }
            }
            return(null);
        }
Exemplo n.º 50
0
 public VertexElementAttribute(DeclarationUsage usage, DeclarationType format)
 {
     _usage = usage;
     _format = format;
 }
 private Declaration GetLetterOrSetter(Declaration declaration, DeclarationType declarationType)
 {
     return(_model.Declarations.FirstOrDefault(item => item.Scope == declaration.Scope &&
                                               item.IdentifierName == declaration.IdentifierName &&
                                               item.DeclarationType == declarationType));
 }
Exemplo n.º 52
0
 public VertexElementAttribute(DeclarationUsage usage)
 {
     _usage = usage;
     _format = DeclarationType.Unused;
 }
Exemplo n.º 53
0
        public static List <Declaration> TestProjectWithMemberRemoved(this List <Declaration> declarations,
                                                                      string memberName, out Declaration componentDeclaration, DeclarationType type = DeclarationType.Member)
        {
            var projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project);
            var removing           = declarations.ToList().TestMemberDeclarations(memberName, out var member, type);

            componentDeclaration = member.ParentDeclaration;

            var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations).ToList();

            return(candidates.Except(removing).ToList());
        }
Exemplo n.º 54
0
 public VertexElementAttribute(DeclarationUsage usage, byte usageIndex)
 {
     _usage = usage;
     _format = DeclarationType.Unused;
     _index = usageIndex;
 }
        private static Uri GetIconUri(DeclarationType declarationType, Accessibility accessibility)
        {
            const string baseUri = @"../Rubberduck.Resources/Icons/Fugue/";

            string path;

            switch (declarationType)
            {
            case DeclarationType.ProceduralModule:
                path = "ObjectModule.png";
                break;

            case DeclarationType.Document | DeclarationType.ClassModule:
                path = "Document.png";
                break;

            case DeclarationType.UserForm | DeclarationType.ClassModule | DeclarationType.Control:
                path = "ProjectForm.png";
                break;

            case DeclarationType.ClassModule | DeclarationType.ProceduralModule:
                path = "ObjectClass.png";
                break;

            case DeclarationType.Procedure | DeclarationType.Member:
            case DeclarationType.Function | DeclarationType.Member:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectMethodPrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectMethodFriend.png";
                    break;
                }

                path = "ObjectMethod.png";
                break;

            case DeclarationType.PropertyGet | DeclarationType.Property | DeclarationType.Function:
            case DeclarationType.PropertyLet | DeclarationType.Property | DeclarationType.Procedure:
            case DeclarationType.PropertySet | DeclarationType.Property | DeclarationType.Procedure:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectPropertiesPrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectPropertiesFriend.png";
                    break;
                }

                path = "ObjectProperties.png";
                break;

            case DeclarationType.Parameter:
                path = "ObjectFieldShortcut.png";
                break;

            case DeclarationType.Variable:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectFieldPrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectFieldFriend.png";
                    break;
                }

                path = "ObjectField.png";
                break;

            case DeclarationType.Constant:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectConstantPrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectConstantFriend.png";
                    break;
                }

                path = "ObjectConstant.png";
                break;

            case DeclarationType.Enumeration:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectEnumPrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectEnumFriend.png";
                    break;
                }

                path = "ObjectEnum.png";
                break;

            case DeclarationType.EnumerationMember:
                path = "ObjectEnumItem.png";
                break;

            case DeclarationType.Event:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectEventPrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectEventFriend.png";
                    break;
                }

                path = "ObjectEvent.png";
                break;

            case DeclarationType.UserDefinedType:
                if (accessibility == Accessibility.Private)
                {
                    path = "ObjectValueTypePrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "ObjectValueTypeFriend.png";
                    break;
                }

                path = "ObjectValueType.png";
                break;

            case DeclarationType.UserDefinedTypeMember:
                path = "ObjectField.png";
                break;

            case DeclarationType.LibraryProcedure | DeclarationType.Procedure:
            case DeclarationType.LibraryFunction | DeclarationType.Function:
                path = "ObjectMethodShortcut.png";
                break;

            case DeclarationType.LineLabel:
                path = "ObjectConstantShortcut.png";
                break;

            case DeclarationType.Project:
                path = "ObjectLibrary.png";
                break;

            default:
                path = "ObjectStructure.png";
                break;
            }

            return(new Uri(baseUri + path, UriKind.Relative));
        }
Exemplo n.º 56
0
 public VertexElementAttribute(DeclarationUsage usage, DeclarationType format, byte usageIndex)
 {
     _usage = usage;
     _format = format;
     _index = usageIndex;
 }
Exemplo n.º 57
0
        private IBoundExpression ResolveMemberInModule(IBoundExpression lExpression, string name, Declaration module, DeclarationType memberType, ExpressionClassification classification)
        {
            /*
             *  A member access expression under the procedure pointer binding context is valid only if <l-
             *  expression> is classified as a procedural module, this procedural module has an accessible function
             *  or subroutine with the same name value as <unrestricted-name>, and <unrestricted-name> either
             *  does not specify a type character or specifies a type character whose associated type matches the
             *  declared type of the function or subroutine. In this case, the member access expression is classified
             *  as a function or subroutine, respectively.
             */
            // AddressOf is only allowed in the same project. See The "procedure pointer binding context" for "simple name expressions" section in the MS-VBAL document.
            var enclosingProjectType = _declarationFinder.FindMemberEnclosedProjectInModule(_project, _module, _parent, module, name, memberType);

            if (enclosingProjectType != null)
            {
                return(new MemberAccessExpression(enclosingProjectType, classification, _expression, _unrestrictedNameContext, lExpression));
            }
            return(null);
        }
Exemplo n.º 58
0
 /// <summary>
 /// Gets all declarations of the specified <see cref="DeclarationType"/>.
 /// </summary>
 public static IEnumerable<Declaration> OfType(this IEnumerable<Declaration> declarations, DeclarationType declarationType)
 {
     return declarations.Where(declaration =>
         declaration.DeclarationType == declarationType);
 }
Exemplo n.º 59
0
        private static Uri GetIconUri(DeclarationType declarationType, Accessibility accessibility)
        {
            const string baseUri = @"../../Resources/Microsoft/PNG/";

            string path;

            switch (declarationType)
            {
            case DeclarationType.ProceduralModule:
                path = "VSObject_Module.png";
                break;

            case DeclarationType.Document | DeclarationType.ClassModule:
                path = "document.png";
                break;

            case DeclarationType.UserForm | DeclarationType.ClassModule | DeclarationType.Control:
                path = "VSProject_Form.png";
                break;

            case DeclarationType.ClassModule | DeclarationType.ProceduralModule:
                path = "VSProject_Class.png";
                break;

            case DeclarationType.Procedure | DeclarationType.Member:
            case DeclarationType.Function | DeclarationType.Member:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_Method_Private.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_Method_Friend.png";
                    break;
                }

                path = "VSObject_Method.png";
                break;

            case DeclarationType.PropertyGet | DeclarationType.Property | DeclarationType.Function:
            case DeclarationType.PropertyLet | DeclarationType.Property | DeclarationType.Procedure:
            case DeclarationType.PropertySet | DeclarationType.Property | DeclarationType.Procedure:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_Properties_Private.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_Properties_Friend.png";
                    break;
                }

                path = "VSObject_Properties.png";
                break;

            case DeclarationType.Parameter:
                path = "VSObject_Field_Shortcut.png";
                break;

            case DeclarationType.Variable:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_Field_Private.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_Field_Friend.png";
                    break;
                }

                path = "VSObject_Field.png";
                break;

            case DeclarationType.Constant:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_Constant_Private.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_Constant_Friend.png";
                    break;
                }

                path = "VSObject_Constant.png";
                break;

            case DeclarationType.Enumeration:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_Enum_Private.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_Enum_Friend.png";
                    break;
                }

                path = "VSObject_Enum.png";
                break;

            case DeclarationType.EnumerationMember | DeclarationType.Constant:
                path = "VSObject_EnumItem.png";
                break;

            case DeclarationType.Event:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_Event_Private.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_Event_Friend.png";
                    break;
                }

                path = "VSObject_Event.png";
                break;

            case DeclarationType.UserDefinedType:
                if (accessibility == Accessibility.Private)
                {
                    path = "VSObject_ValueTypePrivate.png";
                    break;
                }
                if (accessibility == Accessibility.Friend)
                {
                    path = "VSObject_ValueType_Friend.png";
                    break;
                }

                path = "VSObject_ValueType.png";
                break;

            case DeclarationType.UserDefinedTypeMember | DeclarationType.Variable:
                path = "VSObject_Field.png";
                break;

            case DeclarationType.LibraryProcedure | DeclarationType.Procedure:
            case DeclarationType.LibraryFunction | DeclarationType.Function:
                path = "VSObject_Method_Shortcut.png";
                break;

            case DeclarationType.LineLabel:
                path = "VSObject_Constant_Shortcut.png";
                break;

            case DeclarationType.Project:
                path = "VSObject_Library.png";
                break;

            default:
                path = "VSObject_Structure.png";
                break;
            }

            return(new Uri(baseUri + path, UriKind.Relative));
        }
Exemplo n.º 60
0
 public static int SizeOfFormatType(DeclarationType type)
 {
     return VertexDeclarationBuilder.SizeOfFormatType(type);
 }