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); } }
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); } }
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; }
/// <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); }
/// <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); } }
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); }
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);
/// <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);
public T4TextDescription([NotNull] string text, [CanBeNull] IT4TreeNode firstNode = null) { Text = text; FirstNode = firstNode; }
// 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) { }
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(" "); } }
/// <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 T4ImportDescription([NotNull] IT4TreeNode source) => Source = source;