本文整理汇总了C#中SyntaxReference类的典型用法代码示例。如果您正苦于以下问题:C# SyntaxReference类的具体用法?C# SyntaxReference怎么用?C# SyntaxReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SyntaxReference类属于命名空间,在下文中一共展示了SyntaxReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SourceStrictComplexParameterSymbol
internal SourceStrictComplexParameterSymbol(
DiagnosticBag diagnostics,
Binder binder,
Symbol owner,
int ordinal,
TypeSymbol parameterType,
RefKind refKind,
string name,
ImmutableArray<Location> locations,
SyntaxReference syntaxRef,
ConstantValue defaultSyntaxValue,
bool isParams,
bool isExtensionMethodThis)
: base(
owner: owner,
ordinal: ordinal,
parameterType: parameterType,
refKind: refKind,
name: name,
locations: locations,
syntaxRef: syntaxRef,
defaultSyntaxValue: defaultSyntaxValue,
isParams: isParams,
isExtensionMethodThis: isExtensionMethodThis)
{
_tempBinder = binder;
var unused = GetAttributesBag(diagnostics);
_lazyDefaultSyntaxValue = MakeDefaultExpression(diagnostics, binder);
_tempBinder = null; // no need to keep it around anymore, just uses up a lot of memory
}
示例2: GetOrComputeDeclarationAnalysisData
internal DeclarationAnalysisData GetOrComputeDeclarationAnalysisData(
SyntaxReference declaration,
Func<Func<DeclarationAnalysisData>, DeclarationAnalysisData> computeDeclarationAnalysisData,
bool cacheAnalysisData)
{
if (!cacheAnalysisData)
{
return computeDeclarationAnalysisData(_declarationAnalysisDataPool.Allocate);
}
DeclarationAnalysisData data;
lock (_declarationAnalysisDataMap)
{
if (_declarationAnalysisDataMap.TryGetValue(declaration, out data))
{
return data;
}
}
data = computeDeclarationAnalysisData(_declarationAnalysisDataPool.Allocate);
lock (_declarationAnalysisDataMap)
{
_declarationAnalysisDataMap[declaration] = data;
}
return data;
}
示例3: TypeParameterBuilder
internal TypeParameterBuilder(SyntaxReference syntaxRef, SourceNamedTypeSymbol owner, Location location)
{
this.syntaxRef = syntaxRef;
Debug.Assert(syntaxRef.GetSyntax().IsKind(SyntaxKind.TypeParameter));
this.owner = owner;
this.location = location;
}
示例4: SourceAttributeData
internal SourceAttributeData(
SyntaxReference applicationNode,
NamedTypeSymbol attributeClass,
MethodSymbol attributeConstructor,
ImmutableArray<TypedConstant> constructorArguments,
ImmutableArray<int> constructorArgumentsSourceIndices,
ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments,
bool hasErrors,
bool isConditionallyOmitted)
{
Debug.Assert(!isConditionallyOmitted || (object)attributeClass != null && attributeClass.IsConditional);
Debug.Assert(!constructorArguments.IsDefault);
Debug.Assert(!namedArguments.IsDefault);
Debug.Assert(constructorArgumentsSourceIndices.IsDefault ||
constructorArgumentsSourceIndices.Any() && constructorArgumentsSourceIndices.Length == constructorArguments.Length);
this.attributeClass = attributeClass;
this.attributeConstructor = attributeConstructor;
this.constructorArguments = constructorArguments;
this.constructorArgumentsSourceIndices = constructorArgumentsSourceIndices;
this.namedArguments = namedArguments;
this.isConditionallyOmitted = isConditionallyOmitted;
this.hasErrors = hasErrors;
this.applicationNode = applicationNode;
}
示例5: SingleNamespaceOrTypeDeclaration
protected SingleNamespaceOrTypeDeclaration(
string name,
SyntaxReference syntaxReference,
SourceLocation nameLocation)
: base(name)
{
this.syntaxReference = syntaxReference;
this.nameLocation = nameLocation;
}
示例6: SourceEventAccessorSymbol
public SourceEventAccessorSymbol(
SourceEventSymbol @event,
SyntaxReference syntaxReference,
SyntaxReference blockSyntaxReference,
ImmutableArray<Location> locations)
: base(@event.containingType, syntaxReference, blockSyntaxReference, locations)
{
[email protected] = @event;
}
示例7: SingleNamespaceDeclaration
protected SingleNamespaceDeclaration(
string name,
SyntaxReference syntaxReference,
SourceLocation nameLocation,
ImmutableArray<SingleNamespaceOrTypeDeclaration> children)
: base(name, syntaxReference, nameLocation)
{
this.children = children;
}
示例8: SourceMemberFieldSymbol
internal SourceMemberFieldSymbol(
SourceMemberContainerTypeSymbol containingType,
DeclarationModifiers modifiers,
string name,
SyntaxReference syntax,
Location location)
: base(containingType, name, syntax, location)
{
_modifiers = modifiers;
}
示例9: GlobalExpressionVariable
internal GlobalExpressionVariable(
SourceMemberContainerTypeSymbol containingType,
DeclarationModifiers modifiers,
TypeSyntax typeSyntax,
string name,
SyntaxReference syntax,
Location location)
: base(containingType, modifiers, name, syntax, location)
{
Debug.Assert(DeclaredAccessibility == Accessibility.Private);
_typeSyntax = typeSyntax.GetReference();
}
示例10: SourceFieldSymbol
protected SourceFieldSymbol(SourceMemberContainerTypeSymbol containingType, string name, SyntaxReference syntax, Location location)
{
Debug.Assert((object)containingType != null);
Debug.Assert(name != null);
Debug.Assert(syntax != null);
Debug.Assert(location != null);
this.containingType = containingType;
this.name = name;
this.syntaxReference = syntax;
this.location = location;
}
示例11: ImplicitTypeDeclaration
/// <summary>
/// Script class declaration constructor.
/// </summary>
internal ImplicitTypeDeclaration(SyntaxReference memberContainer, ReadOnlyArray<SingleTypeDeclaration> children, ISet<string> memberNames, string name) :
base(
kind: DeclarationKind.Class,
name: name,
arity: 0,
modifiers: DeclarationModifiers.Internal | DeclarationModifiers.Partial | DeclarationModifiers.Sealed,
syntaxReference: memberContainer,
nameLocation: new SourceLocation(memberContainer),
memberNames: memberNames,
children: children)
{
}
示例12: RetargetingAttributeData
internal RetargetingAttributeData(
SyntaxReference applicationNode,
NamedTypeSymbol attributeClass,
MethodSymbol attributeConstructor,
ImmutableArray<TypedConstant> constructorArguments,
ImmutableArray<int> constructorArgumentsSourceIndices,
ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments,
bool hasErrors,
bool isConditionallyOmitted)
: base(applicationNode, attributeClass, attributeConstructor, constructorArguments, constructorArgumentsSourceIndices, namedArguments, hasErrors, isConditionallyOmitted)
{
}
示例13: Translate
protected override SyntaxNode Translate(SyntaxReference reference, CancellationToken cancellationToken)
{
var node = (CSharpSyntaxNode)reference.GetSyntax(cancellationToken);
// If the node is a name syntax, it's something like "X" or "X.Y" in :
// namespace X.Y.Z
// We want to return the full NamespaceDeclarationSyntax.
while (node is NameSyntax)
{
node = node.Parent;
}
Debug.Assert(node is CompilationUnitSyntax || node is NamespaceDeclarationSyntax);
return node;
}
示例14: EvaluateFieldConstant
public static EvaluatedConstant EvaluateFieldConstant(this FieldSymbol symbol, SyntaxReference equalsValueNodeRef, ConstantFieldsInProgress inProgress)
{
Debug.Assert(inProgress != null);
var diagnostics = DiagnosticBag.GetInstance();
try
{
ConstantValue value;
if (inProgress.Contains(symbol))
{
var errorField = inProgress.ErrorField;
diagnostics.Add(ErrorCode.ERR_CircConstValue, errorField.Locations[0], errorField);
value = Roslyn.Compilers.ConstantValue.Bad;
}
else
{
var compilation = ((SourceAssemblySymbol)symbol.ContainingAssembly).Compilation;
var binderFactory = compilation.GetBinderFactory(equalsValueNodeRef.SyntaxTree);
var newInProgress = inProgress.Add(symbol);
var equalsValueNode = (EqualsValueClauseSyntax)equalsValueNodeRef.GetSyntax();
var binder = binderFactory.GetBinder(equalsValueNode);
var inProgressBinder = new ConstantFieldsInProgressBinder(newInProgress, binder);
// CONSIDER: Compiler.BindFieldInitializer will make this same call on this same syntax node
// to determine the bound value for itself. We expect this binding to be fairly cheap
// (since constants tend to be simple) and it should only happen twice (regardless of the
// number of references to this constant). If this becomes a performance bottleneck,
// the re-binding can be eliminated by caching the BoundNode on this SourceFieldSymbol and
// checking for a cached value before binding (here and in Compiler.BindFieldInitializer).
var boundValue = inProgressBinder.BindVariableInitializer(equalsValueNode, symbol.Type, diagnostics);
var initValueNodeLocation = inProgressBinder.Location(equalsValueNode.Value);
value = ConstantValueUtils.GetAndValidateConstantValue(boundValue, symbol, symbol.Type, initValueNodeLocation, diagnostics);
}
return new EvaluatedConstant(value, diagnostics.Seal());
}
finally
{
diagnostics.Free();
}
}
示例15: RootSingleNamespaceDeclaration
public RootSingleNamespaceDeclaration(
bool hasUsings,
bool hasExternAliases,
SyntaxReference treeNode,
ImmutableArray<SingleNamespaceOrTypeDeclaration> children,
ImmutableArray<ReferenceDirective> referenceDirectives,
bool hasAssemblyAttributes)
: base(string.Empty,
treeNode,
nameLocation: new SourceLocation(treeNode),
children: children)
{
Debug.Assert(!referenceDirectives.IsDefault);
_referenceDirectives = referenceDirectives;
_hasAssemblyAttributes = hasAssemblyAttributes;
_hasUsings = hasUsings;
_hasExternAliases = hasExternAliases;
}