本文整理汇总了C#中Microsoft.CodeAnalysis.Location类的典型用法代码示例。如果您正苦于以下问题:C# Location类的具体用法?C# Location怎么用?C# Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Location类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleXmlElement
/// <inheritdoc/>
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, DocumentationCommentTriviaSyntax documentation, XmlNodeSyntax syntax, XElement completeDocumentation, Location[] diagnosticLocations)
{
if (syntax == null)
{
return;
}
if (completeDocumentation != null)
{
XElement summaryNode = completeDocumentation.Nodes().OfType<XElement>().FirstOrDefault(element => element.Name == XmlCommentHelper.SummaryXmlTag);
if (summaryNode == null)
{
// Handled by SA1604
return;
}
if (!XmlCommentHelper.IsConsideredEmpty(summaryNode))
{
return;
}
}
else
{
if (!XmlCommentHelper.IsConsideredEmpty(syntax))
{
return;
}
}
foreach (var location in diagnosticLocations)
{
context.ReportDiagnostic(Diagnostic.Create(Descriptor, location));
}
}
示例2: SimpleDiagnostic
internal SimpleDiagnostic(string id, string category, string message, DiagnosticSeverity severity, bool isEnabledByDefault,
int warningLevel, bool isWarningAsError, Location location,
IEnumerable<Location> additionalLocations)
{
if (isWarningAsError && severity != DiagnosticSeverity.Warning)
{
throw new ArgumentException("isWarningAsError");
}
if ((warningLevel == 0 && severity == DiagnosticSeverity.Warning) ||
(warningLevel != 0 && severity != DiagnosticSeverity.Warning))
{
throw new ArgumentException("warningLevel");
}
this.id = id;
this.category = category;
this.message = message;
this.severity = severity;
this.isEnabledByDefault = isEnabledByDefault;
this.warningLevel = warningLevel;
this.isWarningAsError = isWarningAsError;
this.location = location;
this.additionalLocations = additionalLocations == null ? SpecializedCollections.EmptyReadOnlyList<Location>() : additionalLocations.ToImmutableArray();
}
示例3: CodeGenerationOptions
public CodeGenerationOptions(
Location contextLocation = null,
Location afterThisLocation = null,
Location beforeThisLocation = null,
bool addImports = true,
bool placeSystemNamespaceFirst = true,
IEnumerable<INamespaceSymbol> additionalImports = null,
bool generateMembers = true,
bool mergeNestedNamespaces = true,
bool mergeAttributes = true,
bool generateDefaultAccessibility = true,
bool generateMethodBodies = true,
bool generateDocumentationComments = false,
bool autoInsertionLocation = true,
bool reuseSyntax = false)
{
instance = Activator.CreateInstance (typeInfo, new object[] {
contextLocation,
afterThisLocation,
beforeThisLocation,
addImports,
placeSystemNamespaceFirst,
additionalImports,
generateMembers,
mergeNestedNamespaces,
mergeAttributes,
generateDefaultAccessibility,
generateMethodBodies,
generateDocumentationComments,
autoInsertionLocation,
reuseSyntax
});
}
示例4: HandleXmlElement
/// <inheritdoc/>
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, XmlNodeSyntax syntax, Location diagnosticLocation)
{
if (syntax == null)
{
context.ReportDiagnostic(Diagnostic.Create(Descriptor, diagnosticLocation));
}
}
示例5: SimpleDiagnostic
private SimpleDiagnostic(
DiagnosticDescriptor descriptor,
DiagnosticSeverity severity,
int warningLevel,
Location location,
IEnumerable<Location> additionalLocations,
object[] messageArgs)
{
if ((warningLevel == 0 && severity != DiagnosticSeverity.Error) ||
(warningLevel != 0 && severity == DiagnosticSeverity.Error))
{
throw new ArgumentException(nameof(warningLevel));
}
if(descriptor == null)
{
throw new ArgumentNullException(nameof(descriptor));
}
_descriptor = descriptor;
_severity = severity;
_warningLevel = warningLevel;
_location = location ?? Location.None;
_additionalLocations = additionalLocations == null ? SpecializedCollections.EmptyReadOnlyList<Location>() : additionalLocations.ToImmutableArray();
_messageArgs = messageArgs ?? SpecializedCollections.EmptyArray<object>();
}
示例6: SuggestedHandlerCompletionData
public SuggestedHandlerCompletionData (MonoDevelop.Projects.Project project, CodeMemberMethod methodInfo, INamedTypeSymbol codeBehindClass, Location codeBehindClassLocation)
{
this.project = project;
this.methodInfo = methodInfo;
this.codeBehindClass = codeBehindClass;
this.codeBehindClassLocation = codeBehindClassLocation;
}
示例7: DiagnosticWithInfo
internal DiagnosticWithInfo(DiagnosticInfo info, Location location)
{
Debug.Assert(info != null);
Debug.Assert(location != null);
_info = info;
_location = location;
}
示例8: HandleXmlElement
/// <inheritdoc/>
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, XmlNodeSyntax syntax, Location diagnosticLocation)
{
if (syntax != null && XmlCommentHelper.IsConsideredEmpty(syntax))
{
context.ReportDiagnostic(Diagnostic.Create(Descriptor, diagnosticLocation));
}
}
示例9: GetAdjustedDiagnosticSpan
public void GetAdjustedDiagnosticSpan(
DocumentId documentId, Location location,
out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
{
sourceSpan = location.SourceSpan;
originalLineInfo = location.GetLineSpan();
mappedLineInfo = location.GetMappedLineSpan();
// Update the original source span, if required.
LinePositionSpan originalSpan;
LinePositionSpan mappedSpan;
if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out originalSpan, out mappedSpan))
{
return;
}
if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
{
originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);
var textLines = location.SourceTree.GetText().Lines;
var startPos = textLines.GetPosition(originalSpan.Start);
var endPos = textLines.GetPosition(originalSpan.End);
sourceSpan = new TextSpan(startPos, endPos - startPos);
}
if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
{
mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
}
}
示例10: ConvertSymbol
private QuickFix ConvertSymbol(ISymbol symbol, Location location)
{
var lineSpan = location.GetLineSpan();
var path = lineSpan.Path;
var documents = _workspace.GetDocuments(path);
var format = SymbolDisplayFormat.MinimallyQualifiedFormat;
format = format.WithMemberOptions(format.MemberOptions
^ SymbolDisplayMemberOptions.IncludeContainingType
^ SymbolDisplayMemberOptions.IncludeType);
format = format.WithKindOptions(SymbolDisplayKindOptions.None);
return new SymbolLocation
{
Text = symbol.ToDisplayString(format),
Kind = symbol.GetKind(),
FileName = path,
Line = lineSpan.StartLinePosition.Line + 1,
Column = lineSpan.StartLinePosition.Character + 1,
EndLine = lineSpan.EndLinePosition.Line + 1,
EndColumn = lineSpan.EndLinePosition.Character + 1,
Projects = documents.Select(document => document.Project.Name).ToArray()
};
}
示例11: GetTransformedDocumentAsync
private static async Task<Document> GetTransformedDocumentAsync(Document document, Location location, CancellationToken cancellationToken)
{
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
var sourceSpan = location.SourceSpan;
return document.WithText(text.WithChanges(GetTextChange(text, sourceSpan)));
}
示例12: HandleXmlElement
/// <inheritdoc/>
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, DocumentationCommentTriviaSyntax documentation, XmlNodeSyntax syntax, XElement completeDocumentation, Location[] diagnosticLocations)
{
if (completeDocumentation != null)
{
// We are working with an <include> element
if (completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.SummaryXmlTag))
{
return;
}
if (completeDocumentation.Nodes().OfType<XElement>().Any(element => element.Name == XmlCommentHelper.InheritdocXmlTag))
{
// Ignore nodes with an <inheritdoc/> tag in the included XML.
return;
}
}
else
{
if (syntax != null)
{
return;
}
if (documentation?.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null)
{
// Ignore nodes with an <inheritdoc/> tag.
return;
}
}
foreach (var location in diagnosticLocations)
{
context.ReportDiagnostic(Diagnostic.Create(Descriptor, location));
}
}
示例13: InsertionResult
public InsertionResult(CodeRefactoringContext context, SyntaxNode node, INamedTypeSymbol type, Location location)
{
this.Context = context;
this.Node = node;
this.Type = type;
this.Location = location;
}
示例14: GetAdjustedDiagnosticSpan
public void GetAdjustedDiagnosticSpan(
DocumentId documentId, Location location,
out TextSpan sourceSpan, out FileLinePositionSpan originalLineInfo, out FileLinePositionSpan mappedLineInfo)
{
sourceSpan = location.SourceSpan;
originalLineInfo = location.GetLineSpan();
mappedLineInfo = location.GetMappedLineSpan();
// check quick bail out case.
if (location == Location.None)
{
return;
}
// Update the original source span, if required.
if (!TryAdjustSpanIfNeededForVenus(documentId, originalLineInfo, mappedLineInfo, out var originalSpan, out var mappedSpan))
{
return;
}
if (originalSpan.Start != originalLineInfo.StartLinePosition || originalSpan.End != originalLineInfo.EndLinePosition)
{
originalLineInfo = new FileLinePositionSpan(originalLineInfo.Path, originalSpan.Start, originalSpan.End);
var textLines = location.SourceTree.GetText().Lines;
var startPos = textLines.GetPosition(originalSpan.Start);
var endPos = textLines.GetPosition(originalSpan.End);
sourceSpan = TextSpan.FromBounds(startPos, Math.Max(startPos, endPos));
}
if (mappedSpan.Start != mappedLineInfo.StartLinePosition || mappedSpan.End != mappedLineInfo.EndLinePosition)
{
mappedLineInfo = new FileLinePositionSpan(mappedLineInfo.Path, mappedSpan.Start, mappedSpan.End);
}
}
示例15: Session
public Session(
RenameLocations renameLocationSet,
Location renameSymbolDeclarationLocation,
string originalText,
string replacementText,
OptionSet optionSet,
Func<IEnumerable<ISymbol>, bool?> newSymbolsAreValid,
CancellationToken cancellationToken)
{
_renameLocationSet = renameLocationSet;
_renameSymbolDeclarationLocation = renameSymbolDeclarationLocation;
_originalText = originalText;
_replacementText = replacementText;
_optionSet = optionSet;
_hasConflictCallback = newSymbolsAreValid;
_cancellationToken = cancellationToken;
_renamedSymbolDeclarationAnnotation = new RenameAnnotation();
_conflictLocations = SpecializedCollections.EmptySet<ConflictLocationInfo>();
_replacementTextValid = true;
_possibleNameConflicts = new List<string>();
// only process documents which possibly contain the identifiers.
_documentsIdsToBeCheckedForConflict = new HashSet<DocumentId>();
_documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetDocument(renameSymbolDeclarationLocation.SourceTree).Id;
_renameAnnotations = new AnnotationTable<RenameAnnotation>(RenameAnnotation.Kind);
}