本文整理汇总了C#中SourceRange类的典型用法代码示例。如果您正苦于以下问题:C# SourceRange类的具体用法?C# SourceRange怎么用?C# SourceRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceRange类属于命名空间,在下文中一共展示了SourceRange类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetCodeIssues
public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
ISourceCode sourceCode,
Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
Violation violation,
CsElement csElement)
{
SourcePoint? startPoint = null;
SourcePoint? endPoint = null;
foreach (var token in from token in csElement.ElementTokens
where token.LineNumber == violation.Line && token.CsTokenType != CsTokenType.WhiteSpace
select token)
{
if (token.CsTokenType == CsTokenType.Namespace)
{
startPoint = endPoint = new SourcePoint(token.Location.StartPoint.LineNumber, token.Location.StartPoint.IndexOnLine + 1);
}
else if (token.CsTokenType == CsTokenType.OpenCurlyBracket || token.CsTokenType == CsTokenType.EndOfLine)
{
if (startPoint != null)
{
var sourceRange = new SourceRange(startPoint.Value, endPoint.Value);
yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
}
yield break;
}
else if (startPoint != null)
{
endPoint = new SourcePoint(token.Location.EndPoint.LineNumber, token.Location.EndPoint.IndexOnLine + 2);
}
}
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:32,代码来源:SA1403_FileMayOnlyContainASingleNamespace.cs
示例2: ExtractRemainingSelection
private static void ExtractRemainingSelection(TextDocument ActiveDoc, SourceRange SelectRange)
{
// Extract Remaining Selection
CodeRush.Selection.SelectRange(SelectRange);
ExecuteRefactoring("Extract Method");
ActiveDoc.ParseIfTextChanged();
}
开发者ID:modulexcite,项目名称:CR_ExtractMethodAndInlineLiterals,代码行数:7,代码来源:PlugIn1.cs
示例3: Lexer
public Lexer(IErrorReporter errorReporter, string source)
{
_errorReporter = errorReporter;
_source = source;
_reader = new CharReader(source);
_tokenRange = SourceRange.Empty;
}
开发者ID:chenzuo,项目名称:nquery,代码行数:7,代码来源:Lexer.cs
示例4: TemplateExpandWithCollapsedRegions_Execute
private void TemplateExpandWithCollapsedRegions_Execute(ExecuteEventArgs ea)
{
TextDocument ActiveDoc = CodeRush.Documents.ActiveTextDocument;
using (ActiveDoc.NewCompoundAction("TemplateExpandWithCollapsedRegions"))
{
var LinesFromStart = CodeRush.Caret.Line;
var LinesFromEnd = ActiveDoc.LineCount - LinesFromStart;
DevExpress.CodeRush.Core.Action Action = CodeRush.Actions.Get("TemplateExpand");
Action.DoExecute();
// Calculate line range that template expanded into.
SourceRange TemplateExpandRange = new SourceRange(new SourcePoint(LinesFromStart, 1),
new SourcePoint(ActiveDoc.LineCount - LinesFromEnd,
ActiveDoc.GetLine(LinesFromEnd).Length - 1)
);
// Reparse everything just in case.
CodeRush.Documents.ParseActive();
CodeRush.Documents.ActiveTextDocument.ParseIfTextChanged();
// Execute a delayed collapse of all regions in the ExpansionRange
RangeRegionCollapser Collapser = new RangeRegionCollapser(TemplateExpandRange);
Collapser.PerformDelayedCollapse(150);
}
}
开发者ID:modulexcite,项目名称:CR_TemplateExpandWithCollapsedRegions,代码行数:27,代码来源:PlugIn1.cs
示例5: GetCodeIssues
public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
ISourceCode sourceCode,
Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
Violation violation,
CsElement csElement)
{
CodePoint startPoint = null;
CodePoint endPoint = null;
foreach (var token in from token in csElement.ElementTokens
where token.LineNumber >= violation.Line
select token)
{
if (token.CsTokenType == CsTokenType.UsingDirective || token.CsTokenType == CsTokenType.Using)
{
startPoint = token.Location.StartPoint;
continue;
}
if (token.CsTokenType == CsTokenType.Semicolon)
{
endPoint = token.Location.EndPoint;
}
if (startPoint != null && endPoint != null)
{
var sourceRange = new SourceRange(startPoint.LineNumber, startPoint.IndexOnLine + 1, endPoint.LineNumber, endPoint.IndexOnLine + 2);
yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
}
}
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:30,代码来源:UsingDirectiveCodeIssue.cs
示例6: GetCodeIssues
public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
ISourceCode sourceCode,
Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
Violation violation,
CsElement csElement)
{
CsToken startToken = null;
foreach (var token in from token in csElement.ElementTokens
where violation.Line == token.Location.StartPoint.LineNumber
&& (token.CsTokenType == CsTokenType.OpenCurlyBracket
|| token.CsTokenType == CsTokenType.CloseCurlyBracket)
select token)
{
if (token.CsTokenType == CsTokenType.OpenCurlyBracket)
{
startToken = token;
continue;
}
if (token.CsTokenType == CsTokenType.CloseCurlyBracket)
{
var sourceRange = new SourceRange(startToken.Location.StartPoint.LineNumber, startToken.Location.StartPoint.IndexOnLine + 1, token.Location.EndPoint.LineNumber, token.Location.EndPoint.IndexOnLine + 2);
yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
}
}
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:26,代码来源:SA1501_StatementMustNotBeOnASingleLine.cs
示例7: GetCodeIssues
public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
ISourceCode sourceCode,
Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
Violation violation,
CsElement csElement)
{
int prefixLength = "The call to ".Length;
var memberName = violation.Message.Substring(prefixLength, violation.Message.IndexOf(" must") - prefixLength);
var thisFound = false;
foreach (var token in from token in csElement.ElementTokens
where token.LineNumber == violation.Line && token.CsTokenType != CsTokenType.WhiteSpace
select token)
{
if (token.CsTokenType == CsTokenType.This || (thisFound && token.Text == "."))
{
thisFound = true;
}
else
{
if (token.Text == memberName && !thisFound)
{
var sourceRange = new SourceRange(token.Location.StartPoint.LineNumber, token.Location.StartPoint.IndexOnLine + 1, token.Location.EndPoint.LineNumber, token.Location.EndPoint.IndexOnLine + 2);
yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
}
thisFound = false;
}
}
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:29,代码来源:SA1101_PrefixLocalCallsWithThis.cs
示例8: ResExp
public ResExp(
SourceRange range,
IResTypeExp type)
{
_range = range;
_type = type;
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:7,代码来源:ResExp.cs
示例9: Token
public Token(string text, TokenId tokenId, int pos, SourceRange range)
{
_text = text;
_tokenId = tokenId;
_pos = pos;
_range = range;
}
开发者ID:chenzuo,项目名称:nquery,代码行数:7,代码来源:Token.cs
示例10: ResTypeVarRef
public ResTypeVarRef(
SourceRange range,
IResTypeParamDecl varDecl)
{
_range = range;
_varDecl = varDecl;
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:7,代码来源:ResTypeVarRef.cs
示例11: GetCodeIssues
public IEnumerable<StyleCopCodeIssue> GetCodeIssues(
ISourceCode sourceCode,
Func<ElementTypeFilter, IEnumerable<IElement>> enumerate,
Violation violation,
CsElement csElement)
{
var preprocessorToken = (from token in csElement.ElementTokens
where token.LineNumber == violation.Line && token.CsTokenType == CsTokenType.PreprocessorDirective
select token).FirstOrDefault();
if (preprocessorToken != null)
{
int underlineLength = 1;
while (preprocessorToken.Text[underlineLength] == ' ' || preprocessorToken.Text[underlineLength] == '\t')
{
underlineLength++;
}
while (underlineLength < preprocessorToken.Text.Length && preprocessorToken.Text[underlineLength] != ' ' && preprocessorToken.Text[underlineLength] != '\t')
{
underlineLength++;
}
var startPoint = preprocessorToken.Location.StartPoint;
var sourceRange = new SourceRange(startPoint.LineNumber, startPoint.IndexOnLine + 1, startPoint.LineNumber, startPoint.IndexOnLine + 1 + underlineLength);
yield return new StyleCopCodeIssue(CodeIssueType.CodeSmell, sourceRange);
}
}
开发者ID:kevinmiles,项目名称:dxcorecommunityplugins,代码行数:27,代码来源:PreprocessorDirectiveIssueLocator.cs
示例12: GetPrimitives
private static ElementEnumerable GetPrimitives(SourceRange SelectRange)
{
// Find all literals in SelectRange.
var RangePrimitives = new ElementEnumerable(CodeRush.Source.ActiveFileNode,
new TypeInRangeFilter(LanguageElementType.PrimitiveExpression,
SelectRange), true);
return RangePrimitives;
}
开发者ID:modulexcite,项目名称:CR_ExtractMethodAndInlineLiterals,代码行数:8,代码来源:PlugIn1.cs
示例13: ResVarRef
public ResVarRef(
SourceRange range,
IResVarDecl varDecl,
IResTypeExp type)
: base(range, type)
{
_varDecl = varDecl;
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:8,代码来源:ResVarRef.cs
示例14: ResVarDecl
public ResVarDecl(
SourceRange range,
Identifier name,
IResTypeExp type,
ResVarFlags flags = ResVarFlags.None)
: this(range, name, Lazy.Value(type), flags)
{
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:8,代码来源:ResVarDecl.cs
示例15: ResLabel
public ResLabel(
SourceRange range,
Identifier name,
IResTypeExp type)
{
_range = range;
_name = name;
_type = type;
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:ResLabelExp.cs
示例16: ResTypeParamDecl
public ResTypeParamDecl(
SourceRange range,
Identifier name,
ResKind kind)
{
_range = range;
_name = name;
_kind = kind;
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:ResTypeParamDecl.cs
示例17: MidElementCtorApp
public MidElementCtorApp(
SourceRange range,
MidElementDecl element,
IEnumerable<MidElementCtorArg> args)
: base(range, new MidElementType(element))
{
_element = element;
_args = args.ToArray();
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:MidElementDecl.cs
示例18: MidBuiltinApp
public MidBuiltinApp(
SourceRange range,
MidBuiltinMethodDecl decl,
IEnumerable<MidVal> args)
: base(range, decl.ResultType)
{
_decl = decl;
_args = args.ToArray();
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:MidMethodDecl.cs
示例19: MidBreakExp
public MidBreakExp(
SourceRange range,
MidLabel label,
MidVal value)
: base(range, new MidVoidType())
{
_label = label;
_value = value;
}
开发者ID:spark-shading-language,项目名称:spark,代码行数:9,代码来源:MidLabel.cs
示例20: CompilationError
public CompilationError(SourceRange sourceRange, ErrorId id, string text)
{
if (text == null)
throw ExceptionBuilder.ArgumentNull("text");
_sourceRange = sourceRange;
_id = id;
_text = text;
}
开发者ID:chenzuo,项目名称:nquery,代码行数:9,代码来源:CompilationError.cs
注:本文中的SourceRange类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论