public MDRefactoringScript (MDRefactoringContext context, Document document, CSharpFormattingOptions formattingOptions) : base(document.Editor.Document, formattingOptions, document.Editor.CreateNRefactoryTextEditorOptions ()) { this.context = context; this.document = document; undoGroup = this.document.Editor.OpenUndoGroup (); this.startVersion = this.document.Editor.Version; }
public CSharpIndentEngine(IDocument document, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions) { this.document = document; this.options = formattingOptions; this.textEditorOptions = textEditorOptions; this.indent = new Indent(textEditorOptions); this.thisLineindent = new Indent(textEditorOptions); }
public CSharpOutputVisitor (TextWriter textWriter, CSharpFormattingOptions formattingPolicy) { if (textWriter == null) { throw new ArgumentNullException ("textWriter"); } if (formattingPolicy == null) { throw new ArgumentNullException ("formattingPolicy"); } this.formatter = new TextWriterOutputFormatter (textWriter); this.policy = formattingPolicy; }
public CSharpOutputVisitor (IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { if (formatter == null) { throw new ArgumentNullException ("formatter"); } if (formattingPolicy == null) { throw new ArgumentNullException ("formattingPolicy"); } this.formatter = formatter; this.policy = formattingPolicy; }
CSharpIndentEngine (CSharpIndentEngine prototype) { this.document = prototype.document; this.options = prototype.options; this.textEditorOptions = prototype.textEditorOptions; this.indent = prototype.indent.Clone(); this.thisLineindent = prototype.thisLineindent.Clone(); this.offset = prototype.offset; this.inside = prototype.inside; this.IsLineStart = prototype.IsLineStart; this.pc = prototype.pc; this.parenStack = new Stack<TextLocation>(prototype.parenStack.Reverse ()); this.currentBody = prototype.currentBody; this.nextBody = prototype.nextBody; this.addContinuation = prototype.addContinuation; this.line = prototype.line; this.col = prototype.col; this.popNextParenBlock = prototype.popNextParenBlock; }
public override string GetText (CSharpFormattingOptions formattingOptions = null) { return GetModifierName (Modifier); }
public AstAmbience(ICSharpCode.NRefactory.PlayScript.CSharpFormattingOptions options) { this.options = options; }
public AstAmbience (ICSharpCode.NRefactory.PlayScript.CSharpFormattingOptions options) { this.options = options; }
public CSharpIndentEngine(IDocument document, TextEditorOptions textEditorOptions, CSharpFormattingOptions formattingOptions) { this.document = document; this.options = formattingOptions; this.textEditorOptions = textEditorOptions; this.indent = new Indent(textEditorOptions); this.indentDelta = new Indent(textEditorOptions); this.thisLineindent = new Indent(textEditorOptions); }
public AstFormattingVisitor(CSharpFormattingOptions policy, IDocument document, TextEditorOptions options = null) { if (policy == null) { throw new ArgumentNullException("policy"); } if (document == null) { throw new ArgumentNullException("document"); } this.policy = policy; this.document = document; this.options = options ?? TextEditorOptions.Default; curIndent = new Indent(this.options); }
public override string ToString(CSharpFormattingOptions formattingOptions) { return(TokenRole.Tokens [(int)(this.flags >> AstNodeFlagsUsedBits)]); }
public override string ToString(CSharpFormattingOptions formattingOptions) { return(GetModifierName(Modifier)); }
public void ConvertEntity(IEntity entity, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { if (entity == null) { throw new ArgumentNullException("entity"); } if (formatter == null) { throw new ArgumentNullException("formatter"); } if (formattingPolicy == null) { throw new ArgumentNullException("options"); } TypeSystemAstBuilder astBuilder = CreateAstBuilder(); EntityDeclaration node = astBuilder.ConvertEntity(entity); PrintModifiers(node.Modifiers, formatter); if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyword) == ConversionFlags.ShowDefinitionKeyword) { if (node is TypeDeclaration) { switch (((TypeDeclaration)node).ClassType) { case ClassType.Class: formatter.WriteKeyword("class"); break; case ClassType.Struct: formatter.WriteKeyword("struct"); break; case ClassType.Interface: formatter.WriteKeyword("interface"); break; case ClassType.Enum: formatter.WriteKeyword("enum"); break; default: throw new Exception("Invalid value for ClassType"); } formatter.Space(); } else if (node is DelegateDeclaration) { formatter.WriteKeyword("delegate"); formatter.Space(); } else if (node is EventDeclaration) { formatter.WriteKeyword("event"); formatter.Space(); } } if ((ConversionFlags & ConversionFlags.ShowReturnType) == ConversionFlags.ShowReturnType) { var rt = node.GetChildByRole(Roles.Type); if (!rt.IsNull) { rt.AcceptVisitor(new CSharpOutputVisitor(formatter, formattingPolicy)); formatter.Space(); } } if (entity is ITypeDefinition) { WriteTypeDeclarationName((ITypeDefinition)entity, formatter, formattingPolicy); } else { WriteMemberDeclarationName((IMember)entity, formatter, formattingPolicy); } if ((ConversionFlags & ConversionFlags.ShowParameterList) == ConversionFlags.ShowParameterList && HasParameters(entity)) { formatter.WriteToken(entity.EntityType == EntityType.Indexer ? "[" : "("); bool first = true; foreach (var param in node.GetChildrenByRole(Roles.Parameter)) { if (first) { first = false; } else { formatter.WriteToken(","); formatter.Space(); } param.AcceptVisitor(new CSharpOutputVisitor(formatter, formattingPolicy)); } formatter.WriteToken(entity.EntityType == EntityType.Indexer ? "]" : ")"); } if ((ConversionFlags & ConversionFlags.ShowBody) == ConversionFlags.ShowBody && !(node is TypeDeclaration)) { IProperty property = entity as IProperty; if (property != null) { formatter.Space(); formatter.WriteToken("{"); formatter.Space(); if (property.CanGet) { formatter.WriteKeyword("get"); formatter.WriteToken(";"); formatter.Space(); } if (property.CanSet) { formatter.WriteKeyword("set"); formatter.WriteToken(";"); formatter.Space(); } formatter.WriteToken("}"); } else { formatter.WriteToken(";"); } } }
void WriteMemberDeclarationName(IMember member, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); if ((ConversionFlags & ConversionFlags.ShowDeclaringType) == ConversionFlags.ShowDeclaringType) { ConvertType(member.DeclaringType, formatter, formattingPolicy); formatter.WriteToken("."); } switch (member.EntityType) { case EntityType.Indexer: formatter.WriteKeyword("this"); break; case EntityType.Constructor: formatter.WriteIdentifier(member.DeclaringType.Name); break; case EntityType.Destructor: formatter.WriteToken("~"); formatter.WriteIdentifier(member.DeclaringType.Name); break; case EntityType.Operator: switch (member.Name) { case "op_Implicit": formatter.WriteKeyword("implicit"); formatter.Space(); formatter.WriteKeyword("operator"); formatter.Space(); ConvertType(member.ReturnType, formatter, formattingPolicy); break; case "op_Explicit": formatter.WriteKeyword("explicit"); formatter.Space(); formatter.WriteKeyword("operator"); formatter.Space(); ConvertType(member.ReturnType, formatter, formattingPolicy); break; default: formatter.WriteKeyword("operator"); formatter.Space(); var operatorType = OperatorDeclaration.GetOperatorType(member.Name); if (operatorType.HasValue) { formatter.WriteToken(OperatorDeclaration.GetToken(operatorType.Value)); } else { formatter.WriteIdentifier(member.Name); } break; } break; default: formatter.WriteIdentifier(member.Name); break; } if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList && member.EntityType == EntityType.Method) { var outputVisitor = new CSharpOutputVisitor(formatter, formattingPolicy); outputVisitor.WriteTypeParameters(astBuilder.ConvertEntity(member).GetChildrenByRole(Roles.TypeParameter)); } }
void WriteTypeDeclarationName(ITypeDefinition typeDef, IOutputFormatter formatter, CSharpFormattingOptions formattingPolicy) { TypeSystemAstBuilder astBuilder = CreateAstBuilder(); if (typeDef.DeclaringTypeDefinition != null) { WriteTypeDeclarationName(typeDef.DeclaringTypeDefinition, formatter, formattingPolicy); formatter.WriteToken("."); } else if ((ConversionFlags & ConversionFlags.UseFullyQualifiedTypeNames) == ConversionFlags.UseFullyQualifiedTypeNames) { formatter.WriteIdentifier(typeDef.Namespace); formatter.WriteToken("."); } formatter.WriteIdentifier(typeDef.Name); if ((ConversionFlags & ConversionFlags.ShowTypeParameterList) == ConversionFlags.ShowTypeParameterList) { var outputVisitor = new CSharpOutputVisitor(formatter, formattingPolicy); outputVisitor.WriteTypeParameters(astBuilder.ConvertEntity(typeDef).GetChildrenByRole(Roles.TypeParameter)); } }