/// <summary> /// Initializes a new instance of the <see cref="T4LanguageService"/> class. /// </summary> /// <param name="t4Language">The T4 language.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> /// <param name="constantValueService">The constant value service.</param> /// <param name="t4Environment">An object describing the environment for T4 files.</param> public T4LanguageService([NotNull] T4Language t4Language, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] IConstantValueService constantValueService, [NotNull] T4Environment t4Environment) : base(t4Language, constantValueService) { _t4Environment = t4Environment; _directiveInfoManager = directiveInfoManager; }
internal T4Parser([NotNull] T4Environment t4Environment, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] ILexer lexer, [CanBeNull] IPsiSourceFile sourceFile) { _t4Environment = t4Environment; _directiveInfoManager = directiveInfoManager; _lexer = lexer; _sourceFile = sourceFile; }
public T4CodeStructureDirective( [NotNull] CodeStructureElement parent, [NotNull] IT4Directive directive, [NotNull] DirectiveInfoManager directiveInfoManager ) : base(parent, directive) { _directiveInfoManager = directiveInfoManager; }
/// <summary>Initializes a new instance of the <see cref="T4FileData"/> class.</summary> /// <param name="t4File">The T4 file that will be scanned for data.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4FileData([NotNull] IT4File t4File, [NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; HandleDirectives(t4File); foreach (IT4Include include in t4File.GetRecursiveIncludes()) { HandleDirectives(include); } }
/// <summary>Initializes a new instance of the <see cref="T4CSharpCodeGenerator"/> class.</summary> /// <param name="file">The associated T4 file whose C# code behind will be generated.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4CSharpCodeGenerator([NotNull] IT4File file, [NotNull] DirectiveInfoManager directiveInfoManager) { _file = file; _directiveInfoManager = directiveInfoManager; _usingsResult = new GenerationResult(file); _parametersResult = new GenerationResult(file); _inheritsResult = new GenerationResult(file); _transformTextResult = new GenerationResult(file); _featureResult = new GenerationResult(file); }
/// <summary> /// Initializes a new instance of the <see cref="T4FileDataCache"/> class. /// </summary> /// <param name="lifetime">The lifetime of this class.</param> /// <param name="psiFiles">The PSI manager.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4FileDataCache([NotNull] Lifetime lifetime, [NotNull] PsiFiles psiFiles, [NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; _fileDataChanged = new Signal <Pair <IPsiSourceFile, T4FileDataDiff> >(lifetime, "T4FileDataCache.FileDataChanged"); lifetime.AddBracket( () => psiFiles.PsiFileCreated += OnPsiFileChanged, () => psiFiles.PsiFileCreated -= OnPsiFileChanged); RegisterPsiChanged(lifetime, psiFiles); lifetime.AddDispose(_fileDataBySourceFile); }
private T4TreeBuilder([NotNull] T4Environment t4Environment, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] ILexer lexer, [CanBeNull] IPsiSourceFile sourceFile, [NotNull] HashSet <FileSystemPath> existingIncludePaths, [CanBeNull] ISolution solution, [CanBeNull] T4PsiModule macroResolveModule) { _t4Environment = t4Environment; _directiveInfoManager = directiveInfoManager; _builderLexer = new PsiBuilderLexer(lexer, tnt => tnt.IsWhitespace); _existingIncludePaths = existingIncludePaths; _sourceFile = sourceFile; _solution = solution; _macroResolveModule = macroResolveModule; }
/// <summary>Initializes a new instance of the <see cref="T4FileDataCache"/> class.</summary> /// <param name="lifetime">The lifetime of this class.</param> /// <param name="psiFiles">The PSI manager.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4FileDataCache(Lifetime lifetime, [NotNull] PsiFiles psiFiles, [NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; FileDataChanged = new Signal <Pair <IPsiSourceFile, T4FileDataDiff> >(lifetime, "T4FileDataCache.FileDataChanged"); lifetime.Bracket( () => psiFiles.PsiFileCreated += OnPsiFileChanged, () => psiFiles.PsiFileCreated -= OnPsiFileChanged ); lifetime.Bracket( () => psiFiles.AfterPsiChanged += OnPsiChanged, () => psiFiles.AfterPsiChanged -= OnPsiChanged ); lifetime.OnTermination(_fileDataBySourceFile); }
internal T4TreeBuilder( [NotNull] T4Environment t4Environment, [NotNull] DirectiveInfoManager directiveInfoManager, [NotNull] ILexer lexer, [CanBeNull] IPsiSourceFile sourceFile = null ) : this( t4Environment, directiveInfoManager, lexer, sourceFile, new HashSet <FileSystemPath>(), sourceFile?.GetSolution(), sourceFile?.PsiModule as T4PsiModule ) { }
private static string GetSortValue([NotNull] IT4Directive directive, [CanBeNull] DirectiveInfo directiveInfo, [NotNull] DirectiveInfoManager directiveInfoManager) { if (directiveInfo == directiveInfoManager.Assembly) { return(directive.GetAttributeValue(directiveInfoManager.Assembly.NameAttribute.Name)); } if (directiveInfo == directiveInfoManager.Import) { return(directive.GetAttributeValue(directiveInfoManager.Import.NamespaceAttribute.Name)); } if (directiveInfo == directiveInfoManager.Parameter) { return(directive.GetAttributeValue(directiveInfoManager.Parameter.NameAttribute.Name)); } return(null); }
public DirectiveAttributeValueItemsProvider([NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; }
public T4ModuleReferencer([NotNull] T4Environment environment, [NotNull] DirectiveInfoManager directiveInfoManager) { _environment = environment; _directiveInfoManager = directiveInfoManager; }
/// <summary> /// Initializes a new instance of the <see cref="T4CSharpCustomModificationHandler"/> class. /// </summary> /// <param name="languageManager">The language manager.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4CSharpCustomModificationHandler([NotNull] ILanguageManager languageManager, [NotNull] DirectiveInfoManager directiveInfoManager) : base(languageManager) { _directiveInfoManager = directiveInfoManager; }
/// <summary> /// Initializes a new instance of the <see cref="T4CSharpCodeGenerator"/> class. /// </summary> /// <param name="file">The associated T4 file whose C# code behind will be generated.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> internal T4CSharpCodeGenerator([NotNull] IT4File file, [NotNull] DirectiveInfoManager directiveInfoManager) { _file = file; _directiveInfoManager = directiveInfoManager; }
/// <summary> /// Initializes a new instance of the <see cref="T4DaemonStageProcess"/> class. /// </summary> /// <param name="file">The associated T4 file.</param> /// <param name="daemonProcess">The associated daemon process.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> public T4ErrorProcess([NotNull] IT4File file, [NotNull] IDaemonProcess daemonProcess, [NotNull] DirectiveInfoManager directiveInfoManager) : base(file, daemonProcess) { _directiveInfoManager = directiveInfoManager; }
public T4GeneratedDocumentService([NotNull] FileDependency fileDependency, [NotNull] DirectiveInfoManager directiveInfoManager) { _fileDependency = fileDependency; _directiveInfoManager = directiveInfoManager; }
/// <summary>Finds an anchor for a newly created directive inside a list of existing directives.</summary> /// <param name="newDirective">The directive to add.</param> /// <param name="existingDirectives">The existing directives.</param> /// <param name="directiveInfoManager">An instance of <see cref="DirectiveInfoManager"/>.</param> /// <returns>A pair indicating the anchor (can be null) and its relative position.</returns> public static Pair <IT4Directive, BeforeOrAfter> FindAnchor( [NotNull] this IT4Directive newDirective, [NotNull] IT4Directive[] existingDirectives, [NotNull] DirectiveInfoManager directiveInfoManager ) { // no anchor if (existingDirectives.Length == 0) { return(Pair.Of((IT4Directive)null, BeforeOrAfter.Before)); } // directive name should never be null, but you never know string newName = newDirective.GetName(); if (String.IsNullOrEmpty(newName)) { return(Pair.Of(existingDirectives.Last(), BeforeOrAfter.After)); } var lastDirectiveByName = new Dictionary <string, IT4Directive>(StringComparer.OrdinalIgnoreCase); DirectiveInfo directiveInfo = directiveInfoManager.GetDirectiveByName(newName); string newsortValue = GetSortValue(newDirective, directiveInfo, directiveInfoManager); foreach (IT4Directive existingDirective in existingDirectives) { string existingName = existingDirective.GetName(); if (existingName == null) { continue; } lastDirectiveByName[existingName] = existingDirective; // directive of the same type as the new one: // if the new directive comes alphabetically before the existing one, we got out anchor if (String.Equals(existingName, newName, StringComparison.OrdinalIgnoreCase)) { string existingSortValue = GetSortValue(existingDirective, directiveInfo, directiveInfoManager); if (String.Compare(newsortValue, existingSortValue, StringComparison.OrdinalIgnoreCase) < 0) { return(Pair.Of(existingDirective, BeforeOrAfter.Before)); } } } // no anchor being alphabetically after the new directive was found: // the last directive of the same type will be used as an anchor if (lastDirectiveByName.TryGetValue(newName, out IT4Directive lastDirective)) { return(Pair.Of(lastDirective, BeforeOrAfter.After)); } // there was no directive of the same type as the new one // the anchor will be the last directive of the type just before (determined by the position in DirectiveInfo.AllDirectives) if (directiveInfo != null) { int index = directiveInfoManager.AllDirectives.IndexOf(directiveInfo) - 1; while (index >= 0) { if (lastDirectiveByName.TryGetValue(directiveInfoManager.AllDirectives[index].Name, out lastDirective)) { return(Pair.Of(lastDirective, BeforeOrAfter.After)); } --index; } return(Pair.Of(existingDirectives.First(), BeforeOrAfter.Before)); } // we don't know the directive name (shouldn't happen), use the last directive as an anchor return(Pair.Of(existingDirectives.Last(), BeforeOrAfter.After)); }
public T4CSharpCodeStructureProvider([NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; }
public DirectiveNameItemsProvider([NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; }
public T4ErrorStage([NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; }
public T4GeneratedDocumentService([NotNull] DirectiveInfoManager directiveInfoManager) { _directiveInfoManager = directiveInfoManager; }
public static IT4Directive AddDirective([NotNull] this IT4File t4File, [NotNull] IT4Directive directive, [NotNull] DirectiveInfoManager directiveInfoManager) { Pair <IT4Directive, BeforeOrAfter> anchor = directive.FindAnchor(t4File.GetDirectives().ToArray(), directiveInfoManager); if (anchor.First == null) { return(t4File.AddDirective(directive)); } return(anchor.Second == BeforeOrAfter.Before ? t4File.AddDirectiveBefore(directive, anchor.First) : t4File.AddDirectiveAfter(directive, anchor.First)); }