public void testScanner3() {
			var source = @"#if XXX
class
#else
interface
#endif
C {
}
";
			var codeErrorManager = new CodeErrorManager();
			var preprocessor = new Preprocessor(codeErrorManager, source.toCharArray());
			var scanner = new PreprocessedTextScanner(codeErrorManager, preprocessor.preprocess());
			Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
			RestorePoint rp = scanner.createRestorePoint();
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Identifier, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.OpenBrace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			scanner.restore(rp);
			Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
			Assert.assertEquals("interface", new String(scanner.Text, scanner.StartPosition, scanner.EndPosition - scanner.StartPosition));
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Identifier, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.OpenBrace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.CloseBrace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.EndOfStream, scanner.nextLexicalUnit());
		}
Example #2
0
 protected ScannerBase(CodeErrorManager codeErrorManager, char[] text, int position, int length, int line, int column)
 {
     this.CodeErrorManager = codeErrorManager;
     this.Text             = text;
     this.TabWidth         = 4;
     this.initialize(position, length, line, column, codeErrorManager.ErrorCount, codeErrorManager.DisabledWarnings);
 }
Example #3
0
        public void testScanner3()
        {
            var source           = @"#if XXX
class
#else
interface
#endif
C {
}
";
            var codeErrorManager = new CodeErrorManager();
            var preprocessor     = new Preprocessor(codeErrorManager, source.toCharArray());
            var scanner          = new PreprocessedTextScanner(codeErrorManager, preprocessor.preprocess());

            Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
            RestorePoint rp = scanner.createRestorePoint();

            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Identifier, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.OpenBrace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            scanner.restore(rp);
            Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
            Assert.assertEquals("interface", new String(scanner.Text, scanner.StartPosition, scanner.EndPosition - scanner.StartPosition));
            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Identifier, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.OpenBrace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.CloseBrace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.EndOfStream, scanner.nextLexicalUnit());
        }
Example #4
0
        public void keywordTest()
        {
            var errorManager = new CodeErrorManager();
            var scanner      = new SourceCodeScanner(errorManager, "class".toCharArray());

            Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
            Assert.assertEquals(Keyword.Class, scanner.Keyword);
        }
Example #5
0
        public void integerTest()
        {
            var errorManager = new CodeErrorManager();
            var scanner      = new SourceCodeScanner(errorManager, "123".toCharArray());

            Assert.assertEquals(LexicalUnit.DecimalIntegerLiteral, scanner.nextLexicalUnit());
            Assert.assertEquals(3, scanner.EndPosition);
        }
		public void integersTest() {
			var errorManager = new CodeErrorManager();
			var scanner = new SourceCodeScanner(errorManager, "1 3".toCharArray());
			Assert.assertEquals(LexicalUnit.DecimalIntegerLiteral, scanner.nextLexicalUnit());
			Assert.assertEquals(1, scanner.EndPosition);
			Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
			Assert.assertEquals(2, scanner.EndPosition);
			Assert.assertEquals(LexicalUnit.DecimalIntegerLiteral, scanner.nextLexicalUnit());
			Assert.assertEquals(3, scanner.EndPosition);
		}
		public void testScanner() {
			var source = @"
class C {
}
";
			var codeErrorManager = new CodeErrorManager();
			var preprocessor = new Preprocessor(codeErrorManager, source.toCharArray());
			var scanner = new PreprocessedTextScanner(codeErrorManager, preprocessor.preprocess());
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Identifier, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.OpenBrace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.CloseBrace, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
			Assert.assertEquals(LexicalUnit.EndOfStream, scanner.nextLexicalUnit());
		}
Example #8
0
        public void testScanner()
        {
            var source           = @"
class C {
}
";
            var codeErrorManager = new CodeErrorManager();
            var preprocessor     = new Preprocessor(codeErrorManager, source.toCharArray());
            var scanner          = new PreprocessedTextScanner(codeErrorManager, preprocessor.preprocess());

            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Identifier, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.Whitespace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.OpenBrace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.CloseBrace, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.NewLine, scanner.nextLexicalUnit());
            Assert.assertEquals(LexicalUnit.EndOfStream, scanner.nextLexicalUnit());
        }
