本文整理汇总了C#中Microsoft.CodeAnalysis.Location类的典型用法代码示例。如果您正苦于以下问题:C# Location类的具体用法?C# Location怎么用?C# Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Location类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了Location类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
}
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:35,代码来源:SA1606ElementDocumentationMustHaveSummaryText.cs
示例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();
}
开发者ID:pheede,项目名称:roslyn,代码行数:25,代码来源:Diagnostic_SimpleDiagnostic.cs
示例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
});
}
开发者ID:pabloescribanoloza,项目名称:monodevelop,代码行数:33,代码来源:CodeGenerationOptions.cs
示例4: HandleXmlElement
/// <inheritdoc/>
protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, XmlNodeSyntax syntax, Location diagnosticLocation)
{
if (syntax == null)
{
context.ReportDiagnostic(Diagnostic.Create(Descriptor, diagnosticLocation));
}
}
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1609PropertyDocumentationMustHaveValue.cs
示例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>();
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:26,代码来源:Diagnostic_SimpleDiagnostic.cs
示例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;
}
开发者ID:FreeBSD-DotNet,项目名称:monodevelop,代码行数:7,代码来源:SuggestedHandlerCompletionData.cs
示例7: DiagnosticWithInfo
internal DiagnosticWithInfo(DiagnosticInfo info, Location location)
{
Debug.Assert(info != null);
Debug.Assert(location != null);
_info = info;
_location = location;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:7,代码来源:DiagnosticWithInfo.cs
示例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));
}
}
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:8,代码来源:SA1610PropertyDocumentationMustHaveValueText.cs
示例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);
}
}
开发者ID:JinGuoGe,项目名称:roslyn,代码行数:31,代码来源:VisualStudioVenusSpanMappingService.cs
示例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()
};
}
开发者ID:tugberkugurlu,项目名称:omnisharp-roslyn,代码行数:25,代码来源:OmnisharpController.FindSymbols.cs
示例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)));
}
开发者ID:Romanx,项目名称:StyleCopAnalyzers,代码行数:7,代码来源:SA1005CodeFixProvider.cs
示例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));
}
}
开发者ID:NikolayIT,项目名称:StyleCopAnalyzers,代码行数:36,代码来源:SA1604ElementDocumentationMustHaveSummary.cs
示例13: InsertionResult
public InsertionResult(CodeRefactoringContext context, SyntaxNode node, INamedTypeSymbol type, Location location)
{
this.Context = context;
this.Node = node;
this.Type = type;
this.Location = location;
}
开发者ID:alecor191,项目名称:RefactoringEssentials,代码行数:7,代码来源:InsertionResult.cs
示例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);
}
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:35,代码来源:VisualStudioVenusSpanMappingService.cs
示例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);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:ConflictResolver.Session.cs
示例16: SimpleDiagnostic
private SimpleDiagnostic(
DiagnosticDescriptor descriptor,
DiagnosticSeverity severity,
int warningLevel,
Location location,
IEnumerable<Location> additionalLocations,
object[] messageArgs,
ImmutableDictionary<string, string> properties,
bool isSuppressed)
{
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?.ToImmutableArray() ?? SpecializedCollections.EmptyReadOnlyList<Location>();
_messageArgs = messageArgs ?? Array.Empty<object>();
_properties = properties ?? ImmutableDictionary<string, string>.Empty;
_isSuppressed = isSuppressed;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:30,代码来源:Diagnostic_SimpleDiagnostic.cs
示例17: AddQuickFix
public static async Task AddQuickFix(ICollection<QuickFix> quickFixes, OmnisharpWorkspace workspace, Location location)
{
if (location.IsInSource)
{
var quickFix = await GetQuickFix(workspace, location);
quickFixes.Add(quickFix);
}
}
开发者ID:robbert229,项目名称:omnisharp-roslyn,代码行数:8,代码来源:QuickFixHelper.cs
示例18: ReferenceDirective
public ReferenceDirective(string file, Location location)
{
Debug.Assert(file != null);
Debug.Assert(location != null);
File = file;
Location = location;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:ReferenceDirective.cs
示例19: setLocation
protected void setLocation(Location location)
{
var line = location.GetMappedLineSpan().StartLinePosition;
File = location.FilePath;
Line = line.Line + 1;
Character = line.Character + 1;
}
开发者ID:reicheltp,项目名称:refit,代码行数:8,代码来源:Diagnostics.cs
示例20: AddQuickFix
private async Task AddQuickFix(ICollection<QuickFix> quickFixes, Location location)
{
if (location.IsInSource)
{
var quickFix = await GetQuickFix(location);
quickFixes.Add(quickFix);
}
}
开发者ID:tugberkugurlu,项目名称:omnisharp-roslyn,代码行数:8,代码来源:OmnisharpController.QuickFixes.cs
注:本文中的Microsoft.CodeAnalysis.Location类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论