public override void Undo(BlockCommandContext context) { // If we have a block key, we use that first. ProjectBlockCollection blocks = context.Blocks; if (UseBlockKey) { Block block; using ( blocks.AcquireBlockLock( RequestLock.Write, RequestLock.Write, BlockKey, out block)) { Undo(context, block); } } else { Block block; using ( blocks.AcquireBlockLock( RequestLock.Write, RequestLock.Write, (int)Line, out block)) { Undo(context, block); } } }
public static void GetBeginAndEndCharacterIndices( this SingleLineTextRange range, ProjectBlockCollection blocks, out int blockIndex, out int sourceBegin, out int sourceEnd, out string text) { using (blocks.AcquireLock(RequestLock.Read)) { // Start by getting the block based on the index. Block block; blockIndex = range.LinePosition.GetLineIndex(blocks.Count); using ( blocks.AcquireBlockLock( RequestLock.Read, RequestLock.Read, blockIndex, out block)) { // Get the text and calculate the character indicies. text = block.Text; range.GetBeginAndEndCharacterIndices(text, out sourceBegin, out sourceEnd); } } }
public void Run() { // Figure out which analyzers we need to actually run on the block. var neededAnalyzers = new List <IBlockAnalyzerProjectPlugin>(); foreach (IBlockAnalyzerProjectPlugin blockAnalyzer in BlockAnalyzers) { if (!Analysis.Contains(blockAnalyzer)) { neededAnalyzers.Add(blockAnalyzer); } } // Loop through all the analyzers in the list and perform each one in turn. ProjectBlockCollection blocks = Block.Project.Blocks; foreach (IBlockAnalyzerProjectPlugin blockAnalyzer in neededAnalyzers) { // Check to see if the block had gone stale. using (blocks.AcquireBlockLock(RequestLock.Read, Block)) { if (Block.IsStale(BlockVersion)) { // The block is stale, so we just dump out since there will be // another task to reanalyze this block. return; } } // Perform the analysis on the given block. blockAnalyzer.AnalyzeBlock(Block, BlockVersion); // Once we're done analyzing the block, we need to add this // analyzer to the list so we don't attempt to run it again. Block.AddAnalysis(blockAnalyzer); } }