public override IT4InfoCollectorState GetNextState(IT4TreeNode element)
        {
            switch (element)
            {
            case IT4FeatureBlock:
                return(new T4InfoCollectorStateSeenFeature(Interrupter));

            case IT4ExpressionBlock:
                return(new T4InfoCollectorStateSeenFeatureAndExpressionBlock(Interrupter));

            default:
                if (element.NodeType == T4TokenNodeTypes.NEW_LINE)
                {
                    return(this);
                }
                else if (element.NodeType == T4TokenNodeTypes.RAW_TEXT)
                {
                    return(new T4InfoCollectorStateSeenFeatureAndText(Builder, Interrupter, element));
                }

                var data = T4FailureRawData.FromElement(element, "Unexpected element after feature");
                Interrupter.InterruptAfterProblem(data);
                return(this);
            }
        }
예제 #2
0
        public override IT4InfoCollectorState GetNextState(IT4TreeNode element)
        {
            switch (element)
            {
            case IT4FeatureBlock _: return(this);

            case IT4ExpressionBlock _:
                return(new T4InfoCollectorStateSeenFeatureAndExpressionBlock(Interrupter));

            default:
                if (element.NodeType == T4TokenNodeTypes.NEW_LINE)
                {
                    return(new T4InfoCollectorStateSeenFeatureAndNewLine(Interrupter));
                }
                else if (element.NodeType == T4TokenNodeTypes.RAW_TEXT)
                {
                    // At this point, LastToken is initialized through ConsumeTokenSafe call
                    var builder = new StringBuilder(Convert(LastToken));
                    return(new T4InfoCollectorStateSeenFeatureAndText(builder, Interrupter, element));
                }

                var data = T4FailureRawData.FromElement(element, "Unexpected element after feature");
                Interrupter.InterruptAfterProblem(data);
                return(this);
            }
        }
예제 #3
0
        public override IT4InfoCollectorState GetNextState(IT4TreeNode element)
        {
            switch (element)
            {
            case IT4FeatureBlock _:
                return(new T4InfoCollectorStateSeenFeature(Interrupter));

            case IT4ExpressionBlock _:
                return(this);

            default:
                if (element.NodeType == T4TokenNodeTypes.NEW_LINE)
                {
                    var builder = new StringBuilder(StringLiteralConverter.EscapeToRegular(Environment.NewLine));
                    return(new T4InfoCollectorStateSeenFeatureAndText(builder, Interrupter, element));
                }
                else if (element.NodeType == T4TokenNodeTypes.RAW_TEXT)
                {
                    var builder = new StringBuilder(Convert(LastToken));
                    return(new T4InfoCollectorStateSeenFeatureAndText(builder, Interrupter, element));
                }

                var data = T4FailureRawData.FromElement(element, "Unexpected element after feature");
                Interrupter.InterruptAfterProblem(data);
                return(this);
            }
        }
 public T4InfoCollectorStateSeenFeatureAndText(
     [NotNull] StringBuilder builder,
     [NotNull] IT4CodeGenerationInterrupter interrupter,
     [NotNull] IT4TreeNode firstElement
     ) : base(interrupter)
 {
     Builder      = builder;
     FirstElement = firstElement;
 }
예제 #5
0
파일: T4File.cs 프로젝트: mrgfisher/ForTea
        /// <summary>
        /// Removes a child node from the file.
        /// </summary>
        /// <param name="node">The node to remove.</param>
        public void RemoveChild(IT4TreeNode node)
        {
            if (node == null)
            {
                return;
            }

            using (WriteLockCookie.Create(IsPhysical()))
                ModificationUtil.DeleteChild(node);
        }
예제 #6
0
파일: T4File.cs 프로젝트: sscctech/ForTea
        /// <summary>
        /// Removes a child node from the file.
        /// </summary>
        /// <param name="node">The node to remove.</param>
        public void RemoveChild(IT4TreeNode node)
        {
            if (node == null)
            {
                return;
            }

            using (this.CreateWriteLock())
                ModificationUtil.DeleteChild(node);
        }
 protected override void AppendTransformation(string message, IT4TreeNode firstNode)
 {
     if (Result.FeatureStarted)
     {
         Result.AppendFeature(message, firstNode.NotNull());
     }
     else
     {
         Result.AppendTransformation(message);
     }
 }
예제 #8
0
 private static void AddFolding(
     [NotNull] FoldingHighlightingConsumer context,
     [NotNull] string id,
     [NotNull] IT4TreeNode node,
     [NotNull] string replacement
     )
 {
     if (!node.IsValid() || !node.IsVisibleInDocument())
     {
         return;
     }
     context.AddDefaultPriorityFolding(id, node.GetDocumentRange(), replacement);
 }
