예제 #1
0
        private void HandleInclude(
            [CanBeNull] string includeFileName,
            [NotNull] T4DirectiveAttribute fileAttr,
            [NotNull] CompositeElement parentElement,
            bool once
            )
        {
            FileSystemPath includePath = ResolveInclude(includeFileName);

            if (includePath.IsEmpty)
            {
                fileAttr.ValueError = String.Format(CultureInfo.InvariantCulture, "Unresolved file \"{0}\"", includePath);
                return;
            }

            if (!_existingIncludePaths.Add(includePath))
            {
                if (!once)
                {
                    fileAttr.ValueError = String.Format(CultureInfo.InvariantCulture, "Already included file \"{0}\"", includePath);
                }
                return;
            }

            FileSystemPath sourceLocation = _sourceFile.GetLocation();

            if (includePath == sourceLocation)
            {
                fileAttr.ValueError = "Recursive include";
                _existingIncludePaths.Add(includePath);
                return;
            }

            if (!includePath.ExistsFile)
            {
                fileAttr.ValueError = String.Format(CultureInfo.InvariantCulture, "File \"{0}\" not found", includePath);
                return;
            }

            // find the matching include in the existing solution source files
            // or create a new one if the include file is outside the solution
            IPsiSourceFile includeSourceFile = includePath.FindSourceFileInSolution(_solution) ?? CreateIncludeSourceFile(includePath);

            if (includeSourceFile == null)
            {
                fileAttr.ValueError = "No current solution";
                return;
            }

            ILexer    includeLexer = CreateLexer(includeSourceFile);
            var       builder      = new T4TreeBuilder(_t4Environment, _directiveInfoManager, includeLexer, includeSourceFile, _existingIncludePaths, _solution, _macroResolveModule);
            T4Include include      = builder.CreateIncludeT4Tree();

            include.Path = includePath;
            _includes.Add(include);

            // do not use AppendNewChild, we don't want the PsiBuilderLexer to move line breaks from the include into the main file.
            parentElement.AddChild(include);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DirectiveBuilder"/> struct.
 /// </summary>
 /// <param name="treeBuilder">The tree builder owning this builder.</param>
 internal DirectiveBuilder([NotNull] T4TreeBuilder treeBuilder)
 {
     _treeBuilder = treeBuilder;
     _currentInfo = null;
     _firstInfo   = null;
 }
 internal AttributeInfo(T4TreeBuilder builder)
 {
     _builder = builder;
 }
예제 #4
0
        private void HandleInclude([CanBeNull] string includeFileName, [NotNull] T4DirectiveAttribute fileAttr, [NotNull] CompositeElement parentElement)
        {
            FileSystemPath includePath = ResolveInclude(includeFileName);
            if (includePath.IsEmpty) {
                fileAttr.ValueError = String.Format(CultureInfo.InvariantCulture, "Unresolved file \"{0}\"", includePath);
                return;
            }

            if (!_existingIncludePaths.Add(includePath)) {
                fileAttr.ValueError = String.Format(CultureInfo.InvariantCulture, "Already included file \"{0}\"", includePath);
                return;
            }

            FileSystemPath sourceLocation = _sourceFile.GetLocation();
            if (includePath == sourceLocation) {
                fileAttr.ValueError = "Recursive include";
                _existingIncludePaths.Add(includePath);
                return;
            }

            if (!includePath.ExistsFile) {
                fileAttr.ValueError = String.Format(CultureInfo.InvariantCulture, "File \"{0}\" not found", includePath);
                return;
            }

            // find the matching include in the existing solution source files
            // or create a new one if the include file is outside the solution
            IPsiSourceFile includeSourceFile = includePath.FindSourceFileInSolution(_solution) ?? CreateIncludeSourceFile(includePath);
            if (includeSourceFile == null) {
                fileAttr.ValueError = "No current solution";
                return;
            }

            ILexer includeLexer = CreateLexer(includeSourceFile);
            var builder = new T4TreeBuilder(_t4Environment, _directiveInfoManager, includeLexer, includeSourceFile, _existingIncludePaths, _solution, _macroResolveModule);
            T4Include include = builder.CreateIncludeT4Tree();
            include.Path = includePath;
            _includes.Add(include);

            // do not use AppendNewChild, we don't want the PsiBuilderLexer to move line breaks from the include into the main file.
            parentElement.AddChild(include);
        }
			/// <summary>
			/// Initializes a new instance of the <see cref="DirectiveBuilder"/> struct.
			/// </summary>
			/// <param name="treeBuilder">The tree builder owning this builder.</param>
			internal DirectiveBuilder([NotNull] T4TreeBuilder treeBuilder) {
				_treeBuilder = treeBuilder;
				_currentInfo = null;
				_firstInfo = null;
			}
				internal AttributeInfo(T4TreeBuilder builder) {
					_builder = builder;
				}
예제 #7
0
 public AttributeInfo(T4TreeBuilder builder)
 {
     _builder = builder;
 }