List of usage examples for org.eclipse.jdt.internal.core.util BindingKeyResolver getKey
public String getKey()
From source file:org.eclipse.jdt.core.dom.CompilationUnitResolver.java
License:Open Source License
/** * Add the initial set of compilation units into the loop * -> build compilation unit declarations, their bindings and record their results. *//*ww w.j a va 2 s. c o m*/ protected void beginToCompile(org.eclipse.jdt.internal.compiler.env.ICompilationUnit[] sourceUnits, String[] bindingKeys) { int sourceLength = sourceUnits.length; int keyLength = bindingKeys.length; int maxUnits = sourceLength + keyLength; this.totalUnits = 0; this.unitsToProcess = new CompilationUnitDeclaration[maxUnits]; int index = 0; // walks the source units this.requestedSources = new HashtableOfObject(); for (int i = 0; i < sourceLength; i++) { org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = sourceUnits[i]; CompilationUnitDeclaration parsedUnit; CompilationResult unitResult = new CompilationResult(sourceUnit, index++, maxUnits, this.options.maxProblemsPerUnit); try { if (this.options.verbose) { this.out.println( Messages.bind(Messages.compilation_request, new String[] { String.valueOf(index++ + 1), String.valueOf(maxUnits), new String(sourceUnit.getFileName()) })); } // diet parsing for large collection of units if (this.totalUnits < this.parseThreshold) { parsedUnit = this.parser.parse(sourceUnit, unitResult); } else { parsedUnit = this.parser.dietParse(sourceUnit, unitResult); } // initial type binding creation this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/); addCompilationUnit(sourceUnit, parsedUnit); this.requestedSources.put(unitResult.getFileName(), sourceUnit); worked(1); } finally { sourceUnits[i] = null; // no longer hold onto the unit } } // walk the binding keys this.requestedKeys = new HashtableOfObject(); for (int i = 0; i < keyLength; i++) { BindingKeyResolver resolver = new BindingKeyResolver(bindingKeys[i], this, this.lookupEnvironment); resolver.parse(true/*pause after fully qualified name*/); // If it doesn't have a type name, then it is either an array type, package or base type, which will definitely not have a compilation unit. // Skipping it will speed up performance because the call will open jars. (theodora) CompilationUnitDeclaration parsedUnit = resolver.hasTypeName() ? resolver.getCompilationUnitDeclaration() : null; if (parsedUnit != null) { char[] fileName = parsedUnit.compilationResult.getFileName(); Object existing = this.requestedKeys.get(fileName); if (existing == null) this.requestedKeys.put(fileName, resolver); else if (existing instanceof ArrayList) ((ArrayList) existing).add(resolver); else { ArrayList list = new ArrayList(); list.add(existing); list.add(resolver); this.requestedKeys.put(fileName, list); } } else { char[] key = resolver.hasTypeName() ? resolver.getKey().toCharArray() // binary binding : CharOperation.concatWith(resolver.compoundName(), '.'); // package binding or base type binding this.requestedKeys.put(key, resolver); } worked(1); } // binding resolution this.lookupEnvironment.completeTypeBindings(); }
From source file:org.eclipse.jdt.core.dom.CompilationUnitResolver.java
License:Open Source License
private void reportBinding(Object key, ASTRequestor astRequestor, WorkingCopyOwner owner, CompilationUnitDeclaration unit) { BindingKeyResolver keyResolver = (BindingKeyResolver) key; Binding compilerBinding = keyResolver.getCompilerBinding(); if (compilerBinding != null) { DefaultBindingResolver resolver = new DefaultBindingResolver(unit.scope, owner, this.bindingTables, false, this.fromJavaProject); AnnotationBinding annotationBinding = keyResolver.getAnnotationBinding(); IBinding binding;//from w w w .java 2 s . c o m if (annotationBinding != null) { binding = resolver.getAnnotationInstance(annotationBinding); } else { binding = resolver.getBinding(compilerBinding); } if (binding != null) astRequestor.acceptBinding(keyResolver.getKey(), binding); } }
From source file:org.eclipse.jdt.core.dom.CompilationUnitResolver.java
License:Open Source License
private void reportBinding(Object key, FileASTRequestor astRequestor, CompilationUnitDeclaration unit) { BindingKeyResolver keyResolver = (BindingKeyResolver) key; Binding compilerBinding = keyResolver.getCompilerBinding(); if (compilerBinding != null) { DefaultBindingResolver resolver = new DefaultBindingResolver(unit.scope, null, this.bindingTables, false, this.fromJavaProject); AnnotationBinding annotationBinding = keyResolver.getAnnotationBinding(); IBinding binding;//from w w w. j a va 2 s . c o m if (annotationBinding != null) { binding = resolver.getAnnotationInstance(annotationBinding); } else { binding = resolver.getBinding(compilerBinding); } if (binding != null) astRequestor.acceptBinding(keyResolver.getKey(), binding); } }