예제 #9
0
        public override IT4InfoCollectorState GetNextState(IT4TreeNode element)
        {
            switch (element)
            {
            case IT4IncludeDirective: return(new T4InfoCollectorStateInitial(Builder, Interrupter));

            case IT4Directive:
            case IT4StatementBlock: return(this);

            case IT4FeatureBlock:
                return(new T4InfoCollectorStateSeenFeature(Interrupter));

            default:
                return(new T4InfoCollectorStateInitial(Builder, Interrupter));
            }
        }
        public override IT4InfoCollectorState GetNextState(IT4TreeNode element)
        {
            switch (element)
            {
            case IT4FeatureBlock _:
                return(new T4InfoCollectorStateSeenFeature(Interrupter));

            case IT4ExpressionBlock _:
                return(new T4InfoCollectorStateSeenFeatureAndExpressionBlock(Interrupter));

            case IT4Token _: return(this);

            default:
                var data = T4FailureRawData.FromElement(FirstElement, "Unexpected element after feature");
                Interrupter.InterruptAfterProblem(data);
                return(this);
            }
        }
 public abstract void AppendCompilationOffset(T4CSharpCodeGenerationResult destination, IT4TreeNode node);
예제 #12
0
파일: T4File.cs 프로젝트: MrJul/ForTea
        /// <summary>
        /// Removes a child node from the file.
        /// </summary>
        /// <param name="node">The node to remove.</param>
        public void RemoveChild(IT4TreeNode node)
        {
            if (node == null)
                return;

            using (WriteLockCookie.Create(IsPhysical()))
                ModificationUtil.DeleteChild(node);
        }
 public abstract void AppendLineDirective(T4CSharpCodeGenerationResult destination, IT4TreeNode node);
예제 #14
0
 public T4TextDescription([NotNull] string text, [CanBeNull] IT4TreeNode firstNode = null)
 {
     Text      = text;
     FirstNode = firstNode;
 }
예제 #15
0
 // There's no way tokens can code blocks, so there's no need to insert them into code behind
 protected override void AppendTransformation(string message, IT4TreeNode firstNode)
 {
 }
		protected abstract void AppendTransformation([NotNull] string message, [CanBeNull] IT4TreeNode firstNode);
        public override void AppendLineDirective(T4CSharpCodeGenerationResult destination, IT4TreeNode node)
        {
            var sourceFile = node.FindLogicalPsiSourceFile();
            int offset     = T4UnsafeManualRangeTranslationUtil.GetDocumentStartOffset(node).Offset;
            int line       = (int)sourceFile.Document.GetCoordsByOffset(offset).Line;

            destination.AppendLine($"#line {line + 1} \"{sourceFile.GetLocation()}\"");
        }
 private T4ImportWithLineDescription([NotNull] IT4TreeNode source) : base(source)
 {
 }
 public override void AppendLineDirective(T4CSharpCodeGenerationResult destination, IT4TreeNode node)
 {
     // Line directives in code-behind affect nothing anyway.
     // The mapping between the code and the document
     // is handled by document range translators.
 }
 public override void AppendCompilationOffset(T4CSharpCodeGenerationResult destination, IT4TreeNode node)
 {
 }
예제 #21
0
 private T4ImportDescription([NotNull] IT4TreeNode source) => Source = source;
 public override void AppendCompilationOffset(T4CSharpCodeGenerationResult destination, IT4TreeNode node)
 {
     // In preprocessed file, behave like VS
 }
        public override void AppendCompilationOffset(T4CSharpCodeGenerationResult destination, IT4TreeNode node)
        {
            int documentOffset = T4UnsafeManualRangeTranslationUtil.GetDocumentStartOffset(node).Offset;
            var lineOffset     = node
                                 .FindLogicalPsiSourceFile()
                                 .Document
                                 .GetCoordsByOffset(documentOffset)
                                 .Column;

            for (var i = Int32 <DocColumn> .O; i < lineOffset; i++)
            {
                destination.Append(" ");
            }
        }
예제 #24
0
파일: T4File.cs 프로젝트: vilinski/ForTea
        /// <summary>
        /// Removes a child node from the file.
        /// </summary>
        /// <param name="node">The node to remove.</param>
        public void RemoveChild(IT4TreeNode node)
        {
            if (node == null)
                return;

            using (this.CreateWriteLock())
                ModificationUtil.DeleteChild(node);
        }
예제 #25
0
 protected T4ImportDescription([NotNull] IT4TreeNode source) => Source = source;