Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
 /// </summary>
 /// <param name='errorType'>
 /// The error type.
 /// </param>
 /// <param name='message'>
 /// The description of the error.
 /// </param>
 public Error(ErrorType errorType, string id, string message)
 {
     this.errorType = errorType;
     this.Id        = id;
     this.message   = message;
     this.region    = DocumentRegion.Empty;
 }
 public override void DisableOnce(MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
 {
     document.Editor.Insert(
         document.Editor.LocationToOffset(loc.BeginLine, 1),
         document.Editor.IndentationTracker.GetIndentationString(loc.Begin) + "// ReSharper disable once " + attr.ResharperDisableKeyword + document.Editor.EolMarker
         );
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
 /// </summary>
 /// <param name='errorType'>
 /// The error type.
 /// </param>
 /// <param name='message'>
 /// The description of the error.
 /// </param>
 /// <param name='region'>
 /// The region of the error.
 /// </param>
 public Error(ErrorType errorType, string id, string message, DocumentRegion region)
 {
     this.errorType = errorType;
     this.Id        = id;
     this.message   = message;
     this.region    = region;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ICSharpCode.NRefactory.TypeSystem.Error"/> class.
 /// </summary>
 /// <param name='errorType'>
 /// The error type.
 /// </param>
 /// <param name='message'>
 /// The description of the error.
 /// </param>
 /// <param name='location'>
 /// The location of the error.
 /// </param>
 public Error(ErrorType errorType, string id, string message, DocumentLocation location)
 {
     this.errorType = errorType;
     this.Id        = id;
     this.message   = message;
     this.region    = new DocumentRegion(location, location);
 }
Пример #5
0
        public ISymbol GetLanguageItem(MonoDevelop.Ide.Gui.Document document, int offset, out DocumentRegion expressionRegion)
        {
            expressionRegion = DocumentRegion.Empty;
            var parsedDocument = document.DocumentContext.AnalysisDocument;

            if (parsedDocument == null)
            {
                return(null);
            }
            var model = parsedDocument.GetSemanticModelAsync().WaitAndGetResult();

            if (model == null)
            {
                return(null);
            }
            foreach (var symbol in model.LookupSymbols(offset))
            {
                var firstDeclaration = symbol.DeclaringSyntaxReferences.FirstOrDefault();
                if (firstDeclaration != null)
                {
                    expressionRegion = new DocumentRegion(
                        document.Editor.OffsetToLocation(firstDeclaration.Span.Start),
                        document.Editor.OffsetToLocation(firstDeclaration.Span.End));
                }
                return(symbol);
            }
            return(null);
        }
Пример #6
0
 void IXmlParserContext.LogWarning(string message, DocumentRegion region)
 {
     if (errors != null || ErrorLogged != null)
     {
         InternalLogError(new Error(ErrorType.Warning, message, region));
     }
 }
Пример #7
0
 static bool IsInsideMember(this DocumentRegion region, IUnresolvedTypeDefinition cl)
 {
     if (region.IsEmpty || cl == null || !cl.BodyRegion.IsInside(region.Begin.Line, region.Begin.Column))
     {
         return(false);
     }
     foreach (var member in cl.Members)
     {
         if (member.BodyRegion.IsEmpty)
         {
             continue;
         }
         if (member.BodyRegion.IsInside(region.Begin.Line, region.Begin.Column) && member.BodyRegion.IsInside(region.End.Line, region.End.Column))
         {
             return(true);
         }
     }
     foreach (var inner in cl.NestedTypes)
     {
         if (region.IsInsideMember(inner))
         {
             return(true);
         }
     }
     return(false);
 }
        public void Run(XElement element, MSBuildLanguageElement resolvedElement, string filename, ITextSource textDocument, MSBuildDocument document, int offset = 0, int length = 0)
        {
            Filename  = filename;
            Document  = document;
            Extension = System.IO.Path.GetExtension(filename);

            //HACK: we should really use the ITextSource directly, but since the XML parser positions are
            //currently line/col, we need a TextDocument to convert to offsets
            TextDocument = textDocument as IReadonlyTextDocument
                           ?? TextEditorFactory.CreateNewReadonlyDocument(
                textDocument, filename, MSBuildTextEditorExtension.MSBuildMimeType
                );

            range = new DocumentRegion(
                TextDocument.OffsetToLocation(offset),
                length > 0
                                        ? TextDocument.OffsetToLocation(length + offset)
                                        : new DocumentLocation(int.MaxValue, int.MaxValue));

            if (resolvedElement != null)
            {
                VisitResolvedElement(element, resolvedElement);
            }
            else if (element != null)
            {
                ResolveAndVisit(element, null);
            }
        }
Пример #9
0
		protected string GetBufferText (DocumentRegion region)
		{
			int start = Editor.LocationToOffset (region.BeginLine, region.BeginColumn);
			int end = Editor.LocationToOffset (region.EndLine, region.EndColumn);
			if (end > start && start >= 0)
				return Editor.GetTextBetween (start, end);
			return null;
		}
Пример #10
0
		protected void EditorSelect (DocumentRegion region)
		{
			int s = Editor.LocationToOffset (region.BeginLine, region.BeginColumn);
			int e = Editor.LocationToOffset (region.EndLine, region.EndColumn);
			if (s > -1 && e > s) {
				Editor.SetSelection (s, e);
				Editor.ScrollTo (s);
			}
		}
Пример #11
0
		public void SelectNode (XNode n)
		{
			var region = n.Region;
			
			var el = n as XElement;
			if (el != null && el.IsClosed && el.ClosingTag.Region.End > region.End) {
				region = new DocumentRegion (region.Begin, el.ClosingTag.Region.End);
			}
			EditorSelect (region);
		}		
Пример #12
0
		public RazorOutlineNode (XElement el)
		{
			Name = el.Name.FullName;
			string id = el.GetId ();
			if (!string.IsNullOrEmpty (id))
				Name = "<" + Name + "#" + id + ">";
			else
				Name = "<" + Name + ">";

			Location = el.Region;
		}
		public static ISymbol GetLanguageItem (this Document document, int offset, out DocumentRegion expressionRegion)
		{
			if (document == null)
				throw new System.ArgumentNullException ("document");

			var textEditorResolver = TextEditorResolverService.GetProvider (document.Editor.MimeType);
			if (textEditorResolver != null) {
				return textEditorResolver.GetLanguageItem (document, offset, out expressionRegion);
			}
			expressionRegion = DocumentRegion.Empty;
			return null;
		}
Пример #14
0
        public static ISymbol GetLanguageItem(this Document document, int offset, out DocumentRegion expressionRegion)
        {
            if (document == null)
            {
                throw new System.ArgumentNullException("document");
            }

            var textEditorResolver = TextEditorResolverService.GetProvider(document.Editor.MimeType);

            if (textEditorResolver != null)
            {
                return(textEditorResolver.GetLanguageItem(document, offset, out expressionRegion));
            }
            expressionRegion = DocumentRegion.Empty;
            return(null);
        }
Пример #15
0
        public RazorOutlineNode(XElement el)
        {
            Name = el.Name.FullName;
            string id = el.GetId();

            if (!string.IsNullOrEmpty(id))
            {
                Name = "<" + Name + "#" + id + ">";
            }
            else
            {
                Name = "<" + Name + ">";
            }

            Location = el.Region;
        }
        private void AddContentPattern_Click(object sender, RoutedEventArgs e)
        {
            var cp = (ContentPattern) contentPaternsLst.SelectedValue;

            var region = new DocumentRegion
                             {
                                 RegionContent = cp.Id
                             };

            region.ContentPattern = cp;

            if (RegionAdded != null)
            {
                RegionAdded(this, new RegionAddedEventArgs(region));
            }

            this.Close();
        }
Пример #17
0
        new void SelectNode(XNode n)
        {
            var region = n.Region;

            XElement el = n as XElement;

            if (el != null && el.IsClosed && el.ClosingTag.Region.End > region.End)
            {
                region = new DocumentRegion(region.Begin, el.ClosingTag.Region.End);
            }

            int s = Editor.LocationToOffset(region.BeginLine, region.BeginColumn);
            int e = Editor.LocationToOffset(region.EndLine, region.EndColumn);

            if (e > s && s > -1)
            {
                Editor.SetSelection(s, e);
            }
        }
		public ISymbol GetLanguageItem (MonoDevelop.Ide.Gui.Document document, int offset, out DocumentRegion expressionRegion)
		{
			expressionRegion = DocumentRegion.Empty;
			var parsedDocument = document.ParsedDocument;
			if (parsedDocument == null)
				return null;
			var model = parsedDocument.GetAst<SemanticModel> ();
			if (model == null)
				return null;
			foreach (var symbol in model.LookupSymbols (offset)) {
				var firstDeclaration = symbol.DeclaringSyntaxReferences.FirstOrDefault ();
				if (firstDeclaration != null) {
					expressionRegion = new DocumentRegion (
						document.Editor.OffsetToLocation (firstDeclaration.Span.Start),
						document.Editor.OffsetToLocation (firstDeclaration.Span.End));
				}
				return symbol;
			}
			return null;
		}
Пример #19
0
        private void Ok_Clicked(object sender, RoutedEventArgs e)
        {
            try
            {

                double d = 0.0;

                var region = new DocumentRegion
                                 {
                                     Uid = this.txtBoxId.Text,
                                     RegionContent = txtBoxId.Text
                                 };

                var proxy = new DocumentEditorServiceSoapClient();

                var cp = proxy.CreateContentPattern();

                cp.Id = txtBoxId.Text;
                cp.X = double.Parse(txtBoxPosX.Text);
                cp.Y = double.Parse(txtBoxosY.Text);
                cp.Width = double.Parse(txtBoxWidth.Text);
                cp.Height = double.Parse(txtBoxHeight.Text);

                proxy.SaveContentPattern(cp);

                region.ContentPattern = cp;

                if (RegionCreated != null)
                {
                    RegionCreated(this, new RegionAddedEventArgs(region));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.Close();
        }
Пример #20
0
        internal string GetSdkPath(IRuntimeInformation runtime, string sdk, DocumentRegion loc)
        {
            if (!SdkReference.TryParse(sdk, out SdkReference sdkRef))
            {
                string parseErrorMsg = $"Could not parse SDK '{sdk}'";
                LoggingService.LogError(parseErrorMsg);
                if (IsToplevel)
                {
                    AddError(parseErrorMsg);
                }
                return(null);
            }

            //FIXME: filename should be the root project, not this file
            try {
                var sdkPath = runtime.GetSdkPath(sdkRef, Filename, null);
                if (sdk != null)
                {
                    return(sdkPath);
                }
            } catch (Exception ex) {
                LoggingService.LogError("Error in SDK resolver", ex);
                return(null);
            }

            string notFoundMsg = $"Did not find SDK '{sdk}'";

            LoggingService.LogError(notFoundMsg);
            if (IsToplevel)
            {
                AddError(notFoundMsg);
            }
            return(null);

            void AddError(string msg) => Errors.Add(new Error(ErrorType.Error, msg, loc));
        }
Пример #21
0
		public virtual void DisableWithPragma (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
		{
			throw new NotSupportedException ();
		}
		public FoldingRegion (DocumentRegion region, FoldType type) : this (null, region, type)
		{
		}
		public FoldingRegion (string name, DocumentRegion region, FoldType type, bool isFoldedByDefault) : this (name, region)
		{
			this.Type = type;
			this.IsFoldedByDefault = isFoldedByDefault;
		}
Пример #24
0
		public virtual void SuppressWithAttribute (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
		{
			throw new NotSupportedException ();
		}
Пример #25
0
		protected string GetBufferText (DocumentRegion region)
		{
			int start = Editor.LocationToOffset (region.BeginLine, region.BeginColumn);
			int end = Editor.LocationToOffset (region.EndLine, region.EndColumn);
			if (end > start && start >= 0)
				return Editor.GetTextBetween (start, end);
			return null;
		}
		public WebFormsHtmlEncodedExpression (DocumentRegion region) : base (region)
		{
		}
Пример #27
0
 public RegionAddedEventArgs(DocumentRegion region)
 {
     this.Region = region;
 }
		public WebFormsResourceExpression (DocumentRegion region) : base (region)
		{
		}
Пример #29
0
 public FoldingRegion(string name, DocumentRegion region, FoldType type, bool isFoldedByDefault) : this(name, region)
 {
     this.Type = type;
     this.IsFoldedByDefault = isFoldedByDefault;
 }
Пример #30
0
 public FoldingRegion(string name, DocumentRegion region)
 {
     this.Name   = name ?? defaultName;
     this.Region = region;
 }
        public override void SuppressWithAttribute(MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
        {
            var member = document.ParsedDocument.GetMember(loc.End);

            document.Editor.Insert(
                document.Editor.LocationToOffset(member.Region.BeginLine, 1),
                document.Editor.IndentationTracker.GetIndentationString(loc.Begin) + string.Format("[SuppressMessage(\"{0}\", \"{1}\")]" + document.Editor.EolMarker, attr.SuppressMessageCategory, attr.SuppressMessageCheckId)
                );
        }
Пример #32
0
 public WebFormsServerComment(DocumentRegion region) : base(region)
 {
 }
 public override void DisableAndRestore(MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
 {
     using (document.Editor.OpenUndoGroup()) {
         document.Editor.Insert(
             document.Editor.LocationToOffset(loc.EndLine + 1, 1),
             document.Editor.IndentationTracker.GetIndentationString(loc.End) + "// ReSharper restore " + attr.ResharperDisableKeyword + document.Editor.EolMarker
             );
         document.Editor.Insert(
             document.Editor.LocationToOffset(loc.BeginLine, 1),
             document.Editor.IndentationTracker.GetIndentationString(loc.Begin) + "// ReSharper disable " + attr.ResharperDisableKeyword + document.Editor.EolMarker
             );
     }
 }
Пример #34
0
 public static bool ContainsOuter(this DocumentRegion region, DocumentLocation location)
 {
     return(region.Begin <= location && location <= region.End);
 }
 public override void DisableWithPragma(MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
 {
     using (document.Editor.OpenUndoGroup()) {
         document.Editor.Insert(
             document.Editor.LocationToOffset(loc.EndLine + 1, 1),
             document.Editor.IndentationTracker.GetIndentationString(loc.End) + "#pragma warning restore " + attr.PragmaWarning + document.Editor.EolMarker
             );
         document.Editor.Insert(
             document.Editor.LocationToOffset(loc.BeginLine, 1),
             document.Editor.IndentationTracker.GetIndentationString(loc.Begin) + "#pragma warning disable " + attr.PragmaWarning + document.Editor.EolMarker
             );
     }
 }
Пример #36
0
		public RazorComment (DocumentRegion region) : base (region)
		{
		}
Пример #37
0
 public FoldingRegion(DocumentRegion region) : this(null, region)
 {
 }
Пример #38
0
		public void Remove (DocumentRegion region)
		{
			Remove (region.GetSegment (document));
		}
Пример #39
0
 public FoldingRegion(string name, DocumentRegion region, FoldType type) : this(name, region)
 {
     this.Type = type;
 }
Пример #40
0
		public string GetTextAt (DocumentRegion region)
		{
			return GetTextAt (region.GetSegment (this));
		}
Пример #41
0
 public FoldingRegion(DocumentRegion region, FoldType type) : this(null, region, type)
 {
 }
		public override void DisableOnce (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
		{
			document.Editor.Insert (
				document.Editor.LocationToOffset (loc.BeginLine, 1), 
				document.Editor.IndentationTracker.GetIndentationString (loc.Begin) + "// " + analysisDisableTag + "disable once " + attr.AnalysisDisableKeyword + document.Editor.EolMarker
			); 
		}
		public override void DisableWithPragma (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
		{
			using (document.Editor.OpenUndoGroup ()) {
				document.Editor.Insert (
					document.Editor.LocationToOffset (loc.EndLine + 1, 1),
					document.Editor.IndentationTracker.GetIndentationString (loc.End) + "#pragma warning restore " + attr.PragmaWarning + document.Editor.EolMarker
				); 
				document.Editor.Insert (
					document.Editor.LocationToOffset (loc.BeginLine, 1),
					document.Editor.IndentationTracker.GetIndentationString (loc.Begin) + "#pragma warning disable " + attr.PragmaWarning + document.Editor.EolMarker
				); 
			}
		}
		new void SelectNode (XNode n)
		{
			var region = n.Region;
			
			XElement el = n as XElement;
			if (el != null && el.IsClosed && el.ClosingTag.Region.End > region.End) {
				region = new DocumentRegion (region.Begin, el.ClosingTag.Region.End);
			}
			
			int s = Editor.LocationToOffset (region.BeginLine, region.BeginColumn );
			int e = Editor.LocationToOffset (region.EndLine, region.EndColumn);
			if (e > s && s > -1)
				Editor.SetSelection (s, e);
		}
Пример #45
0
 public XProcessingInstruction(DocumentRegion region) : base(region)
 {
 }
		public WebFormsRenderBlock (DocumentRegion region) : base (region)
		{
		}
Пример #47
0
		public string GetTextAt (DocumentRegion region)
		{
			return document.GetTextAt (region);
		}
Пример #48
0
		protected XNode (DocumentRegion region) : base (region) {}
		public XProcessingInstruction (DocumentRegion region) : base (region) {}
Пример #50
0
 void AddError(ErrorType errorType, string message, DocumentRegion region) => Document.Errors.Add(new Error(errorType, message, region));
Пример #51
0
 public NavigationAnnotation(string path, DocumentRegion region)
 {
     Path   = path;
     Region = region;
 }
Пример #52
0
 void AddError(string message, DocumentRegion region) => AddError(ErrorType.Error, message, region);
		public override void DisableAndRestore (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
		{
			using (document.Editor.OpenUndoGroup ()) {
				document.Editor.Insert (
					document.Editor.LocationToOffset (loc.EndLine + 1, 1),
					document.Editor.IndentationTracker.GetIndentationString (loc.End) + "// " + analysisDisableTag + "restore " + attr.AnalysisDisableKeyword + document.Editor.EolMarker
				); 
				document.Editor.Insert (
					document.Editor.LocationToOffset (loc.BeginLine, 1),
					document.Editor.IndentationTracker.GetIndentationString (loc.Begin) + "// " + analysisDisableTag + "disable " + attr.AnalysisDisableKeyword + document.Editor.EolMarker
				); 
			}
		}
Пример #54
0
 void AddWarning(string message, DocumentRegion region) => AddError(ErrorType.Warning, message, region);
		public override void SuppressWithAttribute (MonoDevelop.Ide.Gui.Document document, DocumentRegion loc)
		{
			var member = document.ParsedDocument.GetMember (loc.End);
			document.Editor.Insert (
				document.Editor.LocationToOffset (member.Region.BeginLine, 1),
				document.Editor.IndentationTracker.GetIndentationString (loc.Begin) + string.Format ("[SuppressMessage(\"{0}\", \"{1}\")]" + document.Editor.EolMarker, attr.SuppressMessageCategory, attr.SuppressMessageCheckId)
			); 
		}
		public FoldingRegion (DocumentRegion region) : this (null, region)
		{
		}
Пример #57
0
		public void SelectNode (XNode n)
		{
			var region = n.Region;
			
			var el = n as XElement;
			if (el != null && el.IsClosed && el.ClosingTag.Region.End > region.End) {
				region = new DocumentRegion (region.Begin, el.ClosingTag.Region.End);
			}
			EditorSelect (region);
		}		
		public FoldingRegion (string name, DocumentRegion region)
		{
			this.Name = name ?? defaultName;
			this.Region = region;
		}
Пример #59
0
		protected void EditorSelect (DocumentRegion region)
		{
			int s = Editor.LocationToOffset (region.BeginLine, region.BeginColumn);
			int e = Editor.LocationToOffset (region.EndLine, region.EndColumn);
			if (s > -1 && e > s) {
				Editor.SetSelection (s, e);
				Editor.ScrollTo (s);
			}
		}
		public FoldingRegion (string name, DocumentRegion region, FoldType type) : this (name, region)
		{
			this.Type = type;
		}