コード例 #1
0
        private void HandleBracketForClassContent(TempClassContent target, Token token)
        {
            if (string.IsNullOrEmpty(target.ReturnType) && string.IsNullOrEmpty(target.Name))
            {
                throw new InvalidDataException("Got brackets without type");
            }

            // Move the name over to type since this cannot be a name
            if (string.IsNullOrEmpty(target.ReturnType))
            {
                target.ReturnType = target.Name;
                target.Name = null;
            }

            target.ReturnType += token.Contents;
        }
コード例 #2
0
        private void HandleIdentifierForClassContent(TempClassContent target, Token token, bool inThrows)
        {
            if (inThrows)
            {
                target.AddThrow(token.Contents);
                return;
            }

            bool hasReturnValue = !string.IsNullOrEmpty(target.ReturnType);

            if (!string.IsNullOrEmpty(target.Name) && hasReturnValue)
            {
                throw new InvalidDataException("Name already set, unknown token at this point");
            }

            // Check if we are within a qualified type declaration
            if (hasReturnValue && target.ReturnType.EndsWith("."))
            {
                target.ReturnType += token.Contents;
                return;
            }

            // Move the name over to return type
            if (!string.IsNullOrEmpty(target.Name))
            {
                target.ReturnType = target.Name;
            }

            target.Name = token.Contents;
        }
コード例 #3
0
        private void HandleQualifiedTypeForClassContent(TempClassContent target, Token token)
        {
            bool hasReturnValue = !string.IsNullOrEmpty(target.ReturnType);
            bool hasName = !string.IsNullOrEmpty(target.Name);

            if (hasName && hasReturnValue)
            {
                throw new InvalidDataException("Name already set, unknown token at this point");
            }

            if (!hasReturnValue)
            {
                // Move the name over since we are starting a qualified type
                if (hasName)
                {
                    target.ReturnType = target.Name;
                    target.Name = null;
                }
                else
                {
                    throw new InvalidDataException("Qualified type was expected");
                }
            }

            target.ReturnType += token.Contents;
        }