本文整理汇总了C#中SourceLocation类的典型用法代码示例。如果您正苦于以下问题:C# SourceLocation类的具体用法?C# SourceLocation怎么用?C# SourceLocation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SourceLocation类属于命名空间,在下文中一共展示了SourceLocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Selector
public Selector(string selector,SourceLocation sourceLocation) {
AfterTheParameter = null;
// parse up to the first square bracket.
if (string.IsNullOrEmpty(selector)) {
Name = string.Empty;
Parameter = null;
} else {
selector = selector.TrimStart('.');
var p = selector.IndexOf('[');
var c = selector.IndexOf(']', p + 1);
if (p == -1) {
Name = selector;
Parameter = null;
} else {
Name = p == 0 ? "*" : selector.Substring(0, p);
p++;
Parameter = selector.Substring(p, c - p).Trim();
if(c < selector.Length) {
AfterTheParameter = selector.Substring(c + 1);
}
}
}
SourceLocation = sourceLocation;
_hashCode = AfterTheParameter == null ? this.CreateHashCode(Name, Parameter) : this.CreateHashCode(Name,Parameter,AfterTheParameter);
}
示例2: CheckStatics
public void CheckStatics()
{
SourceLocation min = new SourceLocation(0, 0);
SourceLocation max = new SourceLocation(SourceLocation.MaxColumn, SourceLocation.MaxLine);
Assert.AreEqual(min, SourceLocation.MinValue);
Assert.AreEqual(max, SourceLocation.MaxValue);
}
示例3: BinaryOperationNode
public BinaryOperationNode(SourceLocation location, BinaryOperation operation, AstNode left, AstNode right)
{
this.SourceLocation = location;
BinaryOperation = operation;
Children.Add(left);
Children.Add(right);
}
示例4: Resolve
/// <summary>
/// Loads an <see cref="Assembly"/> using the given <paramref name="name"/> and resolves
/// all valid <see cref="ITagHelper"/> <see cref="Type"/>s.
/// </summary>
/// <param name="name">The name of an <see cref="Assembly"/> to search.</param>
/// <param name="documentLocation">The <see cref="SourceLocation"/> of the associated
/// <see cref="Parser.SyntaxTree.SyntaxTreeNode"/> responsible for the current <see cref="Resolve"/> call.
/// </param>
/// <param name="errorSink">The <see cref="ErrorSink"/> used to record errors found when resolving
/// <see cref="ITagHelper"/> <see cref="Type"/>s.</param>
/// <returns>An <see cref="IEnumerable{Type}"/> of valid <see cref="ITagHelper"/> <see cref="Type"/>s.
/// </returns>
public IEnumerable<Type> Resolve(string name,
SourceLocation documentLocation,
[NotNull] ErrorSink errorSink)
{
if (string.IsNullOrEmpty(name))
{
errorSink.OnError(documentLocation,
Resources.TagHelperTypeResolver_TagHelperAssemblyNameCannotBeEmptyOrNull);
return Type.EmptyTypes;
}
var assemblyName = new AssemblyName(name);
IEnumerable<TypeInfo> libraryTypes;
try
{
libraryTypes = GetExportedTypes(assemblyName);
}
catch (Exception ex)
{
errorSink.OnError(
documentLocation,
Resources.FormatTagHelperTypeResolver_CannotResolveTagHelperAssembly(
assemblyName.Name,
ex.Message));
return Type.EmptyTypes;
}
var validTagHelpers = libraryTypes.Where(IsTagHelper);
// Convert from TypeInfo[] to Type[]
return validTagHelpers.Select(type => type.AsType());
}
示例5: Resolve_CalculatesAssemblyLocationInLookupText
public void Resolve_CalculatesAssemblyLocationInLookupText(string lookupText, int assemblyLocation)
{
// Arrange
var errorSink = new ErrorSink();
var tagHelperDescriptorResolver = new InspectableTagHelperDescriptorResolver();
var directiveType = TagHelperDirectiveType.AddTagHelper;
var resolutionContext = new TagHelperDescriptorResolutionContext(
new[]
{
new TagHelperDirectiveDescriptor
{
DirectiveText = lookupText,
Location = SourceLocation.Zero,
DirectiveType = directiveType
}
},
errorSink);
var expectedSourceLocation = new SourceLocation(assemblyLocation, 0, assemblyLocation);
// Act
tagHelperDescriptorResolver.Resolve(resolutionContext);
// Assert
Assert.Empty(errorSink.Errors);
Assert.Equal(expectedSourceLocation, tagHelperDescriptorResolver.DocumentLocation);
}
示例6: MethodParameterInfoContext
public MethodParameterInfoContext(SourceLocation sourceLocation, int parameterIndex, Scope scope, Type expressionType, Identifier methodName)
: base(sourceLocation, parameterIndex)
{
_scope = scope;
_expressionType = expressionType;
_methodName = methodName;
}
示例7: highlightSourceAtLocation
/// <summary>
/// Render a helpful description of the location of the error in the GraphQL
/// Source document.
/// </summary>
private static string highlightSourceAtLocation(Source source, SourceLocation location)
{
var line = location.Line;
var prevLineNum = (line - 1).ToString();
var lineNum = line.ToString();
var nextLineNum = (line + 1).ToString();
var padLen = nextLineNum.Length;
var lines = _lineSplitter.Split(source.Body);
var errorMessage = new StringBuilder();
if (line >= 2)
{
errorMessage.AppendLine(prevLineNum.PadLeft(padLen, ' ') + ": " + lines[line - 2]);
}
else
{
errorMessage.AppendLine();
}
errorMessage.AppendLine(lineNum.PadLeft(padLen, ' ') + ": " + lines[line - 1]);
errorMessage.AppendLine(new String(' ', padLen + location.Column) + "^");
if (line < lines.Length)
{
errorMessage.AppendLine(nextLineNum.PadLeft(padLen, ' ') + ": " + lines[line]);
}
else
{
errorMessage.AppendLine();
}
return errorMessage.ToString();
}
示例8: TableContext
public TableContext(SourceLocation sourceLocation, Identifier remainingPart, Scope scope, TableBinding tableBinding, string correlationName)
: base(sourceLocation, remainingPart)
{
_scope = scope;
_tableBinding = tableBinding;
_correlationName = correlationName;
}
示例9: TryCatchFinally
public static TryStatement TryCatchFinally(SourceSpan span, SourceLocation header, Statement body, CatchBlock[] handlers, Statement @finally)
{
return new TryStatement(
span, header,
body, CollectionUtils.ToReadOnlyCollection(handlers), @finally
);
}
示例10: Switch
public static SwitchStatement Switch(SourceSpan span, SourceLocation header, Expression value, params SwitchCase[] cases)
{
Contract.RequiresNotNull(value, "value");
Contract.Requires(value.Type == typeof(int), "value", "Value must be int");
Contract.RequiresNotEmpty(cases, "cases");
Contract.RequiresNotNullItems(cases, "cases");
bool @default = false;
int max = Int32.MinValue;
int min = Int32.MaxValue;
foreach (SwitchCase sc in cases) {
if (sc.IsDefault) {
Contract.Requires(@default == false, "cases", "Only one default clause allowed");
@default = true;
} else {
int val = sc.Value;
if (val > max) max = val;
if (val < min) min = val;
}
}
Contract.Requires(UniqueCaseValues(cases, min, max), "cases", "Case values must be unique");
return new SwitchStatement(span, header, value, CollectionUtils.ToReadOnlyCollection(cases));
}
示例11: UseStatement
public UseStatement (SourceLocation location, string module, bool relative = false)
: base (location)
{
Module = module;
Relative = relative;
Imports = new List<string> ();
}
示例12: SwitchCase
internal SwitchCase(SourceLocation header, bool @default, int value, Statement body)
: base(AstNodeType.SwitchCase) {
_header = header;
_default = @default;
_value = value;
_body = body;
}
示例13: CaseExpression
public CaseExpression (SourceLocation location, AstNode pattern, AstNode condition, AstNode value)
: base (location)
{
Children.Add (pattern);
Children.Add (condition);
Children.Add (value);
}
示例14: IfNode
public IfNode(SourceLocation location, AstNode predicate, AstNode body, AstNode elseBody)
{
this.SourceLocation = location;
Children.Add(predicate);
Children.Add(body);
Children.Add(elseBody);
}
示例15: ForeachStatement
public ForeachStatement (SourceLocation location, string item, AstNode iterator, AstNode body)
: base (location)
{
this.Item = item;
this.Add (iterator);
this.Add (body);
}