public void traverse(ASTVisitor visitor, CompilationUnitScope unitScope) { traverse(visitor, unitScope, true); } public void traverse(ASTVisitor visitor, CompilationUnitScope unitScope, boolean skipOnError) {
@Override public int compare(CompilationUnitDeclaration o1, CompilationUnitDeclaration o2) { String s1 = new String(o1.getFileName()); String s2 = new String(o2.getFileName()); return s1.compareTo(s2); } }
this.reportProgress(Messages.bind(Messages.compilation_processing, new String(unit.getFileName()))); this.parser.getMethodBodies(unit); unit.resolve(); unit.analyseCode();
private void forEachCompilationUnit(List<CompilationUnitDeclaration> unitList, SpoonProgress.Process process, Consumer<CompilationUnitDeclaration> consumer) { if (getEnvironment().getSpoonProgress() != null) { getEnvironment().getSpoonProgress().start(process); } int i = 0; for (CompilationUnitDeclaration unit : unitList) { if (unit.isModuleInfo() || !unit.isEmpty()) { final String unitPath = new String(unit.getFileName()); if (canProcessCompilationUnit(unitPath)) { consumer.accept(unit); } if (getEnvironment().getSpoonProgress() != null) { getEnvironment().getSpoonProgress().step(process, unitPath, ++i, unitList.size()); } } } if (getEnvironment().getSpoonProgress() != null) { getEnvironment().getSpoonProgress().end(process); } }
static class IntArrayList { public int[] list = new int[5]; public int length = 0; public void add(int i) { if (this.list.length == this.length) { System.arraycopy(this.list, 0, this.list = new int[this.length*2], 0, this.length); } this.list[this.length++] = i; } }
unit.resolve(); if (!this.options.ignoreMethodBodies) unit.analyseCode(); // flow analysis if (!this.options.ignoreMethodBodies) unit.generateCode(); // code generation unit.finalizeProblems();
DefaultBindingResolver(LookupEnvironment lookupEnvironment, WorkingCopyOwner workingCopyOwner, BindingTables bindingTables, boolean isRecoveringBindings, boolean fromJavaProject) { this.newAstToOldAst = new HashMap(); this.astNodesToBlockScope = new HashMap(); this.bindingsToAstNodes = new HashMap(); this.bindingTables = bindingTables; this.scope = new CompilationUnitScope(new CompilationUnitDeclaration(null, null, -1), lookupEnvironment); this.workingCopyOwner = workingCopyOwner; this.isRecoveringBindings = isRecoveringBindings; this.fromJavaProject = fromJavaProject; }
/** * @return null when no errors */ public synchronized String getCompileErrors(CompilationUnitDeclaration unit) { process(unit, 0); CategorizedProblem[] errors = unit.compilationResult().getErrors(); if (errors != null && errors.length > 0) { StringBuilder sb = new StringBuilder(); for (CategorizedProblem p : errors) { sb.append(p.getMessage()).append('\n'); } sb.setLength(sb.length() - 1); return sb.toString(); } return null; }
/** * Creates an IImportDeclaration from the given import statement */ protected IJavaElement createPackageDeclarationHandle(CompilationUnitDeclaration unit) { if (unit.isPackageInfo()) { char[] packName = CharOperation.concatWith(unit.currentPackage.getImportName(), '.'); Openable openable = this.currentPossibleMatch.openable; if (openable instanceof CompilationUnit) { return ((CompilationUnit) openable).getPackageDeclaration(new String(packName)); } } return createTypeHandle(new String(unit.getMainTypeName())); } /**
public boolean isModuleInfo() { return CharOperation.equals(getMainTypeName(), TypeConstants.MODULE_INFO_NAME); }
@Override public void process(CompilationUnitDeclaration unit, int unitNumber) { mCurrentUnit = lookupEnvironment.unitBeingCompleted = unit; parser.getMethodBodies(unit); if (unit.scope != null) { unit.scope.faultInTypes(); unit.scope.verifyMethods(lookupEnvironment.methodVerifier()); } unit.resolve(); unit.analyseCode(); // This is where we differ from super: DON'T call generateCode(). // Sadly we can't just set ignoreMethodBodies=true to have the same effect, // since that would also skip the analyseCode call, which we DO, want: // unit.generateCode(); if (options.produceReferenceInfo && unit.scope != null) { unit.scope.storeDependencyInfo(); } unit.finalizeProblems(); unit.compilationResult.totalUnitsKnown = totalUnits; lookupEnvironment.unitBeingCompleted = null; }
protected CompilationUnitDeclaration buildBindings(ICompilationUnit compilationUnit, boolean isTopLevelOrMember) throws JavaModelException { // source unit org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = (org.eclipse.jdt.internal.compiler.env.ICompilationUnit) compilationUnit; CompilationResult compilationResult = new CompilationResult(sourceUnit, 1, 1, 0); CompilationUnitDeclaration unit = isTopLevelOrMember ? this.locator.basicParser().dietParse(sourceUnit, compilationResult) : this.locator.basicParser().parse(sourceUnit, compilationResult); if (unit != null) { this.locator.lookupEnvironment.buildTypeBindings(unit, null /*no access restriction*/); this.locator.lookupEnvironment.completeTypeBindings(unit, !isTopLevelOrMember); if (!isTopLevelOrMember) { if (unit.scope != null) unit.scope.faultInTypes(); // fault in fields & methods unit.resolve(); } } return unit; } public char[][][] collect() throws JavaModelException {
public CudInfo(CompilationUnitDeclaration cud) { fileName = intern(cud.getFileName()); separatorPositions = cud.compilationResult().getLineSeparatorPositions(); scope = cud.scope; } }
public void cleanUp() { this.source = null; if (this.parsedUnit != null) { this.parsedUnit.cleanUp(); this.parsedUnit = null; } this.nodeSet = null; } public boolean equals(Object obj) {
static class IntArrayList { public int[] list = new int[5]; public int length = 0; public void add(int i) { if (this.list.length == this.length) { System.arraycopy(this.list, 0, this.list = new int[this.length*2], 0, this.length); } this.list[this.length++] = i; } }
unit.resolve(); if (!this.options.ignoreMethodBodies) unit.analyseCode(); // flow analysis if (!this.options.ignoreMethodBodies) unit.generateCode(); // code generation unit.finalizeProblems();
DefaultBindingResolver(LookupEnvironment lookupEnvironment, WorkingCopyOwner workingCopyOwner, BindingTables bindingTables, boolean isRecoveringBindings, boolean fromJavaProject) { this.newAstToOldAst = new HashMap(); this.astNodesToBlockScope = new HashMap(); this.bindingsToAstNodes = new HashMap(); this.bindingTables = bindingTables; this.scope = new CompilationUnitScope(new CompilationUnitDeclaration(null, null, -1), lookupEnvironment); this.workingCopyOwner = workingCopyOwner; this.isRecoveringBindings = isRecoveringBindings; this.fromJavaProject = fromJavaProject; }
for (CompilationUnitDeclaration unit : ecjResult.getCompilationUnits()) { CategorizedProblem[] problems = unit.compilationResult() .getAllProblems(); if (problems != null) {
/** * Creates an IImportDeclaration from the given import statement */ protected IJavaElement createPackageDeclarationHandle(CompilationUnitDeclaration unit) { if (unit.isPackageInfo()) { char[] packName = CharOperation.concatWith(unit.currentPackage.getImportName(), '.'); Openable openable = this.currentPossibleMatch.openable; if (openable instanceof CompilationUnit) { return ((CompilationUnit) openable).getPackageDeclaration(new String(packName)); } } return createTypeHandle(new String(unit.getMainTypeName())); } /**
public boolean isPackageInfo() { return CharOperation.equals(getMainTypeName(), TypeConstants.PACKAGE_INFO_NAME); }