/// <summary> /// Initializes a new instance of the ConditionalCompilationDirective class. /// </summary> /// <param name="text"> /// The line text. /// </param> /// <param name="type"> /// The type of the directive. /// </param> /// <param name="body"> /// The expression that makes up the body of the directive. /// </param> /// <param name="location"> /// The location of the preprocessor in the code. /// </param> /// <param name="parent"> /// The parent code part. /// </param> /// <param name="generated"> /// Indicates whether the directive lies within a block of generated code. /// </param> internal ConditionalCompilationDirective( string text, ConditionalCompilationDirectiveType type, Expression body, CodeLocation location, Reference <ICodePart> parent, bool generated) : base(text, CsTokenClass.ConditionalCompilationDirective, location, parent, generated) { Param.AssertValidString(text, "text"); Param.Ignore(type); Param.Ignore(body); Param.AssertNotNull(location, "location"); Param.AssertNotNull(parent, "parent"); Param.Ignore(generated); this.type = type; this.body = body; }
/// <summary> /// Initializes a new instance of the ConditionalCompilationDirective class. /// </summary> /// <param name="text"> /// The line text. /// </param> /// <param name="type"> /// The type of the directive. /// </param> /// <param name="body"> /// The expression that makes up the body of the directive. /// </param> /// <param name="location"> /// The location of the preprocessor in the code. /// </param> /// <param name="parent"> /// The parent code part. /// </param> /// <param name="generated"> /// Indicates whether the directive lies within a block of generated code. /// </param> internal ConditionalCompilationDirective( string text, ConditionalCompilationDirectiveType type, Expression body, CodeLocation location, Reference<ICodePart> parent, bool generated) : base(text, CsTokenClass.ConditionalCompilationDirective, location, parent, generated) { Param.AssertValidString(text, "text"); Param.Ignore(type); Param.Ignore(body); Param.AssertNotNull(location, "location"); Param.AssertNotNull(parent, "parent"); Param.Ignore(generated); this.type = type; this.body = body; }
/// <summary> /// Gets the next conditional compilation directive from the code. /// </summary> /// <param name="preprocessorSymbol"> /// The symbol representing the directive. /// </param> /// <param name="type"> /// The type of the conditional compilation directive. /// </param> /// <param name="startIndex"> /// The start index of the body of the directive. /// </param> /// <param name="parent"> /// The parent code part. /// </param> /// <param name="generated"> /// Indicates whether the directive lies within a block of generated code. /// </param> /// <returns> /// Returns the directive. /// </returns> private ConditionalCompilationDirective GetConditionalCompilationDirective( Symbol preprocessorSymbol, ConditionalCompilationDirectiveType type, int startIndex, Reference<ICodePart> parent, bool generated) { Param.AssertNotNull(preprocessorSymbol, "preprocessorSymbol"); Param.Ignore(type); Param.AssertGreaterThanOrEqualToZero(startIndex, "startIndex"); Param.AssertNotNull(parent, "parent"); Param.Ignore(generated); Expression body = null; // Extract the body of the directive if necessary. if (type != ConditionalCompilationDirectiveType.Endif && startIndex < preprocessorSymbol.Text.Length) { body = CodeParser.GetConditionalPreprocessorBodyExpression(this.parser, this.document.SourceCode, preprocessorSymbol, startIndex); } // Create and return the directive. return new ConditionalCompilationDirective(preprocessorSymbol.Text, type, body, preprocessorSymbol.Location, parent, generated); }
private ConditionalCompilationDirective GetConditionalCompilationDirective(Symbol preprocessorSymbol, ConditionalCompilationDirectiveType type, int startIndex, bool generated) { Expression body = null; if ((type != ConditionalCompilationDirectiveType.Endif) && (startIndex < preprocessorSymbol.Text.Length)) { body = GetConditionalPreprocessorBodyExpression(this.parser, this.document.SourceCode, preprocessorSymbol, startIndex); } return new ConditionalCompilationDirective(preprocessorSymbol.Text, type, body, preprocessorSymbol.Location, generated); }