本文整理汇总了C#中DocumentRange类的典型用法代码示例。如果您正苦于以下问题:C# DocumentRange类的具体用法?C# DocumentRange怎么用?C# DocumentRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentRange类属于命名空间,在下文中一共展示了DocumentRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PsiIntentionResult
public PsiIntentionResult(List<ITemplateFieldHolder> holders, IDeclaration declaration, ITreeNode anchor, DocumentRange range)
{
myDeclaration = declaration;
myHolders = holders;
myPrefferedSelection = range;
myAnchor = anchor;
}
示例2: Actions
/// <summary>
/// Returns a WhyBulb for the given highlighting.
/// </summary>
/// <param name="highlighting">Highlighting to process.</param>
/// <param name="highlightingRange">Hihglighting range - not used here.</param>
/// <returns></returns>
public ICollection<IDisableHighlightingAction> Actions(IHighlighting highlighting, DocumentRange highlightingRange)
{
var cSharpHighlighting = highlighting as CSharpHighlightingBase;
return (cSharpHighlighting == null)
? EmptyArray<IDisableHighlightingAction>.Instance
: new IDisableHighlightingAction[] { new WhyBulb(highlighting.ErrorStripeToolTip, highlighting.GetType().Name) };
}
示例3: GetHighlight
/// <summary>
/// Gets the highlight for the specified StyleCop Violation.
/// </summary>
/// <param name="violation">
/// The <see cref="StyleCop.ViolationEventArgs"/> instance containing the event data.
/// </param>
/// <param name="documentRange">
/// <see cref="DocumentRange"/>where the Violation happened.
/// </param>
/// <param name="fileName">
/// <see cref="CsElement"/>of the violation.
/// </param>
/// <param name="lineNumber">
/// Line number where the violation happened.
/// </param>
/// <returns>
/// An <see cref="IHighlighting"/> for the specified Violation.
/// </returns>
public static IHighlighting GetHighlight(ViolationEventArgs violation, DocumentRange documentRange, string fileName, int lineNumber)
{
string ruleID = violation.Violation.Rule.CheckId;
string highlightID = HighlightingRegistering.GetHighlightID(ruleID);
VSSolutionManager solutionManager = Shell.Instance.GetComponent<VSSolutionManager>();
IContextBoundSettingsStore settingsStore = PsiSourceFileExtensions.GetSettingsStore(null, solutionManager.CurrentSolution);
Severity severity = HighlightingSettingsManager.Instance.GetConfigurableSeverity(highlightID, settingsStore);
switch (severity)
{
case Severity.ERROR:
return new StyleCopHighlightingError(violation, documentRange, fileName, lineNumber);
case Severity.HINT:
return new StyleCopHighlightingHint(violation, documentRange, fileName, lineNumber);
case Severity.INFO:
return new StyleCopHighlightingError(violation, documentRange, fileName, lineNumber);
case Severity.SUGGESTION:
return new StyleCopHighlightingSuggestion(violation, documentRange, fileName, lineNumber);
case Severity.WARNING:
return new StyleCopHighlightingWarning(violation, documentRange, fileName, lineNumber);
default:
return new StyleCopHighlightingDoNotShow(violation, documentRange, fileName, lineNumber);
}
}
示例4: AttributeParamImpl
public AttributeParamImpl(IXmlAttribute xmlAttribute,IParameterDescriptorProvider parameterDescriptorProvider)
{
name = xmlAttribute.AttributeName;
nameDocumentRange = xmlAttribute.ToTreeNode().NameNode.GetDocumentRange();
stringValue = xmlAttribute.UnquotedValue;
this.parameterDescriptorProvider = parameterDescriptorProvider;
}
示例5: FixExpressionToStatement
public static ICSharpStatement FixExpressionToStatement(DocumentRange expressionRange,
[NotNull] IPsiServices psiServices)
{
var solution = psiServices.Solution;
var offset = expressionRange.TextRange.StartOffset;
var document = expressionRange.Document;
var expressions = TextControlToPsi.GetElements<IRazorImplicitExpression>(solution, document, offset);
foreach (var razorExpression in expressions)
{
var razorRange = razorExpression.GetDocumentRange();
const string commandName = "Replacing razor expression with statement";
using (solution.CreateTransactionCookie(
DefaultAction.Commit, commandName, NullProgressIndicator.Instance))
{
razorRange.Document.ReplaceText(razorRange.TextRange, "@using(null){}");
}
solution.GetPsiServices().CommitAllDocuments();
var statements = TextControlToPsi.GetElements<IUsingStatement>(solution, document, offset);
foreach (var razorStatement in statements)
{
return razorStatement;
}
break;
}
return null;
}
示例6: GetHighlight
/// <summary>
/// Gets the highlight for the specified StyleCop Violation.
/// </summary>
/// <param name="violation">
/// The <see cref="StyleCop.ViolationEventArgs"/> instance containing the event data.
/// </param>
/// <param name="documentRange">
/// <see cref="DocumentRange"/>where the Violation happened.
/// </param>
/// <param name="fileName">
/// <see cref="CsElement"/>of the violation.
/// </param>
/// <param name="lineNumber">
/// Line number where the violation happened.
/// </param>
/// <returns>
/// An <see cref="IHighlighting"/> for the specified Violation.
/// </returns>
public static IHighlighting GetHighlight(ViolationEventArgs violation, DocumentRange documentRange, string fileName, int lineNumber)
{
string ruleID = violation.Violation.Rule.CheckId;
string highlightID = HighlightingRegistering.GetHighlightID(ruleID);
// To get the correct severity for a highlight we need to specify the current solution.
ISolutionManager solutionManager = Shell.Instance.GetComponent<ISolutionManager>();
Severity severity = HighlightingSettingsManager.Instance.GetConfigurableSeverity(highlightID, solutionManager.CurrentSolution);
switch (severity)
{
case Severity.ERROR:
return new StyleCopViolationError(violation, documentRange, fileName, lineNumber);
case Severity.HINT:
return new StyleCopViolationHint(violation, documentRange, fileName, lineNumber);
case Severity.INFO:
return new StyleCopViolationError(violation, documentRange, fileName, lineNumber);
case Severity.SUGGESTION:
return new StyleCopViolationSuggestion(violation, documentRange, fileName, lineNumber);
case Severity.WARNING:
return new StyleCopViolationWarning(violation, documentRange, fileName, lineNumber);
default:
return new StyleCopViolationDoNotShow(violation, documentRange, fileName, lineNumber);
}
}
示例7: GetSelectedRange
public ISelectedRange GetSelectedRange(IPsiSourceFile sourceFile, DocumentRange documentRange) {
Pair<IT4File, IFile> pair = GetFiles(sourceFile, documentRange);
IT4File t4File = pair.First;
IFile codeBehindFile = pair.Second;
if (t4File == null)
return null;
ITreeNode t4Node = t4File.FindNodeAt(documentRange);
if (t4Node == null)
return null;
// if the current selection is inside C# code, use the C# extend selection directly
if (codeBehindFile != null) {
ISelectEmbracingConstructProvider codeBehindProvider = PsiShared.GetComponent<PsiProjectFileTypeCoordinator>()
.GetByPrimaryPsiLanguageType(codeBehindFile.Language)
.SelectNotNull(fileType => Shell.Instance.GetComponent<IProjectFileTypeServices>().TryGetService<ISelectEmbracingConstructProvider>(fileType))
.FirstOrDefault();
if (codeBehindProvider != null) {
ISelectedRange codeBehindRange = codeBehindProvider.GetSelectedRange(sourceFile, documentRange);
if (codeBehindRange != null)
return new T4CodeBehindWrappedSelection(t4File, codeBehindRange);
}
}
return new T4NodeSelection(t4File, t4Node);
}
示例8: SuggestionBase
/// <summary>Initializes a new instance of the <see cref="SuggestionBase"/> class.</summary>
/// <param name="suggestionName">Name of the suggestion.</param>
/// <param name="element">The element.</param>
/// <param name="highlightingRange">The highlighting range.</param>
/// <param name="toolTip">The tool tip.</param>
protected SuggestionBase(string suggestionName, IElement element, DocumentRange highlightingRange, string toolTip)
{
this.range = highlightingRange;
this.toolTip = toolTip;
this.element = element;
this.suggestionName = suggestionName;
}
示例9: CreateMissedParameterFix
public CreateMissedParameterFix(MissedParameterError missedParameterError)
{
if (missedParameterError == null)
throw new ArgumentNullException("missedParameterError");
this.missedParameterError = missedParameterError;
headerNameRange = ((IXmlTag) missedParameterError.Element).ToTreeNode().Header.Name.GetDocumentRange();
}
示例10: StyleCopHighlightingBase
/// <summary>
/// Initializes a new instance of the <see cref="StyleCopHighlightingBase"/> class.
/// </summary>
/// <param name="violationEventArgs">
/// The <see cref="StyleCop.ViolationEventArgs"/> instance containing the Violation data.
/// </param>
/// <param name="documentRange">
/// Range where the Violation happened.
/// </param>
protected StyleCopHighlightingBase(ViolationEventArgs violationEventArgs, DocumentRange documentRange)
{
this.CheckId = violationEventArgs.Violation.Rule.CheckId;
this.ToolTip = violationEventArgs.Message + " [StyleCop Rule: " + this.CheckId + "]";
this.documentRange = documentRange;
this.Rule = violationEventArgs.Violation.Rule;
this.Violation = violationEventArgs.Violation;
}
示例11: NTriplesIntentionResult
public NTriplesIntentionResult(
List<ITemplateFieldHolder> holders, IDeclaration declaration, ITreeNode anchor, DocumentRange range)
{
this.myDeclaration = declaration;
this.myHolders = holders;
this.myPreferredSelection = range;
this.myAnchor = anchor;
}
示例12: ExecutePsiTransaction
protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
{
var methodDeclaration = _highlighting.MethodDeclaration;
methodDeclaration.SetExtern(false);
var textRange = LanguageManager.Instance.GetService<IMemberBodyOperations>(methodDeclaration.Language).SetBodyToDefault(methodDeclaration);
var rangeMarker = new DocumentRange(methodDeclaration.GetDocumentRange().Document, textRange).CreateRangeMarker(DocumentManager.GetInstance(solution));
return control => control.Selection.SetRange(rangeMarker.Range);
}
示例13: Block
/// <summary>
///
/// </summary>
/// <param name="startLineNumber">Indexed from 1</param>
/// <param name="endLineNumber">Indexed from 1</param>
/// <param name="projectFile"></param>
/// <param name="set"></param>
/// <param name="range"></param>
public Block(int startLineNumber, int endLineNumber, IProjectFile projectFile, Set set, DocumentRange? range)
{
Range = range;
this.set = set;
this.projectFile = projectFile;
this.startLineNumber = startLineNumber;
this.endLineNumber = endLineNumber;
}
示例14: AddHighLighting
private void AddHighLighting(DocumentRange range, ITreeNode element, IHighlightingConsumer consumer, IHighlighting highlighting)
{
var info = new HighlightingInfo(range, highlighting, new Severity?());
IFile file = element.GetContainingFile();
if (file != null)
{
consumer.AddHighlighting(info.Highlighting, file);
}
}
示例15: StyleCopViolationBase
/// <summary>
/// Initializes a new instance of the <see cref="StyleCopViolationBase"/> class.
/// </summary>
/// <param name="violation">
/// The <see cref="StyleCop.ViolationEventArgs"/> instance containing the Violation data.
/// </param>
/// <param name="documentRange">
/// Range where the Violation happened.
/// </param>
/// <param name="fileName">
/// The file Name.
/// </param>
/// <param name="lineNumber">
/// Line number of where the violation happened.
/// </param>
protected StyleCopViolationBase(ViolationEventArgs violation, DocumentRange documentRange, string fileName, int lineNumber)
{
this.CheckId = violation.Violation.Rule.CheckId;
this.ToolTip = violation.Message + " [StyleCop Rule: " + this.CheckId + "]";
this.DocumentRange = documentRange;
this.FileName = fileName;
this.LineNumber = lineNumber;
this.Rule = violation.Violation.Rule;
}