Ejemplo n.º 1
0
        private IEnumerable <CompletionItem> GetSymbolCompletions(SemanticModel model, BicepCompletionContext context)
        {
            if (!context.Kind.HasFlag(BicepCompletionContextKind.Expression) &&
                !context.Kind.HasFlag(BicepCompletionContextKind.DecoratorName))
            {
                return(Enumerable.Empty <CompletionItem>());
            }

            if (context.Kind.HasFlag(BicepCompletionContextKind.DecoratorName | BicepCompletionContextKind.MemberAccess))
            {
                // This is already handled by GetMemberAccessCompletions.
                return(Enumerable.Empty <CompletionItem>());
            }

            if (context.Property != null && model.GetDeclaredTypeAssignment(context.Property)?.Flags == DeclaredTypeFlags.Constant)
            {
                // the enclosing property's declared type is supposed to be a constant value
                // the constant flag comes from TypeProperty constant flag, so nothing else can really alter it except for another property
                // (in other words constant flag inherits down into the expression tree of the property value)
                return(Enumerable.Empty <CompletionItem>());
            }

            // when we're inside an expression that is inside a property that expects a compile-time constant value,
            // we should not be emitting accessible symbol completions
            return(GetAccessibleSymbolCompletions(model, context));
        }
Ejemplo n.º 2
0
 private static DeclaredTypeAssignment?GetDeclaredTypeAssignment(SemanticModel model, SyntaxBase?syntax) => syntax == null
     ? null
     : model.GetDeclaredTypeAssignment(syntax);