139 references to GlobalStatementSyntax
Microsoft.CodeAnalysis.CSharp (27)
Binder\Binder_Statements.cs (1)
3659
if (statement is
GlobalStatementSyntax
topLevelStatement)
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
103
public override Binder VisitGlobalStatement(
GlobalStatementSyntax
node)
Binder\LocalBinderFactory.cs (1)
526
public override void VisitGlobalStatement(
GlobalStatementSyntax
node)
Binder\ScriptLocalScopeBinder.cs (1)
88
LocalScopeBinder.BuildLabels(scriptInitializer, ((
GlobalStatementSyntax
)member).Statement, ref builder);
Binder\SimpleProgramBinder.cs (3)
32
if (statement is
GlobalStatementSyntax
topLevelStatement)
47
if (statement is
GlobalStatementSyntax
topLevelStatement)
70
if (statement is
GlobalStatementSyntax
topLevelStatement)
Compilation\CSharpCompilation.cs (3)
787
if (root.DescendantNodes(n => n is
GlobalStatementSyntax
|| n is StatementSyntax || n is CompilationUnitSyntax).Any(n => n.IsKind(SyntaxKind.ReturnStatement)))
793
var
lastGlobalStatement = (
GlobalStatementSyntax
?)root.Members.LastOrDefault(m => m.IsKind(SyntaxKind.GlobalStatement));
Compilation\CSharpSemanticModel.cs (1)
2404
case
GlobalStatementSyntax
globalStatement:
Compilation\SyntaxTreeSemanticModel.cs (3)
938
if (SyntaxFacts.IsSimpleProgramTopLevelStatement((
GlobalStatementSyntax
)memberDecl))
2216
bool isGlobalStatement = firstStatement.Parent is
GlobalStatementSyntax
;
2217
if (isGlobalStatement && (lastStatement.Parent is not
GlobalStatementSyntax
|| firstStatement.Parent.Parent != lastStatement.Parent.Parent))
Declarations\DeclarationTreeBuilder.cs (4)
144
GlobalStatementSyntax
firstGlobalStatement = null;
157
var
global = (
GlobalStatementSyntax
)member;
232
private static SingleNamespaceOrTypeDeclaration CreateSimpleProgram(
GlobalStatementSyntax
firstGlobalStatement, bool hasAwaitExpressions, bool isIterator, bool hasReturnWithExpression, ImmutableArray<Diagnostic> diagnostics)
Symbols\Source\SourceMemberContainerSymbol.cs (2)
5201
var globalStatement = ((
GlobalStatementSyntax
)m).Statement;
5248
else if (reportMisplacedGlobalCode && !SyntaxFacts.IsSimpleProgramTopLevelStatement((
GlobalStatementSyntax
)m))
Symbols\Synthesized\SynthesizedSimpleProgramEntryPointSymbol.cs (1)
266
foreach (var global in ((CompilationUnitSyntax)tree.GetRoot(cancellationToken)).Members.OfType<
GlobalStatementSyntax
>())
Syntax\GlobalStatementSyntax.cs (1)
9
public
GlobalStatementSyntax
Update(StatementSyntax statement)
Syntax\InternalSyntax\ContextAwareSyntax.cs (1)
11
public
GlobalStatementSyntax
GlobalStatement(StatementSyntax statement)
Syntax\SyntaxFactory.cs (2)
2373
var
globalStatement = (
GlobalStatementSyntax
)lastNode;
Syntax\SyntaxFacts.cs (2)
533
internal static bool IsTopLevelStatement([NotNullWhen(true)]
GlobalStatementSyntax
? syntax)
538
internal static bool IsSimpleProgramTopLevelStatement(
GlobalStatementSyntax
? syntax)
Microsoft.CodeAnalysis.CSharp.CodeStyle (15)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_ProgramMain.cs (2)
63
return root.Members.OfType<
GlobalStatementSyntax
>().First().GetFirstToken().GetLocation();
72
TextSpan.FromBounds(start, root.Members.OfType<
GlobalStatementSyntax
>().Last().FullSpan.End));
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
258
if (parent is
GlobalStatementSyntax
)
273
return compilationUnit.Members.OfType<
GlobalStatementSyntax
>().Last().Statement;
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (2)
183
n => n is BlockSyntax or ArrowExpressionClauseSyntax or AnonymousFunctionExpressionSyntax or
GlobalStatementSyntax
);
184
if (outermostBody is null or
GlobalStatementSyntax
)
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (2)
28
case
GlobalStatementSyntax
globalStatement:
40
if (member is not
GlobalStatementSyntax
currentGlobalStatement)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (1)
110
var searchScope = localDeclaration.Parent is
GlobalStatementSyntax
globalStatement
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (1)
13
=> compilationUnit.Members is [
GlobalStatementSyntax
, ..];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (1)
360
case
GlobalStatementSyntax
:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
33
GlobalStatementSyntax
globalStatement => globalStatement.Parent,
43
CompilationUnitSyntax compilationUnit => compilationUnit.Members.OfType<
GlobalStatementSyntax
>().SelectAsArray(globalStatement => globalStatement.Statement),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (2)
236
=> node is
GlobalStatementSyntax
;
239
=> ((
GlobalStatementSyntax
)node).Statement;
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (7)
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (2)
175
editor.RemoveNode(localDeclarationStatement.Parent is
GlobalStatementSyntax
globalStatement
249
return compilationUnit.Members.OfType<
GlobalStatementSyntax
>().Select(g => g.Statement).ToImmutableArray();
src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (1)
57
editor.RemoveNode(localFunction.Parent is
GlobalStatementSyntax
globalStatement ? globalStatement : localFunction);
src\Analyzers\CSharp\CodeFixes\UseSimpleUsingStatement\UseSimpleUsingStatementCodeFixProvider.cs (2)
51
var blockLikes = topmostUsingStatements.Select(u => u.Parent is
GlobalStatementSyntax
? u.Parent.GetRequiredParent() : u.GetRequiredParent()).ToSet();
112
compilationUnit.Members.ReplaceRange((
GlobalStatementSyntax
)usingStatement.GetRequiredParent(), expandedUsingStatements.Select(GlobalStatement))),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
118
if (destination is
GlobalStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
219
var globalStatement = token.GetAncestor<
GlobalStatementSyntax
>();
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (1)
Semantics\PatternMatchingTestBase.cs (1)
428
Assert.Empty(tree.GetRoot().DescendantNodes().OfType<
GlobalStatementSyntax
>());
Microsoft.CodeAnalysis.CSharp.Features (49)
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (1)
50
if (container == null || container is
GlobalStatementSyntax
or FieldDeclarationSyntax or EventFieldDeclarationSyntax)
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (1)
353
if (newLocalDeclaration?.Parent is
GlobalStatementSyntax
globalStatement)
CodeRefactorings\NodeSelectionHelpers.cs (2)
43
IncompleteMemberSyntax or
GlobalStatementSyntax
=> [],
61
return members.Any(m => m is
GlobalStatementSyntax
or IncompleteMemberSyntax)
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (5)
44
var newRoot = root.RemoveNodes(root.Members.OfType<
GlobalStatementSyntax
>().Skip(1), SyntaxGenerator.DefaultRemoveOptions);
53
var
firstGlobalStatement = newRoot.Members.OfType<
GlobalStatementSyntax
>().Single();
127
foreach (
var
globalStatement in root.Members.OfType<
GlobalStatementSyntax
>())
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (2)
153
private static ImmutableArray<
GlobalStatementSyntax
> GetGlobalStatements(
230
var globalStatements = new FixedSizeArrayBuilder<
GlobalStatementSyntax
>(statements.Count);
Debugging\CSharpProximityExpressionsService.Worker.cs (1)
120
&& _parentStatement.Parent is
GlobalStatementSyntax
{ Parent: CompilationUnitSyntax compilationUnit } globalStatement
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (1)
1622
var globalStatements = unit.Members.OfType<
GlobalStatementSyntax
>();
EditAndContinue\DeclarationBody\TopLevelCodeDeclarationBody.cs (3)
23
private IEnumerable<
GlobalStatementSyntax
> GlobalStatements
24
=> unit.Members.OfType<
GlobalStatementSyntax
>();
30
=> model.AnalyzeDataFlow(((
GlobalStatementSyntax
)unit.Members[0]).Statement, GlobalStatements.Last().Statement)!.CapturedInside;
EditAndContinue\SyntaxUtilities.cs (1)
134
=> compilationUnit.Members is [
GlobalStatementSyntax
, ..];
ExtractMethod\CSharpMethodExtractor.cs (4)
50
var globalStatement = root.FindToken(originalSpanStart).GetAncestor<
GlobalStatementSyntax
>();
96
if (currentNode is
GlobalStatementSyntax
globalStatement)
124
if (memberNode is
GlobalStatementSyntax
globalStatement)
130
SyntaxNode GetInsertionPointForGlobalStatement(
GlobalStatementSyntax
globalStatement, MemberDeclarationSyntax memberNode)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
345
public override SyntaxNode VisitGlobalStatement(
GlobalStatementSyntax
node)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.MultipleStatementsCodeGenerator.cs (2)
74
GlobalStatementSyntax
globalStatement => ((CompilationUnitSyntax)globalStatement.Parent).Members.OfType<
GlobalStatementSyntax
>().Select(globalStatement => globalStatement.Statement),
ExtractMethod\CSharpSelectionResult.cs (1)
128
if (container is
GlobalStatementSyntax
)
ExtractMethod\CSharpSelectionValidator.cs (2)
138
if (current is
GlobalStatementSyntax
)
299
case
GlobalStatementSyntax
:
ExtractMethod\CSharpSelectionValidator.Validator.cs (1)
21
GlobalStatementSyntax
_ => CheckGlobalStatement(),
ExtractMethod\Extensions.cs (2)
39
=> node is BlockSyntax or SwitchSectionSyntax or
GlobalStatementSyntax
;
70
GlobalStatementSyntax
or
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (5)
36
var globalStatement = expression.GetAncestor<
GlobalStatementSyntax
>();
291
? scope.ChildNodes().OfType<
GlobalStatementSyntax
>()
322
var
firstAffectedGlobalStatement = compilationUnit.Members.OfType<
GlobalStatementSyntax
>().Single(s => firstAffectedExpression.GetAncestorOrThis<
GlobalStatementSyntax
>().Contains(s));
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_ProgramMain.cs (2)
63
return root.Members.OfType<
GlobalStatementSyntax
>().First().GetFirstToken().GetLocation();
72
TextSpan.FromBounds(start, root.Members.OfType<
GlobalStatementSyntax
>().Last().FullSpan.End));
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (2)
258
if (parent is
GlobalStatementSyntax
)
273
return compilationUnit.Members.OfType<
GlobalStatementSyntax
>().Last().Statement;
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryLambdaExpression\CSharpRemoveUnnecessaryLambdaExpressionDiagnosticAnalyzer.cs (2)
183
n => n is BlockSyntax or ArrowExpressionClauseSyntax or AnonymousFunctionExpressionSyntax or
GlobalStatementSyntax
);
184
if (outermostBody is null or
GlobalStatementSyntax
)
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\RemoveUnreachableCodeHelpers.cs (2)
28
case
GlobalStatementSyntax
globalStatement:
40
if (member is not
GlobalStatementSyntax
currentGlobalStatement)
src\Analyzers\CSharp\Analyzers\UseDeconstruction\CSharpUseDeconstructionDiagnosticAnalyzer.cs (1)
110
var searchScope = localDeclaration.Parent is
GlobalStatementSyntax
globalStatement
src\Analyzers\CSharp\CodeFixes\InlineDeclaration\CSharpInlineDeclarationCodeFixProvider.cs (2)
175
editor.RemoveNode(localDeclarationStatement.Parent is
GlobalStatementSyntax
globalStatement
249
return compilationUnit.Members.OfType<
GlobalStatementSyntax
>().Select(g => g.Statement).ToImmutableArray();
src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (1)
57
editor.RemoveNode(localFunction.Parent is
GlobalStatementSyntax
globalStatement ? globalStatement : localFunction);
src\Analyzers\CSharp\CodeFixes\UseSimpleUsingStatement\UseSimpleUsingStatementCodeFixProvider.cs (2)
51
var blockLikes = topmostUsingStatements.Select(u => u.Parent is
GlobalStatementSyntax
? u.Parent.GetRequiredParent() : u.GetRequiredParent()).ToSet();
112
compilationUnit.Members.ReplaceRange((
GlobalStatementSyntax
)usingStatement.GetRequiredParent(), expandedUsingStatements.Select(GlobalStatement))),
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (11)
Semantics\ScriptSemanticsTests.cs (4)
493
Members[0] as
GlobalStatementSyntax
).
522
var statements = root.ChildNodes().Select(n => ((
GlobalStatementSyntax
)n).Statement).ToArray();
1390
var
node2 = (
GlobalStatementSyntax
)node1.Members.First();
Semantics\TopLevelStatementsTests.cs (7)
257
foreach (
var
globalStatement in tree1.GetRoot().DescendantNodes().OfType<
GlobalStatementSyntax
>())
408
foreach (
var
globalStatement in tree1.GetRoot().DescendantNodes().OfType<
GlobalStatementSyntax
>())
6438
var
globalStatement = (
GlobalStatementSyntax
)context.Node;
9707
model.TryGetSpeculativeSemanticModel(root.DescendantNodes().Single(n => n is ExpressionStatementSyntax { Parent:
GlobalStatementSyntax
}).Span.End, nodeToSpeculate, out var speculativeModelInTopLevel);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (3)
Compilation\GetSemanticInfoTests.cs (2)
1137
var
stmt = (
GlobalStatementSyntax
)root.Members.Single();
Symbols\ExtensionMethodTests.cs (1)
2431
var expr = ((ExpressionStatementSyntax)((
GlobalStatementSyntax
)tree.GetCompilationUnitRoot().Members[0]).Statement).Expression;
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (14)
Generated\Syntax.Test.xml.Generated.cs (5)
10550
private static
GlobalStatementSyntax
GenerateGlobalStatement()
12225
var
node = GenerateGlobalStatement();
12230
var
newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithStatement(node.Statement);
16881
var
oldNode = GenerateGlobalStatement();
16897
var
oldNode = GenerateGlobalStatement();
IncrementalParsing\BinaryExpression.cs (2)
216
var
statementType = newTree.GetCompilationUnitRoot().Members[0] as
GlobalStatementSyntax
;
IncrementalParsing\CompoundAssignment.cs (2)
156
var
statementType = newTree.GetCompilationUnitRoot().Members[0] as
GlobalStatementSyntax
;
IncrementalParsing\UnaryExpression.cs (2)
99
var
statementType = newTree.GetCompilationUnitRoot().Members[0] as
GlobalStatementSyntax
;
Parsing\ParsingErrorRecoveryTests.cs (2)
7300
var
globalStatement = (
GlobalStatementSyntax
)file.ChildNodesAndTokens()[0];
Syntax\SyntaxNodeTests.cs (1)
3331
var method = (LocalFunctionStatementSyntax)((
GlobalStatementSyntax
)root.Members[0]).Statement;
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CSharpTestBase.cs (1)
1337
bool hasTopLevelStatements = syntaxTrees.Any(s => s.GetRoot().ChildNodes().OfType<
GlobalStatementSyntax
>().Any());
Microsoft.CodeAnalysis.CSharp.Workspaces (11)
LanguageServices\FixAllSpanMappingService\CSharpFixAllSpanMappingService.cs (2)
33
if (node.GetAncestorOrThis<
GlobalStatementSyntax
>() is null)
45
var globalStatements = root.ChildNodes().OfType<
GlobalStatementSyntax
>();
ReassignedVariable\CSharpReassignedVariableService.cs (1)
52
return current is
GlobalStatementSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (1)
13
=> compilationUnit.Members is [
GlobalStatementSyntax
, ..];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (1)
360
case
GlobalStatementSyntax
:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpBlockFacts.cs (2)
33
GlobalStatementSyntax
globalStatement => globalStatement.Parent,
43
CompilationUnitSyntax compilationUnit => compilationUnit.Members.OfType<
GlobalStatementSyntax
>().SelectAsArray(globalStatement => globalStatement.Statement),
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (2)
236
=> node is
GlobalStatementSyntax
;
239
=> ((
GlobalStatementSyntax
)node).Statement;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (1)
118
if (destination is
GlobalStatementSyntax
)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
219
var globalStatement = token.GetAncestor<
GlobalStatementSyntax
>();