Skip to content

Commit

Permalink
Move all classes to the Semmle.Extraction.CSharp namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tamasvajk committed Nov 14, 2024
1 parent a0cac46 commit 9057994
Show file tree
Hide file tree
Showing 25 changed files with 494 additions and 568 deletions.
1 change: 0 additions & 1 deletion csharp/extractor/Semmle.Extraction.CSharp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ load(
codeql_csharp_library(
name = "Semmle.Extraction.CSharp",
srcs = glob([
"_Base/**/*.cs",
"CodeAnalysisExtensions/**/*.cs",
"Comments/**/*.cs",
"Entities/**/*.cs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
using System.IO;
using Microsoft.CodeAnalysis;

namespace Semmle.Extraction
namespace Semmle.Extraction.CSharp.Entities
{
/// <summary>
/// A cached entity.
///
/// The <see cref="Entity.Id"/> property is used as label in caching.
/// </summary>
public abstract class CachedEntity : CSharp.LabelledEntity
public abstract class CachedEntity : LabelledEntity
{
protected CachedEntity(Context context) : base(context)
{
Expand Down Expand Up @@ -62,7 +62,7 @@ public override bool Equals(object? obj)
return other?.GetType() == GetType() && Equals(other.Symbol, Symbol);
}

public override CSharp.TrapStackBehaviour TrapStackBehaviour => CSharp.TrapStackBehaviour.NoLabel;
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Semmle.Extraction.CSharp
/// <summary>
/// A factory for creating cached entities.
/// </summary>
public abstract class CachedEntityFactory<TInit, TEntity> where TEntity : CachedEntity
public abstract class CachedEntityFactory<TInit, TEntity> where TEntity : Entities.CachedEntity
{
public abstract TEntity Create(Context cx, TInit init);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class CachedEntityFactoryExtensions
/// <param name="init">The initializer for the entity.</param>
/// <returns>The entity.</returns>
public static TEntity CreateEntity<TInit, TEntity>(this CachedEntityFactory<TInit, TEntity> factory, Context cx, object cacheKey, TInit init)
where TEntity : CachedEntity => cx.CreateEntity(factory, cacheKey, init);
where TEntity : Entities.CachedEntity => cx.CreateEntity(factory, cacheKey, init);

/// <summary>
/// Creates and populates a new entity from an `ISymbol`, or returns the existing one
Expand All @@ -30,6 +30,6 @@ public static TEntity CreateEntity<TInit, TEntity>(this CachedEntityFactory<TIni
/// <returns>The entity.</returns>
public static TEntity CreateEntityFromSymbol<TSymbol, TEntity>(this CachedEntityFactory<TSymbol, TEntity> factory, Context cx, TSymbol init)
where TSymbol : ISymbol
where TEntity : CachedEntity => cx.CreateEntityFromSymbol(factory, init);
where TEntity : Entities.CachedEntity => cx.CreateEntityFromSymbol(factory, init);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace Semmle.Extraction.CSharp
{
public abstract class Entity : IEntity
{
public virtual Semmle.Extraction.Context Context { get; }
public virtual Context Context { get; }

protected Entity(Semmle.Extraction.Context context)
protected Entity(Context context)
{
this.Context = context;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.IO;

namespace Semmle.Extraction
namespace Semmle.Extraction.CSharp.Entities
{
/// <summary>
/// An entity which has a default "*" ID assigned to it.
/// </summary>
public abstract class FreshEntity : CSharp.UnlabelledEntity
public abstract class FreshEntity : UnlabelledEntity
{
protected FreshEntity(Context cx) : base(cx)
{
Expand Down Expand Up @@ -33,6 +33,6 @@ public string DebugContents

public override Microsoft.CodeAnalysis.Location? ReportingLocation => null;

public override CSharp.TrapStackBehaviour TrapStackBehaviour => CSharp.TrapStackBehaviour.NoLabel;
public override TrapStackBehaviour TrapStackBehaviour => TrapStackBehaviour.NoLabel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Semmle.Extraction.CSharp
{
public abstract class LabelledEntity : Entity
{
protected LabelledEntity(Semmle.Extraction.Context cx) : base(cx)
protected LabelledEntity(Context cx) : base(cx)
{
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Semmle.Extraction.CSharp
{
public abstract class UnlabelledEntity : Entity
{
protected UnlabelledEntity(Extraction.Context cx) : base(cx)
protected UnlabelledEntity(Context cx) : base(cx)
{
cx.AddFreshLabel(this);
}
Expand Down
12 changes: 0 additions & 12 deletions csharp/extractor/Semmle.Extraction.CSharp/Entities/CachedEntity.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using Semmle.Extraction.Entities;

namespace Semmle.Extraction.CSharp.Entities
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.IO;
using System.Linq;
using Microsoft.CodeAnalysis;
using Semmle.Extraction.Entities;
using Semmle.Util;

namespace Semmle.Extraction.CSharp.Entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using System.IO;
using System.Threading;
using Semmle.Util;
using Semmle.Extraction.CSharp;

namespace Semmle.Extraction.Entities
namespace Semmle.Extraction.CSharp.Entities
{
internal class ExtractionMessage : FreshEntity
{
Expand Down Expand Up @@ -41,7 +40,7 @@ protected override void Populate(TextWriter trapFile)
if (val == limit + 1)
{
Context.ExtractionContext.Logger.LogWarning($"Stopped logging extractor messages after reaching {limit}");
_ = new ExtractionMessage(Context, new Message($"Stopped logging extractor messages after reaching {limit}", null, null, null, Util.Logging.Severity.Warning), bypassLimit: true);
_ = new ExtractionMessage(Context, new Message($"Stopped logging extractor messages after reaching {limit}", null, null, null, Semmle.Util.Logging.Severity.Warning), bypassLimit: true);
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Semmle.Extraction.CSharp.Entities.Expressions;
using Semmle.Extraction.Entities;
using Semmle.Extraction.Kinds;

namespace Semmle.Extraction.CSharp.Entities
Expand Down
12 changes: 0 additions & 12 deletions csharp/extractor/Semmle.Extraction.CSharp/Entities/FreshEntity.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Semmle.Extraction.CSharp.Entities
{
public class File : Extraction.CachedEntity<string>
public class File : CachedEntity<string>
{
protected readonly string originalPath;
private readonly Lazy<PathTransformer.ITransformedPath> transformedPathLazy;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Semmle.Extraction.CSharp.Entities
{
#nullable disable warnings
public abstract class Location : Extraction.CachedEntity<Microsoft.CodeAnalysis.Location?>
public abstract class Location : CachedEntity<Microsoft.CodeAnalysis.Location?>
{
#nullable restore warnings
protected Location(Context cx, Microsoft.CodeAnalysis.Location? init)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Semmle.Extraction.CSharp.Entities
{
internal class Modifier : Extraction.CachedEntity<string>
internal class Modifier : CachedEntity<string>
{
private Modifier(Context cx, string init)
: base(cx, init) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Semmle.Extraction.CSharp.Populators;
using Semmle.Extraction.Entities;

namespace Semmle.Extraction.CSharp.Entities
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using Microsoft.CodeAnalysis.CSharp;
using Semmle.Extraction.CSharp.Populators;
using Semmle.Extraction.Entities;

namespace Semmle.Extraction.CSharp.Entities
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.IO;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Semmle.Extraction.Entities;
using Semmle.Extraction.Kinds;

namespace Semmle.Extraction.CSharp.Entities.Statements
Expand Down
Loading

0 comments on commit 9057994

Please sign in to comment.