mirror of
https://github.com/github/codeql.git
synced 2026-05-05 05:35:13 +02:00
C#: Add support for the global modifier for using directives.
This commit is contained in:
@@ -47,6 +47,11 @@ namespace Semmle.Extraction.CSharp.Entities
|
||||
trapFile.using_directive_location(this, Context.CreateLocation(ReportingLocation));
|
||||
}
|
||||
|
||||
if (node.GlobalKeyword.Kind() == SyntaxKind.GlobalKeyword)
|
||||
{
|
||||
trapFile.using_global(this);
|
||||
}
|
||||
|
||||
if (parent is not null)
|
||||
{
|
||||
trapFile.parent_namespace_declaration(this, parent);
|
||||
|
||||
@@ -371,6 +371,9 @@ namespace Semmle.Extraction.CSharp
|
||||
internal static void using_static_directives(this TextWriter trapFile, UsingDirective @using, Type type) =>
|
||||
trapFile.WriteTuple("using_static_directives", @using, type);
|
||||
|
||||
internal static void using_global(this TextWriter trapFile, UsingDirective @using) =>
|
||||
trapFile.WriteTuple("using_global", @using);
|
||||
|
||||
internal static void preprocessor_directive_location<TDirective>(this TextWriter trapFile,
|
||||
PreprocessorDirective<TDirective> directive, Location location)
|
||||
where TDirective : DirectiveTriviaSyntax =>
|
||||
|
||||
@@ -36,6 +36,9 @@ class UsingDirective extends Element, @using_directive {
|
||||
}
|
||||
|
||||
override Location getALocation() { using_directive_location(this, result) }
|
||||
|
||||
/** Holds if this directive is `global`. */
|
||||
predicate isGlobal() { using_global(this) }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -324,6 +324,10 @@ parent_namespace_declaration(
|
||||
|
||||
@using_directive = @using_namespace_directive | @using_static_directive;
|
||||
|
||||
using_global(
|
||||
unique int id: @using_directive ref
|
||||
);
|
||||
|
||||
using_namespace_directives(
|
||||
unique int id: @using_namespace_directive,
|
||||
int namespace_id: @namespace ref);
|
||||
|
||||
Reference in New Issue
Block a user