/// <summary> /// /// </summary> /// <returns></returns> protected XmlObjectLocationCollection RetrieveSymbolLocationFromXsd() { XmlObjectLocationCollection xmlObjectLocationCollection = new XmlObjectLocationCollection(); XmlSchemaCompletionCollection schemas = this.AutoFindSchemaCollection(); // Find schema object for selected xml element or attribute. XmlSchemaCompletion currentSchemaCompletion = schemas.FirstOrDefault(); if (currentSchemaCompletion == null) { return(null); } XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, currentSchemaCompletion); XmlObjectLocation schemaObjectLocation = schemaDefinition.GetSelectedSchemaObjectLocation(this.Text.Content, this.Position.Offset); if (schemaObjectLocation != null) { xmlObjectLocationCollection.Add(schemaObjectLocation); } return(xmlObjectLocationCollection); }
/// <summary> /// /// </summary> /// <param name="textDocumentPosition"></param> /// <param name="requestContext"></param> /// <returns></returns> internal async Task HandleDefinitionRequest(TextDocumentPosition textDocumentPosition, RequestContext <Location[]> requestContext) { List <Location> locations = new List <Location>(); Text text = this.CreateXmlTextFromTextDocumentUri(textDocumentPosition.TextDocument.Uri); TextPosition textPosition = PositionUtils.CreateTextPosition(text.Content, textDocumentPosition.Position); XmlSymbolDefinitionProvider xmlSymbolDefinition = this.CreateSymbolDefinitionProvider(text, textPosition); XmlObjectLocationCollection xmlObjectLocationCollection = xmlSymbolDefinition.RetrieveSymbolLocation(); if (xmlObjectLocationCollection != null) { foreach (XmlObjectLocation xmlObjectLocation in xmlObjectLocationCollection) { locations.Add(new Location() { Range = new Range() { Start = new Position() { Line = xmlObjectLocation.LineNumber - 1, Character = xmlObjectLocation.LinePosition - 1 }, End = new Position() { Line = xmlObjectLocation.LineNumber - 1, Character = xmlObjectLocation.LinePosition - 1 } }, Uri = xmlObjectLocation.Uri.ToString(), }); } } await requestContext.SendResult(locations.ToArray()); }