Beispiel #1
0
        public string GetFullFunctionOrEventHeaderText(PapyrusSymbol symbol)
        {
            if (symbol is FunctionSymbol functionSymbol)
            {
                var displayText = GetDisplayTextForFunction(functionSymbol);
                var typePrefix  = string.Empty;

                var typeIdentifier = functionSymbol.Definition.Header.TypeIdentifier;
                if (typeIdentifier != null)
                {
                    var returnType = symbol.GetPapyrusType();
                    typePrefix = (returnType?.Name.FullyQualifiedDisplayName ?? typeIdentifier.Text + (typeIdentifier.IsArray ? "[]" : string.Empty)) + " ";
                }

                return($"{typePrefix}Function {functionSymbol.Name}({displayText.Parameters.Select(t => t.Text).Join(", ")})");
            }

            if (symbol is EventSymbol eventSymbol)
            {
                var displayText = GetDisplayTextForEvent(eventSymbol);
                return($"Event {eventSymbol.Name}({displayText.Parameters.Select(t => t.Text).Join(", ")})");
            }

            return(null);
        }
Beispiel #2
0
        public DisplayText GetDisplayText(PapyrusSymbol symbol)
        {
            if (symbol is AliasedSymbol asAliased)
            {
                return(GetDisplayText(asAliased.Aliased));
            }

            // TODO: User flags

            switch (symbol.Kind)
            {
            case SymbolKinds.CustomEvent:
                return(GetBasicDisplayText(symbol.Name, "custom event", "CustomEvent"));

            case SymbolKinds.Event:
                var eventDisplayText = GetDisplayTextForEvent((EventSymbol)symbol);
                return(new DisplayText()
                {
                    Kind = eventDisplayText.Kind,
                    Text = $"{eventDisplayText.Prefix}({eventDisplayText.Parameters.Select(t => t.Text).Join(", ")}){eventDisplayText.Postfix}",
                    Documentation = eventDisplayText.Documentation
                });

            case SymbolKinds.Function:
                var funcDisplayText = GetDisplayTextForFunction((FunctionSymbol)symbol);
                return(new DisplayText()
                {
                    Kind = funcDisplayText.Kind,
                    Text = $"{funcDisplayText.Prefix}({funcDisplayText.Parameters.Select(t => t.Text).Join(", ")}){funcDisplayText.Postfix}",
                    Documentation = funcDisplayText.Documentation
                });

            case SymbolKinds.Group:
                return(GetBasicDisplayText(symbol.Name, "group", "Group"));

            case SymbolKinds.Import:
                return(GetBasicDisplayText(symbol.Name, "import", "Import"));

            case SymbolKinds.Property:
                return(GetDisplayTextForProperty((PropertySymbol)symbol));

            case SymbolKinds.State:
                return(GetDisplayTextForState((StateSymbol)symbol));

            case SymbolKinds.Struct:
                return(GetBasicDisplayText(
                           symbol.GetPapyrusType()?.Name.FullyQualifiedDisplayName
                           ?? symbol.Name, "struct", "Struct"));

            case SymbolKinds.Variable:
                return(GetDisplayTextForVariable((VariableSymbol)symbol));

            case SymbolKinds.Script:
                return(GetDisplayTextForScript((ScriptSymbol)symbol));
            }

            return(null);
        }
Beispiel #3
0
        public string GetEventHandlerSignatureText(PapyrusSymbol symbol)
        {
            if (symbol is EventSymbol eventSymbol)
            {
                var displayText = GetDisplayTextForEvent(eventSymbol);
                return($"{eventSymbol.Name}({symbol.Parent.Name} akSender, {displayText.Parameters.Select(t => t.Text).Join(", ")})");
            }

#if FALLOUT4
            if (symbol is CustomEventSymbol customEventSymbol)
            {
                return($"{customEventSymbol.Name}({symbol.Parent.Name} akSender, Var[] akArgs)");
            }
#endif
            return(null);
        }
Beispiel #4
0
        public PapyrusSymbol(SyntaxNode node, IdentifierNode identifier, PapyrusSymbol parent)
        {
            _node          = node;
            _documentation = new string[] { _node.GetLeadingComments() };

            _identifier = identifier;

            _parent = parent;
            if (_parent != null)
            {
                lock (_parent._children)
                {
                    _parent._children.Add(this);
                }
            }
        }
Beispiel #5
0
 protected TypeSymbol(SyntaxNode node, IdentifierNode identifier, PapyrusSymbol parent, ObjectIdentifier id) : base(node, identifier, parent)
 {
     _id = id;
 }
Beispiel #6
0
 public StructSymbol(StructDefinitionNode node, PapyrusSymbol parent) :
     base(node, node.Header.Identifier, parent, ObjectIdentifier.Parse(parent.Name + "#" + node.Header.Identifier.Text))
 {
 }
Beispiel #7
0
 public VariableSymbol(ITypedIdentifiable node, PapyrusSymbol parent) : base((SyntaxNode)node, node.Identifier, parent)
 {
     DefaultValue = node is FunctionParameterNode asFunctionParameter ? asFunctionParameter.DefaultValue : null;
 }
Beispiel #8
0
 public PropertySymbol(PropertyDefinitionNode node, PapyrusSymbol parent) : base(node, node.Header.Identifier, parent)
 {
 }
Beispiel #9
0
 public StateSymbol(StateDefinitionNode node, PapyrusSymbol parent) : base(node, node.Identifier, parent)
 {
 }
Beispiel #10
0
 public ImportSymbol(ImportNode node, PapyrusSymbol parent) : base(node, node.Identifier, parent)
 {
 }
Beispiel #11
0
 public GroupSymbol(GroupDefinitionNode node, PapyrusSymbol parent) : base(node, node.Header.Identifier, parent)
 {
 }
Beispiel #12
0
 public FunctionSymbol(FunctionDefinitionNode node, PapyrusSymbol parent) : base(node, node.Header.Identifier, parent)
 {
 }
Beispiel #13
0
 public EventSymbol(EventDefinitionNode node, PapyrusSymbol parent) : base(node, node.Header.Identifier, parent)
 {
 }
Beispiel #14
0
 public CustomEventSymbol(CustomEventDefinitionNode node, PapyrusSymbol parent) : base(node, node.Identifier, parent)
 {
 }