Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the QualifiedAliasOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal QualifiedAliasOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Reference, OperatorType.QualifiedAlias, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the NegativeOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal NegativeOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Unary, OperatorType.Negative, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the ConditionalOrOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal ConditionalOrOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Logical, OperatorType.ConditionalOr, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the OrEqualsOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal OrEqualsOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Assignment, OperatorType.OrEquals, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the MultiplicationOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal MultiplicationOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Arithmetic, OperatorType.Multiplication, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the SimpleToken class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The token string.</param>
        /// <param name="tokenType">The token type.</param>
        /// <param name="location">The location of the token within the code document.</param>
        /// <param name="generated">True if the token is inside of a block of generated code.</param>
        internal SimpleToken(CsDocument document, string text, int tokenType, CodeLocation location, bool generated)
            : base(new CodeUnitProxy(document), tokenType, location)
        {
            Param.Ignore(document, text, tokenType, location, generated);

            this.Text      = text;
            this.Generated = generated;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the Whitespace class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The whitespace text.</param>
        internal Whitespace(CsDocument document, string text)
            : base(document, LexicalElementType.WhiteSpace)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(text, "text");

            this.Text = text;
        }
Exemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the GreaterThanOperator class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal GreaterThanOperator(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, OperatorCategory.Relational, OperatorType.GreaterThan, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the ContinueToken class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal ContinueToken(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, TokenType.Continue, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the ElementHeaderLine class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal ElementHeaderLine(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, CommentType.ElementHeaderLine, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the OpenAttributeBracketToken class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 /// <param name="location">The location of the item.</param>
 /// <param name="generated">Indicates whether the item is generated.</param>
 internal OpenAttributeBracketToken(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, TokenType.OpenAttributeBracket, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the CodeModelException class.
        /// </summary>
        /// <param name="document">The document containing the exception.</param>
        /// <param name="message">The exception message.</param>
        internal CodeModelException(CsDocument document, string message)
            : base(string.Format(CultureInfo.CurrentCulture, Strings.CodeModelErrorWithMessage, document.Name, message))
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(message, "message");

            this.document = document;
        }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the RegionDirective class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The line text.</param>
 /// <param name="location">The location of the preprocessor in the code.</param>
 /// <param name="generated">Indicates whether the preprocessor lies within a block of generated code.</param>
 internal RegionDirective(CsDocument document, string text, CodeLocation location, bool generated)
     : base(document, text, PreprocessorType.Region, location, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
     Param.AssertNotNull(location, "location");
     Param.Ignore(generated);
 }
Exemplo n.º 14
0
        /// <summary>
        /// Initializes a new instance of the SyntaxException class.
        /// </summary>
        /// <param name="document">The document containing the exception.</param>
        /// <param name="lineNumber">The line number of the exception.</param>
        internal SyntaxException(CsDocument document, int lineNumber)
            : base(string.Format(CultureInfo.CurrentCulture, Strings.SyntaxErrorInFile, document.Name, lineNumber))
        {
            Param.AssertNotNull(document, "document");
            Param.AssertGreaterThanZero(lineNumber, "lineNumber");

            this.document   = document;
            this.lineNumber = lineNumber;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Creates and starts a code walker.
        /// </summary>
        /// <param name="document">The document to walk through.</param>
        /// <param name="callback">Callback executed when a code unit is visited.</param>
        /// <param name="context">The optional visitor context data.</param>
        /// <param name="codeUnitTypes">The types of code units to visit.</param>
        public static void Start(CsDocument document, CodeUnitVisitor <T> callback, T context, params CodeUnitType[] codeUnitTypes)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(callback, "callback");
            Param.Ignore(context);
            Param.Ignore(codeUnitTypes);

            WalkCodeUnit(document, callback, context, codeUnitTypes);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the CodeUnit class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="fundamentalType">The type of the code unit.</param>
        /// <param name="location">The location of the code unit.</param>
        internal CodeUnit(CsDocument document, int fundamentalType, CodeLocation location)
            : this(new CodeUnitProxy(document), fundamentalType)
        {
            Param.AssertNotNull(document, "document");
            Param.Ignore(fundamentalType);
            Param.Ignore(location);

            this.location.Value = location;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the Comment class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The line text.</param>
        /// <param name="commentType">The type of the comment.</param>
        internal Comment(CsDocument document, string text, CommentType commentType)
            : base(document, (int)commentType)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(text, "text");
            Param.Ignore(commentType);

            this.Text = text;
            CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(CommentType), this.CommentType), "The type is invalid.");
        }
Exemplo n.º 18
0
        /// <summary>
        /// Creates a TypeToken of type void.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <returns>Returns the token.</returns>
        private TypeToken CreateVoidTypeToken(CsDocument document)
        {
            Param.AssertNotNull(document, "document");

            var tokenProxy = new CodeUnitProxy(document);

            tokenProxy.Children.Add(new LiteralToken(document, "void", CodeLocation.Empty, this.Generated));

            return(new TypeToken(tokenProxy));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the SkippedSection class.
        /// </summary>
        /// <param name="document">The document that contains the section.</param>
        /// <param name="location">The location of the section.</param>
        /// <param name="generated">Indicates whether the section lies within a block of generated code.</param>
        /// <param name="contents">The contents of the section.</param>
        internal SkippedSection(CsDocument document, CodeLocation location, bool generated, string contents)
            : base(document, LexicalElementType.SkippedSection, location, generated)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertNotNull(location, "location");
            Param.Ignore(generated);
            Param.AssertNotNull(contents, "contents");

            this.Text = contents;
        }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the EndOfLine class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The text of the newline.</param>
        /// <param name="location">The location of the end-of-line in the code.</param>
        /// <param name="generated">True if the token is inside of a block of generated code.</param>
        internal EndOfLine(CsDocument document, string text, CodeLocation location, bool generated)
            : base(document, LexicalElementType.EndOfLine, location, generated)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(text, "text");
            Param.AssertNotNull(location, "location");
            Param.Ignore(generated);

            this.Text = text;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Initializes a new instance of the OperatorSymbolToken class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The text of the operator symbol.</param>
        /// <param name="category">The category of the operator.</param>
        /// <param name="symbolType">The specific symbol type.</param>
        internal OperatorSymbolToken(CsDocument document, string text, OperatorCategory category, OperatorType symbolType)
            : base(document, text, (int)symbolType)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(text, "text");
            Param.Ignore(category);
            Param.Ignore(symbolType);

            this.category = category;
            CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(OperatorType), this.SymbolType), "The type is invalid.");
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the SyntaxException class.
        /// </summary>
        /// <param name="document">The document containing the exception.</param>
        /// <param name="lineNumber">The line number of the exception.</param>
        /// <param name="message">The exception message.</param>
        /// <param name="innerException">The exception within this exception.</param>
        internal SyntaxException(CsDocument document, int lineNumber, string message, Exception innerException)
            : base(string.Format(CultureInfo.CurrentCulture, Strings.SyntaxErrorInFileWithMessage, document.Name, lineNumber, message), innerException)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertGreaterThanZero(lineNumber, "lineNumber");
            Param.AssertValidString(message, "message");
            Param.Ignore(innerException);

            this.document   = document;
            this.lineNumber = lineNumber;
        }
Exemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the SimpleLexicalElement class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="lexicalElementType">The lexical element type.</param>
        /// <param name="location">The location of the lexical element within the code document.</param>
        /// <param name="generated">True if the lexical element is inside of a block of generated code.</param>
        internal SimpleLexicalElement(CsDocument document, int lexicalElementType, CodeLocation location, bool generated)
            : base(new CodeUnitProxy(document), lexicalElementType, location)
        {
            Param.AssertNotNull(document, "document");
            Param.Ignore(lexicalElementType, generated);
            Param.Ignore(location);
            Param.Ignore(generated);

            CsLanguageService.Debug.Assert(System.Enum.IsDefined(typeof(LexicalElementType), this.LexicalElementType), "The type is invalid.");
            this.Generated = generated;
        }
Exemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the SimplePreprocessorDirective class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The preprocessor directive text.</param>
        /// <param name="preprocessorDirectiveType">The preprocessor directive type.</param>
        /// <param name="location">The location of the directive within the code document.</param>
        /// <param name="generated">True if the directive is inside of a block of generated code.</param>
        internal SimplePreprocessorDirective(CsDocument document, string text, PreprocessorType preprocessorDirectiveType, CodeLocation location, bool generated)
            : base(new CodeUnitProxy(document), preprocessorDirectiveType, location)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(text, "text");
            Param.Ignore(preprocessorDirectiveType);
            Param.AssertNotNull(location, "location");
            Param.Ignore(generated);

            this.Text      = text;
            this.Generated = generated;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the CloseBracketToken class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The token string.</param>
        /// <param name="tokenType">The token type.</param>
        /// <param name="location">The location of the token within the code document.</param>
        /// <param name="generated">True if the token is inside of a block of generated code.</param>
        internal CloseBracketToken(CsDocument document, string text, TokenType tokenType, CodeLocation location, bool generated)
            : base(document, text, tokenType, location, generated)
        {
            Param.Ignore(document, text, tokenType, location, generated);

            CsLanguageService.Debug.Assert(
                tokenType == TokenType.CloseCurlyBracket ||
                tokenType == TokenType.CloseSquareBracket ||
                tokenType == TokenType.CloseParenthesis ||
                tokenType == TokenType.CloseGenericBracket ||
                tokenType == TokenType.CloseAttributeBracket,
                "The symbol is not a bracket type.");
        }
