C#: Add support for the global modifier for using directives.

This commit is contained in:
Michael Nebel
2022-01-10 15:17:39 +01:00
parent e305a8a6c5
commit c118d9bf6f
4 changed files with 15 additions and 0 deletions

View File

@@ -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);

View File

@@ -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 =>

View File

@@ -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) }
}
/**

View File

@@ -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);