コード例 #1
0
ファイル: FullSymbol.cs プロジェクト: microsoft/BuildXL
        /// <summary>
        /// Adds a identifier that might be relative, abandons if the identifier is invalid.
        /// </summary>
        /// <remarks>
        /// This is useful for hard-coded identifiers, don't use with any user input since it will kill the process on bad format.
        /// </remarks>
        /// <param name="table">The identifier table to use.</param>
        /// <param name="relativeId">The identifier to add. If absolute this will be the identifier returned, otherwise the relative identifier is tacked onto the end of the base identifier.</param>
        /// <returns>Final resulting absolute identifier.</returns>
        public FullSymbol Combine(SymbolTable table, StringSegment relativeId)
        {
            Contract.RequiresNotNull(table, "table != null");
            PartialSymbol relIdentifier;

            PartialSymbol.ParseResult parseResult = PartialSymbol.TryCreate(table.StringTable, relativeId, out relIdentifier, out _);
            if (parseResult != PartialSymbol.ParseResult.Success)
            {
                Contract.Assume(false, I($"Failed to create a full symbol from the segment '{relativeId.ToString()}'"));
            }

            return(AddIdentifierComponents(table, this, relIdentifier.Components));
        }
コード例 #2
0
ファイル: FullSymbol.cs プロジェクト: erickulcyk/BuildXL
        /// <summary>
        /// Adds a identifier that might be relative, abandons if the identifier is invalid.
        /// </summary>
        /// <remarks>
        /// This is useful for hard-coded identifiers, don't use with any user input since it will kill the process on bad format.
        /// </remarks>
        /// <param name="table">The identifier table to use.</param>
        /// <param name="relativeId">The identifier to add. If absolute this will be the identifier returned, otherwise the relative identifier is tacked onto the end of the base identifier.</param>
        /// <returns>Final resulting absolute identifier.</returns>
        public FullSymbol Combine(SymbolTable table, StringSegment relativeId)
        {
            Contract.Requires(table != null, "table != null");
            Contract.Ensures(Contract.Result <FullSymbol>() != FullSymbol.Invalid);

            int           characterWithError;
            PartialSymbol relIdentifier;

            PartialSymbol.ParseResult parseResult = PartialSymbol.TryCreate(table.StringTable, relativeId, out relIdentifier, out characterWithError);
            if (parseResult != PartialSymbol.ParseResult.Success)
            {
                Contract.Assume(false, I($"Failed to create a full symbol from the segment '{relativeId.ToString()}'"));
            }

            return(AddIdentifierComponents(table, this, relIdentifier.Components));
        }
コード例 #3
0
ファイル: FullSymbol.cs プロジェクト: microsoft/BuildXL
        /// <summary>
        /// Tries to break down an absolute identifier string into its constituent parts.
        /// </summary>
        private static ParseResult TryGetComponents(SymbolTable table, StringSegment fullSymbol, out StringId[] components, out int characterWithError)
        {
            Contract.RequiresNotNull(table, "table != null");

            PartialSymbol relIdentifier;

            PartialSymbol.ParseResult parseResult = PartialSymbol.TryCreate(table.StringTable, fullSymbol, out relIdentifier, out characterWithError);
            if (parseResult == PartialSymbol.ParseResult.Success)
            {
                components         = relIdentifier.Components;
                characterWithError = -1;
                return(ParseResult.Success);
            }

            components = null;

            return(parseResult == PartialSymbol.ParseResult.LeadingOrTrailingDot
                ? ParseResult.LeadingOrTrailingDot
                : ParseResult.FailureDueToInvalidCharacter);
        }