Ejemplo n.º 1
0
 public void Reset()
 {
     offset         = 0;
     line           = column = 1;
     thisLineIndent = new Indent(ctx.GetOptionSet());
     nextLineIndent = new Indent(ctx.GetOptionSet());
     currentIndent  = new StringBuilder();
     // previousNewline = '\0';
     previousChar = '\0';
     isLineStart  = true;
     isInString   = false;
 }
        public static async Task <OptionSet> GetOptionsAsync(this DocumentContext ctx, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (ctx == null)
            {
                throw new ArgumentNullException(nameof(ctx));
            }
            try {
                if (ctx.AnalysisDocument != null)
                {
                    var result = await ctx.AnalysisDocument.GetOptionsAsync().ConfigureAwait(false);

                    if (result != null)
                    {
                        return(result);
                    }
                }
                var policies = ctx.Project?.Policies;
                if (policies == null)
                {
                    var defaultPolicy     = PolicyService.GetDefaultPolicy <CSharpFormattingPolicy> (CSharpFormatter.MimeType);
                    var defaultTextPolicy = PolicyService.GetDefaultPolicy <TextStylePolicy> (CSharpFormatter.MimeType);
                    return(defaultPolicy.CreateOptions(defaultTextPolicy));
                }
                var policy     = policies.Get <CSharpFormattingPolicy> (CSharpFormatter.MimeType);
                var textpolicy = policies.Get <TextStylePolicy> (CSharpFormatter.MimeType);
                return(policy.CreateOptions(textpolicy));
            } catch (Exception e) {
                LoggingService.LogError("Error while getting document options", e);
                return(ctx.GetOptionSet());
            }
        }
Ejemplo n.º 3
0
		public SignatureMarkupCreator (DocumentContext ctx, int offset)
		{
			this.offset = offset;
			this.colorStyle = SyntaxModeService.GetColorStyle (Ide.IdeApp.Preferences.ColorScheme);
			if (!this.colorStyle.FitsIdeSkin (Ide.IdeApp.Preferences.UserInterfaceSkin))
				this.colorStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceSkin);
			this.ctx = ctx;
			if (ctx != null) {
				this.options = ctx.GetOptionSet ();
			} else {
				this.options = MonoDevelop.Ide.TypeSystem.TypeSystemService.Workspace.Options;
			}
		}
		public SignatureMarkupCreator (DocumentContext ctx, int offset)
		{
			this.offset = offset;
			this.colorStyle = SyntaxModeService.GetColorStyle (MonoDevelop.Ide.IdeApp.Preferences.ColorScheme);
			this.ctx = ctx;
			if (ctx != null) {
				if (ctx.ParsedDocument == null || ctx.AnalysisDocument == null) {
					LoggingService.LogError ("Signature markup creator created with invalid context." + Environment.NewLine + Environment.StackTrace);
				}
				this.options = ctx.GetOptionSet ();
			} else {
				this.options = MonoDevelop.Ide.TypeSystem.TypeSystemService.Workspace.Options;
			}
		}
Ejemplo n.º 5
0
		public SignatureMarkupCreator (DocumentContext ctx, int offset)
		{
			this.offset = offset;
			try {
				this.colorStyle = SyntaxModeService.GetColorStyle (Ide.IdeApp.Preferences.ColorScheme);
				if (!this.colorStyle.FitsIdeTheme (Ide.IdeApp.Preferences.UserInterfaceTheme))
					this.colorStyle = SyntaxModeService.GetDefaultColorStyle (Ide.IdeApp.Preferences.UserInterfaceTheme);
			} catch (Exception e) {
				LoggingService.LogError ("Error while getting the color style : " + Ide.IdeApp.Preferences.ColorScheme + " in ide theme : " + Ide.IdeApp.Preferences.UserInterfaceTheme, e);
				this.colorStyle = SyntaxModeService.DefaultColorStyle;
			}
			this.ctx = ctx;
			if (ctx != null) {
				this.options = ctx.GetOptionSet ();
			} else {
				this.options = MonoDevelop.Ide.TypeSystem.TypeSystemService.Workspace.Options;
			}
		}
 public override Microsoft.CodeAnalysis.Options.OptionSet GetOptionSet()
 {
     return(originalContext.GetOptionSet());
 }
Ejemplo n.º 7
0
        public void Push(char ch)
        {
            var isNewLine = NewLine.IsNewLine(ch);

            if (!isNewLine)
            {
                if (ch == '"')
                {
                    isInString = !IsInsideString;
                    if (isInString)
                    {
                        savedStringIndent = nextLineIndent;
                        nextLineIndent    = new Indent(ctx.GetOptionSet());
                    }
                    else
                    {
                        nextLineIndent = savedStringIndent;
                    }
                }
                if (ch == '{' || ch == '[')
                {
                    nextLineIndent.Push(IndentType.Block);
                }
                else if (ch == '}' || ch == ']')
                {
                    if (thisLineIndent.Count > 0)
                    {
                        thisLineIndent.Pop();
                    }
                    if (nextLineIndent.Count > 0)
                    {
                        nextLineIndent.Pop();
                    }
                }
            }
            else
            {
                if (ch == NewLine.LF && previousChar == NewLine.CR)
                {
                    offset++;
                    previousChar = ch;
                    return;
                }
            }

            offset++;
            if (!isNewLine)
            {
                // previousNewline = '\0';

                isLineStart &= char.IsWhiteSpace(ch);

                if (isLineStart)
                {
                    currentIndent.Append(ch);
                }

                if (ch == '\t')
                {
                    var nextTabStop = (column - 1 + editor.Options.IndentationSize) / editor.Options.IndentationSize;
                    column = 1 + nextTabStop * editor.Options.IndentationSize;
                }
                else
                {
                    column++;
                }
            }
            else
            {
                // previousNewline = ch;
                currentIndent.Length = 0;
                isLineStart          = true;
                column = 1;
                line++;
                thisLineIndent = nextLineIndent.Clone();
            }
            previousChar = ch;
        }