Beispiel #1
0
        public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent)
        {
            ICompilationUnit compilationUnit;

            using (ParseAndLock(fileContent)) {
                var document = parser.LastDocument;

                CompilationUnitCreatorVisitor visitor =
                    new CompilationUnitCreatorVisitor(projectContent, fileContent.Text, fileName, lexerTags);

                document.AcceptVisitor(visitor);

                compilationUnit = visitor.CompilationUnit;
            }

            // During project load all XAML files are parsed
            // most of them are not opened, thus fileContent.Version is null.
            // We can clear the parser data, because the file will be reparsed
            // as soon as it is opened by the user.

            // This will save us some memory, because we only use the
            // compilation unit created by the visitor above for code completion.
            if (fileContent.Version == null)
            {
                parser.Lock.EnterWriteLock();
                // double-checked locking (other threads might parse the document in the meantime)
                if (lastParsedVersion == null)
                {
                    parser.Clear();
                }
                parser.Lock.ExitWriteLock();
            }

            return(compilationUnit);
        }
Beispiel #2
0
		public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent)
		{
			//using (new DebugTimerObject("background parser")) {
			//	Core.LoggingService.Info("file: " + fileName);
			using (ParseAndLock(fileContent)) {
				var document = parser.LastDocument;
				
				CompilationUnitCreatorVisitor visitor =
					new CompilationUnitCreatorVisitor(projectContent, fileContent.Text, fileName, lexerTags);
				
				document.AcceptVisitor(visitor);
				
				return visitor.CompilationUnit;
			}
			//}
		}
Beispiel #3
0
		public ICompilationUnit Parse(IProjectContent projectContent, string fileName, ITextBuffer fileContent)
		{
			ICompilationUnit compilationUnit;
			
			using (ParseAndLock(fileContent)) {
				var document = parser.LastDocument;
				
				CompilationUnitCreatorVisitor visitor =
					new CompilationUnitCreatorVisitor(projectContent, fileContent.Text, fileName, lexerTags);
				
				document.AcceptVisitor(visitor);
				
				compilationUnit = visitor.CompilationUnit;
			}
			
			// During project load all XAML files are parsed
			// most of them are not opened, thus fileContent.Version is null.
			// We can clear the parser data, because the file will be reparsed
			// as soon as it is opened by the user.
			
			// This will save us some memory, because we only use the
			// compilation unit created by the visitor above for code completion.
			if (fileContent.Version == null) {
				parser.Lock.EnterWriteLock();
				// double-checked locking (other threads might parse the document in the meantime)
				if (lastParsedVersion == null) {
					parser.Clear();
				}
				parser.Lock.ExitWriteLock();
			}
			
			return compilationUnit;
		}