Move location-like entities to the Semmle.Extraction.CSharp namespace

This commit is contained in:
Tamas Vajk
2024-11-13 14:24:08 +01:00
parent e7844e2855
commit b7098b72a4
50 changed files with 122 additions and 138 deletions

View File

@@ -0,0 +1,35 @@
using Microsoft.CodeAnalysis;
namespace Semmle.Extraction
{
public static class CachedEntityFactoryExtensions
{
/// <summary>
/// Creates and populates a new entity, or returns the existing one from the cache,
/// based on the supplied cache key.
/// </summary>
/// <typeparam name="TInit">The type used to construct the entity.</typeparam>
/// <typeparam name="TEntity">The type of the entity to create.</typeparam>
/// <param name="factory">The factory used to construct the entity.</param>
/// <param name="cx">The extractor context.</param>
/// <param name="cacheKey">The key used for caching.</param>
/// <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);
/// <summary>
/// Creates and populates a new entity from an `ISymbol`, or returns the existing one
/// from the cache.
/// </summary>
/// <typeparam name="TSymbol">The type used to construct the entity.</typeparam>
/// <typeparam name="TEntity">The type of the entity to create.</typeparam>
/// <param name="factory">The factory used to construct the entity.</param>
/// <param name="cx">The extractor context.</param>
/// <param name="init">The initializer for the entity.</param>
/// <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);
}
}