Exemplo n.º 26
0
        /// <summary>
        /// Initializes a new instance of the OpenBracketToken class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The token string.</param>
        /// <param name="tokenType">The token type.</param>
        internal OpenBracketToken(CsDocument document, string text, TokenType tokenType)
            : base(document, text, tokenType)
        {
            Param.Ignore(document, text, tokenType);

            CsLanguageService.Debug.Assert(
                tokenType == TokenType.OpenCurlyBracket ||
                tokenType == TokenType.OpenSquareBracket ||
                tokenType == TokenType.OpenParenthesis ||
                tokenType == TokenType.OpenGenericBracket ||
                tokenType == TokenType.OpenAttributeBracket,
                "The symbol is not a bracket type.");
        }
Exemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the LiteralToken class.
        /// </summary>
        /// <param name="document">The parent document.</param>
        /// <param name="text">The text of the item.</param>
        internal LiteralToken(CsDocument document, string text)
            : base(document, text, TokenType.Literal)
        {
            Param.AssertNotNull(document, "document");
            Param.AssertValidString(text, "text");

            bool nonWhitespace = false;

            for (int i = 0; i < text.Length; ++i)
            {
                if (!char.IsWhiteSpace(text[i]))
                {
                    nonWhitespace = true;
                }
            }

            if (!nonWhitespace)
            {
                throw new ArgumentException(Strings.LiteralMustContainNonWhitespace, "text");
            }
        }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the DestructorTildeToken class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 internal DestructorTildeToken(CsDocument document)
     : base(document, "~", TokenType.DestructorTilde)
 {
     Param.AssertNotNull(document, "document");
 }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the NumberToken class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 /// <param name="text">The text of the item.</param>
 internal NumberToken(CsDocument document, string text)
     : base(document, text, TokenType.Number)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertValidString(text, "text");
 }
Exemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the BaseToken class.
 /// </summary>
 /// <param name="document">The parent document.</param>
 internal BaseToken(CsDocument document)
     : base(document, "base", TokenType.Base)
 {
     Param.AssertNotNull(document, "document");
 }