Example #9
0
        private void parse(IFile file, char[] text, CodeErrorManager errorManager, Map <String, CompilationUnitNode> compilationUnits)
        {
            var filename = parameters.AllFiles.getProjectRelativeName(file);

            var preprocessor = new Preprocessor(errorManager, text);

            preprocessor.setFilename(filename);
            preprocessor.Symbols.addAll(parameters.PreprocessorSymbols);
            var preprocessedText = preprocessor.preprocess();

            var parser  = new Parser();
            var scanner = new PreprocessedTextScanner(errorManager, preprocessedText);

            scanner.setFilename(filename);
            scanner.setTabWidth(Environment.getTabWidth());

            var compilationUnit = parser.parseCompilationUnit(scanner);

            if (compilationUnit != null)
            {
                compilationUnit.setSymbols(preprocessor.Symbols);
                compilationUnits[filename] = compilationUnit;
            }
        }
        public CompilerResults() {
            this.codeErrorManager = new CodeErrorManager();
            this.classFiles = new HashMap<String, byte[]>();
			this.compilationStage = CompilationStage.None;
        }
		private SourceCompilerResults compileCore(IProgressMonitor monitor) {
			var t0 = System.nanoTime();
			
			var results = new SourceCompilerResults();
			var hasErrors = false;
			var errorManager = new CodeErrorManager();
			var allFiles = parameters.AllFiles;
			Iterable<IFile> filesToCompile = null;
			
			try {
				monitor.beginTask("", 11);

				var deletedFiles = parameters.FilesToCompile
						.select(p => allFiles.getResource(p))
						.where(p => p == null || !p.exists())
						.select(p => allFiles.getProjectRelativeName(p)).toSet();
				var typesToCopy = Query.empty<TypeInfo>();

				// Get the files to compile
				if (parameters.FullBuild) {
					filesToCompile = allFiles.getAllResources().where(p => p.exists()).toList();
				} else {
					bool filteringDone = false;
					var referencingFiles = parameters.getDependencyInfo().getAllReferencingFiles(parameters.getFilesToCompile());
					if (parameters.ProgressiveBuild && deletedFiles.isEmpty()) {
						var referencedFiles = parameters.getDependencyInfo().getAllReferencedFiles(parameters.getFilesToCompile());
						referencedFiles = referencedFiles.except(parameters.getFilesToCompile());
						referencedFiles = referencedFiles.intersect(referencingFiles);
						
						// Progressive build only if referenced and referencing files do not intersect
						if (!referencedFiles.any()) {
							filesToCompile = parameters.FilesToCompile.select(p => allFiles.getResource(p)).where(p => p.exists()).toList();
							filteringDone = true;
						}
					}
					if (!filteringDone) {
						// Incremental build with dependencies
						filesToCompile = referencingFiles.select(p => allFiles.getResource(p)).where(p => p.exists()).toList();
					}
					
					var filesToKeep = allFiles.getAllProjectRelativeNames().except(referencingFiles);
					typesToCopy = filesToKeep.selectMany(p => parameters.DependencyInfo.getFileContents(p))
							.where(p => p.indexOf('$') == -1).select(p => parameters.TypeSystem.getType(p));
							
					Environment.trace(this, "keeping " + filesToKeep.count() + " files");
					Environment.trace(this, "ignoring " +
							(allFiles.getAllResources().count() - filesToCompile.count() - filesToKeep.count()) + " files");
				}
				Environment.trace(this, "compiling " + filesToCompile.count() + " files");
				monitor.worked(1);
				if (monitor.isCanceled()) {
					throw new InterruptedException();
				}

				var compilationUnits = new HashMap<String, CompilationUnitNode>();
				
				// Parsing
				foreach (var file in filesToCompile) {
					var text = getText(file);
					if (text != null) {
						parse(file, text, errorManager, compilationUnits);
					}
				}
				monitor.worked(1);
				if (monitor.isCanceled()) {
					throw new InterruptedException();
				}
				
				// Compiling
				var t1 = System.nanoTime();
				
				var typeSystem = new Library(parameters.ClassPath);
				JvmTypeSystemHelper.cloneTypes(typesToCopy, typeSystem);
				
				var annotatedTypeSystem = new Library(new[] { Environment.getLibraryPath("stabal.jar") }, typeSystem);
				
				var cparams = new CompilerParameters();
				cparams.TypeSystem = typeSystem;
				cparams.AnnotatedTypeSystem = annotatedTypeSystem;
				cparams.GenerateClassFiles = parameters.GenerateClassFiles;
				cparams.ProgressTracker = new CompilationProgressTracker(monitor);
				
				var cunits = compilationUnits.values().toArray(new CompilationUnitNode[compilationUnits.size()]);
				var cresults = new StabCompiler().compileFromCompilationUnits(cparams, cunits);
				
				Environment.trace(this, "compilation of " + sizeof(cunits) + " files done in " + ((System.nanoTime() - t1) / 1e6) + "ms");

				foreach (var error in cresults.Errors) {
					if (error.Level == 0) {
						hasErrors = true;
					}
					results.CodeErrors.add(error);
					Environment.trace(this, "error (" + error.Line + ", " + error.Column + ") " + error.Filename + ": " + error.Message);
				}

				if (!hasErrors) {
					var dependencyInfo = new DependencyInfo();
					results.DependencyInfo = dependencyInfo;
					var allTypes = new HashSet<String>();
	
					// Copy informations from unbuilt files
					if (parameters.DependencyInfo != null) {
						var unbuiltFiles = allFiles.getAllProjectRelativeNames();
						unbuiltFiles = unbuiltFiles.except(filesToCompile.select(p => allFiles.getProjectRelativeName(p)));
						unbuiltFiles = unbuiltFiles.except(deletedFiles);
						foreach (var file in unbuiltFiles) {
							foreach (var type in parameters.DependencyInfo.getFileContents(file)) {
								allTypes.add(type);
								dependencyInfo.addFileToTypeRelation(file, type);
								foreach (var refType in parameters.DependencyInfo.getReferencedTypes(type)) {
									dependencyInfo.addTypeToTypeRelation(type, refType);
								}
							}
						}
					}
					
					// Collect the types and update the dependencies.
					var typeMembers = new HashMap<IFile, Iterable<TypeMemberNode>>();
					foreach (var file in filesToCompile) {
						var fileName = allFiles.getProjectRelativeName(file);
						var compilationUnit = compilationUnits[fileName];
						if (compilationUnit == null) {
							continue;
						}
						var members = SyntaxTreeHelper.getTypeMembers(compilationUnit);
						typeMembers.put(file, members);
						foreach (var member in members) {
							var typeName = member.getUserData(typeof(TypeInfo)).FullName;
							dependencyInfo.addFileToTypeRelation(fileName, typeName);
							allTypes.add(typeName);
						}
					}

					if (parameters.DependencyInfo != null) {
						// Copy the types ignored by this compilation
						var missingTypes = new HashSet<TypeInfo>();
						foreach (var t in allTypes.where(p => p.indexOf('$') == -1 && !typeSystem.typeExists(p))) {
							if (hasErrors = !parameters.DependencyInfo.getReferencedTypes(t).all(p => allTypes.contains(p))) {
								Environment.trace(this, "Incremental build failed: a type was deleted");
								break;
							}
							missingTypes.add(parameters.TypeSystem.getType(t));
						}
						if (!hasErrors) {
							JvmTypeSystemHelper.cloneTypes(missingTypes, typeSystem);
						}
					}
					
					if (!hasErrors) {
						// Compute the dependencies in the compiled files
						foreach (var member in filesToCompile.select(p => typeMembers[p]).where(p => p != null).selectMany(p => p)) {
							foreach (var t in SyntaxTreeHelper.getTypeMemberDependencies(member)
									.intersect(allTypes.select(p => JvmTypeSystemHelper.getType(typeSystem, p)))) {
								dependencyInfo.addTypeToTypeRelation(member.getUserData(typeof(TypeInfo)).FullName, t.FullName);
							}
						}
	
						results.TypeSystem = typeSystem;
						results.AnnotatedTypeSystem = annotatedTypeSystem;
						foreach (var e in compilationUnits.entrySet()) {
							results.CompilationUnits[e.Key] = e.Value;
						}
						foreach (var e in cresults.ClassFiles.entrySet()) {
							results.ClassFiles[e.Key] = e.Value;
						}
					}
				}
				monitor.worked(1);
			} catch (CodeErrorException e) {
				monitor.worked(10);
			} catch (TypeLoadException e) {
				results.MissingType = e.TypeName;
				hasErrors = true;
				monitor.worked(6);
			} finally {
				monitor.done();
			}

			foreach (var file in filesToCompile) {
				results.CompiledFiles.add(allFiles.getProjectRelativeName(file));
			}
			foreach (var error in errorManager.Errors) {
				if (error.Level == 0) {
					hasErrors = true;
				}
				results.CodeErrors.add(error);
				Environment.trace(this, "error (" + error.Line + ", " + error.Column + ") " + error.Filename + ": " + error.Message);
			}
			results.Failed = hasErrors;
			
			Environment.trace(this, "compilation done in " + ((System.nanoTime() - t0) / 1e6) + "ms");
			return results;
		}
 public SourceCodeScanner(CodeErrorManager codeErrorManager, char[] text, int position, int length, int line, int column)
     : super(codeErrorManager, text, position, length, line, column) {
 public SourceCodeScanner(CodeErrorManager codeErrorManager, char[] text)
     : this(codeErrorManager, text, 0, sizeof(text), 0, 0) {
 }
        public PreprocessedTextScanner(CodeErrorManager codeErrorManager, PreprocessedText preprocessedText) {
            this.CodeErrorManager = codeErrorManager;
            this.PreprocessedText = preprocessedText;
			this.tabWidth = 4;
        }
Example #15
0
        private SourceCompilerResults compileCore(IProgressMonitor monitor)
        {
            var t0 = System.nanoTime();

            var results      = new SourceCompilerResults();
            var hasErrors    = false;
            var errorManager = new CodeErrorManager();
            var allFiles     = parameters.AllFiles;
            Iterable <IFile> filesToCompile = null;

            try {
                monitor.beginTask("", 11);

                var deletedFiles = parameters.FilesToCompile
                                   .select(p => allFiles.getResource(p))
                                   .where (p => p == null || !p.exists())
                                   .select(p => allFiles.getProjectRelativeName(p)).toSet();
                var typesToCopy = Query.empty <TypeInfo>();

                // Get the files to compile
                if (parameters.FullBuild)
                {
                    filesToCompile = allFiles.getAllResources().where (p => p.exists()).toList();
                }
                else
                {
                    bool filteringDone    = false;
                    var  referencingFiles = parameters.getDependencyInfo().getAllReferencingFiles(parameters.getFilesToCompile());
                    if (parameters.ProgressiveBuild && deletedFiles.isEmpty())
                    {
                        var referencedFiles = parameters.getDependencyInfo().getAllReferencedFiles(parameters.getFilesToCompile());
                        referencedFiles = referencedFiles.except(parameters.getFilesToCompile());
                        referencedFiles = referencedFiles.intersect(referencingFiles);

                        // Progressive build only if referenced and referencing files do not intersect
                        if (!referencedFiles.any())
                        {
                            filesToCompile = parameters.FilesToCompile.select(p => allFiles.getResource(p)).where (p => p.exists()).toList();
                            filteringDone  = true;
                        }
                    }
                    if (!filteringDone)
                    {
                        // Incremental build with dependencies
                        filesToCompile = referencingFiles.select(p => allFiles.getResource(p)).where (p => p.exists()).toList();
                    }

                    var filesToKeep = allFiles.getAllProjectRelativeNames().except(referencingFiles);
                    typesToCopy = filesToKeep.selectMany(p => parameters.DependencyInfo.getFileContents(p))
                                  .where (p => p.indexOf('$') == -1).select(p => parameters.TypeSystem.getType(p));

                    Environment.trace(this, "keeping " + filesToKeep.count() + " files");
                    Environment.trace(this, "ignoring " +
                                      (allFiles.getAllResources().count() - filesToCompile.count() - filesToKeep.count()) + " files");
                }
                Environment.trace(this, "compiling " + filesToCompile.count() + " files");
                monitor.worked(1);
                if (monitor.isCanceled())
                {
                    throw new InterruptedException();
                }

                var compilationUnits = new HashMap <String, CompilationUnitNode>();

                // Parsing
                foreach (var file in filesToCompile)
                {
                    var text = getText(file);
                    if (text != null)
                    {
                        parse(file, text, errorManager, compilationUnits);
                    }
                }
                monitor.worked(1);
                if (monitor.isCanceled())
                {
                    throw new InterruptedException();
                }

                // Compiling
                var t1 = System.nanoTime();

                var typeSystem = new Library(parameters.ClassPath);
                JvmTypeSystemHelper.cloneTypes(typesToCopy, typeSystem);

                var annotatedTypeSystem = new Library(new[] { Environment.getLibraryPath("stabal.jar") }, typeSystem);

                var cparams = new CompilerParameters();
                cparams.TypeSystem          = typeSystem;
                cparams.AnnotatedTypeSystem = annotatedTypeSystem;
                cparams.GenerateClassFiles  = parameters.GenerateClassFiles;
                cparams.ProgressTracker     = new CompilationProgressTracker(monitor);

                var cunits   = compilationUnits.values().toArray(new CompilationUnitNode[compilationUnits.size()]);
                var cresults = new StabCompiler().compileFromCompilationUnits(cparams, cunits);

                Environment.trace(this, "compilation of " + sizeof(cunits) + " files done in " + ((System.nanoTime() - t1) / 1e6) + "ms");

                foreach (var error in cresults.Errors)
                {
                    if (error.Level == 0)
                    {
                        hasErrors = true;
                    }
                    results.CodeErrors.add(error);
                    Environment.trace(this, "error (" + error.Line + ", " + error.Column + ") " + error.Filename + ": " + error.Message);
                }

                if (!hasErrors)
                {
                    var dependencyInfo = new DependencyInfo();
                    results.DependencyInfo = dependencyInfo;
                    var allTypes = new HashSet <String>();

                    // Copy informations from unbuilt files
                    if (parameters.DependencyInfo != null)
                    {
                        var unbuiltFiles = allFiles.getAllProjectRelativeNames();
                        unbuiltFiles = unbuiltFiles.except(filesToCompile.select(p => allFiles.getProjectRelativeName(p)));
                        unbuiltFiles = unbuiltFiles.except(deletedFiles);
                        foreach (var file in unbuiltFiles)
                        {
                            foreach (var type in parameters.DependencyInfo.getFileContents(file))
                            {
                                allTypes.add(type);
                                dependencyInfo.addFileToTypeRelation(file, type);
                                foreach (var refType in parameters.DependencyInfo.getReferencedTypes(type))
                                {
                                    dependencyInfo.addTypeToTypeRelation(type, refType);
                                }
                            }
                        }
                    }

                    // Collect the types and update the dependencies.
                    var typeMembers = new HashMap <IFile, Iterable <TypeMemberNode> >();
                    foreach (var file in filesToCompile)
                    {
                        var fileName        = allFiles.getProjectRelativeName(file);
                        var compilationUnit = compilationUnits[fileName];
                        if (compilationUnit == null)
                        {
                            continue;
                        }
                        var members = SyntaxTreeHelper.getTypeMembers(compilationUnit);
                        typeMembers.put(file, members);
                        foreach (var member in members)
                        {
                            var typeName = member.getUserData(typeof(TypeInfo)).FullName;
                            dependencyInfo.addFileToTypeRelation(fileName, typeName);
                            allTypes.add(typeName);
                        }
                    }

                    if (parameters.DependencyInfo != null)
                    {
                        // Copy the types ignored by this compilation
                        var missingTypes = new HashSet <TypeInfo>();
                        foreach (var t in allTypes.where (p => p.indexOf('$') == -1 && !typeSystem.typeExists(p)))
                        {
                            if (hasErrors = !parameters.DependencyInfo.getReferencedTypes(t).all(p => allTypes.contains(p)))
                            {
                                Environment.trace(this, "Incremental build failed: a type was deleted");
                                break;
                            }
                            missingTypes.add(parameters.TypeSystem.getType(t));
                        }
                        if (!hasErrors)
                        {
                            JvmTypeSystemHelper.cloneTypes(missingTypes, typeSystem);
                        }
                    }

                    if (!hasErrors)
                    {
                        // Compute the dependencies in the compiled files
                        foreach (var member in filesToCompile.select(p => typeMembers[p]).where (p => p != null).selectMany(p => p))
                        {
                            foreach (var t in SyntaxTreeHelper.getTypeMemberDependencies(member)
                                     .intersect(allTypes.select(p => JvmTypeSystemHelper.getType(typeSystem, p))))
                            {
                                dependencyInfo.addTypeToTypeRelation(member.getUserData(typeof(TypeInfo)).FullName, t.FullName);
                            }
                        }

                        results.TypeSystem          = typeSystem;
                        results.AnnotatedTypeSystem = annotatedTypeSystem;
                        foreach (var e in compilationUnits.entrySet())
                        {
                            results.CompilationUnits[e.Key] = e.Value;
                        }
                        foreach (var e in cresults.ClassFiles.entrySet())
                        {
                            results.ClassFiles[e.Key] = e.Value;
                        }
                    }
                }
                monitor.worked(1);
            } catch (CodeErrorException e) {
                monitor.worked(10);
            } catch (TypeLoadException e) {
                results.MissingType = e.TypeName;
                hasErrors           = true;
                monitor.worked(6);
            } finally {
                monitor.done();
            }

            foreach (var file in filesToCompile)
            {
                results.CompiledFiles.add(allFiles.getProjectRelativeName(file));
            }
            foreach (var error in errorManager.Errors)
            {
                if (error.Level == 0)
                {
                    hasErrors = true;
                }
                results.CodeErrors.add(error);
                Environment.trace(this, "error (" + error.Line + ", " + error.Column + ") " + error.Filename + ": " + error.Message);
            }
            results.Failed = hasErrors;

            Environment.trace(this, "compilation done in " + ((System.nanoTime() - t0) / 1e6) + "ms");
            return(results);
        }
 public PreprocessorScanner(CodeErrorManager codeErrorManager, char[] text)
     : this(codeErrorManager, text, 0, sizeof(text), 0, 0) {
 }
 public PreprocessorScanner(CodeErrorManager codeErrorManager, char[] text)
     : this(codeErrorManager, text, 0, sizeof(text), 0, 0)
 {
 }
 public Preprocessor(CodeErrorManager codeErrorManager, char[] text) {
     this.scanner = new PreprocessorScanner(codeErrorManager, text);
     this.Symbols = new HashSet<String>();
     this.warnings = new int[16];
 }
Example #19
0
 public SourceCodeScanner(CodeErrorManager codeErrorManager, char[] text, int position, int length, int line, int column)
     : super(codeErrorManager, text, position, length, line, column)
Example #20
0
 public SourceCodeScanner(CodeErrorManager codeErrorManager, char[] text)
     : this(codeErrorManager, text, 0, sizeof(text), 0, 0)
 {
 }
 protected ScannerBase(CodeErrorManager codeErrorManager, char[] text, int position, int length, int line, int column) {
     this.CodeErrorManager = codeErrorManager;
     this.Text = text;
     this.TabWidth = 4;
     this.initialize(position, length, line, column, codeErrorManager.ErrorCount, codeErrorManager.DisabledWarnings);
 }
 public PreprocessorScanner(CodeErrorManager codeErrorManager, char[] text, int position, int length, int line, int column)
     : super(codeErrorManager, text, position, length, line, column) {
		public void keywordTest() {
			var errorManager = new CodeErrorManager();
			var scanner = new SourceCodeScanner(errorManager, "class".toCharArray());
			Assert.assertEquals(LexicalUnit.Keyword, scanner.nextLexicalUnit());
			Assert.assertEquals(Keyword.Class, scanner.Keyword);
		}
		private void parse(IFile file, char[] text, CodeErrorManager errorManager, Map<String, CompilationUnitNode> compilationUnits) {
			var filename = parameters.AllFiles.getProjectRelativeName(file);
			
			var preprocessor = new Preprocessor(errorManager, text);
			preprocessor.setFilename(filename);
			preprocessor.Symbols.addAll(parameters.PreprocessorSymbols);
			var preprocessedText = preprocessor.preprocess();
			
			var parser = new Parser();
			var scanner = new PreprocessedTextScanner(errorManager, preprocessedText);
			scanner.setFilename(filename);
			scanner.setTabWidth(Environment.getTabWidth());
			
			var compilationUnit = parser.parseCompilationUnit(scanner);
			if (compilationUnit != null) {
				compilationUnit.setSymbols(preprocessor.Symbols);
				compilationUnits[filename] = compilationUnit;
			}
		}
 public PreprocessorScanner(CodeErrorManager codeErrorManager, char[] text, int position, int length, int line, int column)
     : super(codeErrorManager, text, position, length, line, column)
 public Preprocessor(CodeErrorManager codeErrorManager, char[] text)
 {
     this.scanner  = new PreprocessorScanner(codeErrorManager, text);
     this.Symbols  = new HashSet <String>();
     this.warnings = new int[16];
 }