本文整理汇总了C#中Microsoft.CodeAnalysis.Solution.GetDocumentIdsWithFilePath方法的典型用法代码示例。如果您正苦于以下问题:C# Solution.GetDocumentIdsWithFilePath方法的具体用法?C# Solution.GetDocumentIdsWithFilePath怎么用?C# Solution.GetDocumentIdsWithFilePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.Solution
的用法示例。
在下文中一共展示了Solution.GetDocumentIdsWithFilePath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddActiveStatements
private void AddActiveStatements(Solution solution, ShellInterop.ENC_ACTIVE_STATEMENT[] vsActiveStatements)
{
Debug.Assert(_activeMethods.Count == 0);
Debug.Assert(_exceptionRegions.Count == 0);
foreach (var vsActiveStatement in vsActiveStatements)
{
log.DebugWrite("+AS[{0}]: {1} {2} {3} {4} '{5}'",
vsActiveStatement.id,
vsActiveStatement.tsPosition.iStartLine,
vsActiveStatement.tsPosition.iStartIndex,
vsActiveStatement.tsPosition.iEndLine,
vsActiveStatement.tsPosition.iEndIndex,
vsActiveStatement.filename);
// TODO (tomat):
// Active statement is in user hidden code. The only information that we have from the debugger
// is the method token. We don't need to track the statement (it's not in user code anyways),
// but we should probably track the list of such methods in order to preserve their local variables.
// Not sure what's exactly the scenario here, perhaps modifying async method/iterator?
// Dev12 just ignores these.
if (vsActiveStatement.posType != TEXT_POSITION_ACTIVE_STATEMENT)
{
continue;
}
var flags = (ActiveStatementFlags)vsActiveStatement.ASINFO;
// Finds a document id in the solution with the specified file path.
DocumentId documentId = solution.GetDocumentIdsWithFilePath(vsActiveStatement.filename)
.Where(dId => dId.ProjectId == _vsProject.Id).SingleOrDefault();
if (documentId != null)
{
var document = solution.GetDocument(documentId);
Debug.Assert(document != null);
SourceText source = document.GetTextAsync(default(CancellationToken)).Result;
LinePositionSpan lineSpan = vsActiveStatement.tsPosition.ToLinePositionSpan();
// If the PDB is out of sync with the source we might get bad spans.
var sourceLines = source.Lines;
if (lineSpan.End.Line >= sourceLines.Count || sourceLines.GetPosition(lineSpan.End) > sourceLines[sourceLines.Count - 1].EndIncludingLineBreak)
{
log.Write("AS out of bounds (line count is {0})", source.Lines.Count);
continue;
}
SyntaxNode syntaxRoot = document.GetSyntaxRootAsync(default(CancellationToken)).Result;
var analyzer = document.Project.LanguageServices.GetService<IEditAndContinueAnalyzer>();
s_pendingActiveStatements.Add(new VsActiveStatement(
this,
vsActiveStatement.id,
document.Id,
new ActiveStatementSpan(flags, lineSpan)));
bool isLeaf = (flags & ActiveStatementFlags.LeafFrame) != 0;
var ehRegions = analyzer.GetExceptionRegions(source, syntaxRoot, lineSpan, isLeaf);
for (int i = 0; i < ehRegions.Length; i++)
{
_exceptionRegions.Add(new VsExceptionRegion(
vsActiveStatement.id,
i,
vsActiveStatement.methodToken,
ehRegions[i]));
}
}
_activeMethods.Add(vsActiveStatement.methodToken);
}
}
示例2: GetDocument
private static Document GetDocument(Solution solution, string fname)
{
var docId = solution.GetDocumentIdsWithFilePath(fname).First();
var doc = solution.GetDocument(docId);
return doc;
}