List of usage examples for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy DEBUG
boolean DEBUG
To view the source code for org.eclipse.jdt.internal.core.hierarchy TypeHierarchy DEBUG.
Click Source Link
From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java
License:Open Source License
/** * Connect the supplied type to its superclass & superinterfaces. * The superclass & superinterfaces are the identical binary or source types as * supplied by the name environment.//from w ww. j a v a 2 s . c o m */ public void connect(IGenericType type, IType typeHandle, IType superclassHandle, IType[] superinterfaceHandles) { /* * Temporary workaround for 1G2O5WK: ITPJCORE:WINNT - NullPointerException when selecting "Show in Type Hierarchy" for a inner class */ if (typeHandle == null) return; if (TypeHierarchy.DEBUG) { System.out.println("Connecting: " + ((JavaElement) typeHandle).toStringWithAncestors()); //$NON-NLS-1$ System.out.println(" to superclass: " //$NON-NLS-1$ + (superclassHandle == null ? "<None>" //$NON-NLS-1$ : ((JavaElement) superclassHandle).toStringWithAncestors())); System.out.print(" and superinterfaces:"); //$NON-NLS-1$ if (superinterfaceHandles == null || superinterfaceHandles.length == 0) { System.out.println(" <None>"); //$NON-NLS-1$ } else { System.out.println(); for (int i = 0, length = superinterfaceHandles.length; i < length; i++) { if (superinterfaceHandles[i] == null) continue; System.out.println(" " + ((JavaElement) superinterfaceHandles[i]).toStringWithAncestors()); //$NON-NLS-1$ } } } // now do the caching switch (TypeDeclaration.kind(type.getModifiers())) { case TypeDeclaration.CLASS_DECL: case TypeDeclaration.ENUM_DECL: if (superclassHandle == null) { this.hierarchy.addRootClass(typeHandle); } else { this.hierarchy.cacheSuperclass(typeHandle, superclassHandle); } break; case TypeDeclaration.INTERFACE_DECL: case TypeDeclaration.ANNOTATION_TYPE_DECL: // https://bugs.eclipse.org/bugs/show_bug.cgi?id=329663 if (this.hierarchy.typeToSuperInterfaces.get(typeHandle) == null) this.hierarchy.addInterface(typeHandle); break; } if (superinterfaceHandles == null) { superinterfaceHandles = TypeHierarchy.NO_TYPE; } this.hierarchy.cacheSuperInterfaces(typeHandle, superinterfaceHandles); // record flags this.hierarchy.cacheFlags(typeHandle, type.getModifiers()); }
From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java
License:Open Source License
/** * Creates the type info from the given class file on disk and * adds it to the given list of infos./*from w w w . j av a2s. c o m*/ */ protected IBinaryType createInfoFromClassFile(Openable handle, IResource file) { IBinaryType info = null; try { info = Util.newClassFileReader(file); } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } return null; } catch (java.io.IOException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } return null; } catch (CoreException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } return null; } this.infoToHandle.put(info, handle); return info; }
From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyBuilder.java
License:Open Source License
/** * Create a type info from the given class file in a jar and adds it to the given list of infos. *//* w w w.j a v a 2 s . co m*/ protected IBinaryType createInfoFromClassFileInJar(Openable classFile) { PackageFragment pkg = (PackageFragment) classFile.getParent(); String classFilePath = Util.concatWith(pkg.names, classFile.getElementName(), '/'); IBinaryType info = null; java.util.zip.ZipFile zipFile = null; try { zipFile = ((JarPackageFragmentRoot) pkg.getParent()).getJar(); info = org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.read(zipFile, classFilePath); } catch (org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } return null; } catch (java.io.IOException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } return null; } catch (CoreException e) { if (TypeHierarchy.DEBUG) { e.printStackTrace(); } return null; } finally { JavaModelManager.getJavaModelManager().closeZipFile(zipFile); } this.infoToHandle.put(info, classFile); return info; }
From source file:org.eclipse.jdt.internal.core.hierarchy.HierarchyResolver.java
License:Open Source License
/** * Resolve the supertypes for the types contained in the given openables (ICompilationUnits and/or IClassFiles). * Inform the requestor of the resolved supertypes for each * supplied source type using:/*from w ww . j a v a2 s . co m*/ * connect(ISourceType suppliedType, IGenericType superclass, IGenericType[] superinterfaces) * * Also inform the requestor of the supertypes of each * additional requested super type which is also a source type * instead of a binary type. * @param openables * @param localTypes * @param monitor */ public void resolve(Openable[] openables, HashSet localTypes, IProgressMonitor monitor) { try { int openablesLength = openables.length; CompilationUnitDeclaration[] parsedUnits = new CompilationUnitDeclaration[openablesLength]; boolean[] hasLocalType = new boolean[openablesLength]; org.eclipse.jdt.core.ICompilationUnit[] cus = new org.eclipse.jdt.core.ICompilationUnit[openablesLength]; int unitsIndex = 0; CompilationUnitDeclaration focusUnit = null; ReferenceBinding focusBinaryBinding = null; IType focus = this.builder.getType(); Openable focusOpenable = null; if (focus != null) { if (focus.isBinary()) { focusOpenable = (Openable) focus.getClassFile(); } else { focusOpenable = (Openable) focus.getCompilationUnit(); } } // build type bindings // GROOVY start: ensure downstream groovy parses share the same compilationunit /* old { Parser parser = new Parser(this.lookupEnvironment.problemReporter, true); } new */ Parser parser = LanguageSupportFactory.getParser(this, this.lookupEnvironment.globalOptions, this.lookupEnvironment.problemReporter, true, 1); // GROOVY end for (int i = 0; i < openablesLength; i++) { Openable openable = openables[i]; if (openable instanceof org.eclipse.jdt.core.ICompilationUnit) { org.eclipse.jdt.core.ICompilationUnit cu = (org.eclipse.jdt.core.ICompilationUnit) openable; // contains a potential subtype as a local or anonymous type? boolean containsLocalType = false; if (localTypes == null) { // case of hierarchy on region containsLocalType = true; } else { IPath path = cu.getPath(); containsLocalType = localTypes.contains(path.toString()); } // build parsed unit CompilationUnitDeclaration parsedUnit = null; if (cu.isOpen()) { // create parsed unit from source element infos CompilationResult result = new CompilationResult((ICompilationUnit) cu, i, openablesLength, this.options.maxProblemsPerUnit); SourceTypeElementInfo[] typeInfos = null; try { IType[] topLevelTypes = cu.getTypes(); int topLevelLength = topLevelTypes.length; if (topLevelLength == 0) continue; // empty cu: no need to parse (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=65677) typeInfos = new SourceTypeElementInfo[topLevelLength]; for (int j = 0; j < topLevelLength; j++) { IType topLevelType = topLevelTypes[j]; typeInfos[j] = (SourceTypeElementInfo) ((JavaElement) topLevelType) .getElementInfo(); } } catch (JavaModelException e) { // types/cu exist since cu is opened } int flags = !containsLocalType ? SourceTypeConverter.MEMBER_TYPE : SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE | SourceTypeConverter.LOCAL_TYPE; parsedUnit = SourceTypeConverter.buildCompilationUnit(typeInfos, flags, this.lookupEnvironment.problemReporter, result); // We would have got all the necessary local types by now and hence there is no further need // to parse the method bodies. Parser.getMethodBodies, which is called latter in this function, // will not parse the method statements if ASTNode.HasAllMethodBodies is set. if (containsLocalType) parsedUnit.bits |= ASTNode.HasAllMethodBodies; } else { // create parsed unit from file IFile file = (IFile) cu.getResource(); ICompilationUnit sourceUnit = this.builder.createCompilationUnitFromPath(openable, file); CompilationResult unitResult = new CompilationResult(sourceUnit, i, openablesLength, this.options.maxProblemsPerUnit); parsedUnit = parser.dietParse(sourceUnit, unitResult); } if (parsedUnit != null) { hasLocalType[unitsIndex] = containsLocalType; cus[unitsIndex] = cu; parsedUnits[unitsIndex++] = parsedUnit; try { this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/); if (openable.equals(focusOpenable)) { focusUnit = parsedUnit; } } catch (AbortCompilation e) { // classpath problem for this type: ignore } } } else { // cache binary type binding ClassFile classFile = (ClassFile) openable; IBinaryType binaryType = (IBinaryType) JavaModelManager.getJavaModelManager() .getInfo(classFile.getType()); if (binaryType == null) { // create binary type from file if (classFile.getPackageFragmentRoot().isArchive()) { binaryType = this.builder.createInfoFromClassFileInJar(classFile); } else { IResource file = classFile.resource(); binaryType = this.builder.createInfoFromClassFile(classFile, file); } } if (binaryType != null) { try { BinaryTypeBinding binaryTypeBinding = this.lookupEnvironment.cacheBinaryType(binaryType, false/*don't need field and method (bug 125067)*/, null /*no access restriction*/); remember(binaryType, binaryTypeBinding); if (openable.equals(focusOpenable)) { focusBinaryBinding = binaryTypeBinding; } } catch (AbortCompilation e) { // classpath problem for this type: ignore } } } } // remember type declaration of focus if local/anonymous early (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210498) TypeDeclaration focusLocalType = null; if (focus != null && focusBinaryBinding == null && focusUnit != null && ((Member) focus).getOuterMostLocalContext() != null) { focusLocalType = new ASTNodeFinder(focusUnit).findType(focus); } for (int i = 0; i <= this.typeIndex; i++) { IGenericType suppliedType = this.typeModels[i]; if (suppliedType != null && suppliedType.isBinaryType()) { CompilationUnitDeclaration previousUnitBeingCompleted = this.lookupEnvironment.unitBeingCompleted; // fault in its hierarchy... try { // ensure that unitBeingCompleted is set so that we don't get an AbortCompilation for a missing type // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=213249 ) if (previousUnitBeingCompleted == null) { this.lookupEnvironment.unitBeingCompleted = FakeUnit; } ReferenceBinding typeBinding = this.typeBindings[i]; typeBinding.superclass(); typeBinding.superInterfaces(); } catch (AbortCompilation e) { // classpath problem for this type: ignore } finally { this.lookupEnvironment.unitBeingCompleted = previousUnitBeingCompleted; } } } // complete type bindings (i.e. connect super types) for (int i = 0; i < unitsIndex; i++) { CompilationUnitDeclaration parsedUnit = parsedUnits[i]; if (parsedUnit != null) { try { if (hasLocalType[i]) { // NB: no-op if method bodies have been already parsed if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); parser.getMethodBodies(parsedUnit); } } catch (AbortCompilation e) { // classpath problem for this type: don't try to resolve (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=49809) hasLocalType[i] = false; } } } // complete type bindings and build fields and methods only for local types // (in this case the constructor is needed when resolving local types) // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=145333) try { this.lookupEnvironment.completeTypeBindings(parsedUnits, hasLocalType, unitsIndex); // remember type bindings for (int i = 0; i < unitsIndex; i++) { CompilationUnitDeclaration parsedUnit = parsedUnits[i]; if (parsedUnit != null && !parsedUnit.hasErrors()) { boolean containsLocalType = hasLocalType[i]; if (containsLocalType) { if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); parsedUnit.scope.faultInTypes(); parsedUnit.resolve(); } rememberAllTypes(parsedUnit, cus[i], containsLocalType); } } } catch (AbortCompilation e) { // skip it silently } worked(monitor, 1); // if no potential subtype was a real subtype of the binary focus type, no need to go further // (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=54043) if (focusBinaryBinding == null && focus != null && focus.isBinary()) { char[] fullyQualifiedName = focus.getFullyQualifiedName().toCharArray(); focusBinaryBinding = this.lookupEnvironment .getCachedType(CharOperation.splitOn('.', fullyQualifiedName)); if (focusBinaryBinding == null) return; } reportHierarchy(focus, focusLocalType, focusBinaryBinding); } catch (ClassCastException e) { // work-around for 1GF5W1S - can happen in case duplicates are fed to the hierarchy with binaries hiding sources } catch (AbortCompilation e) { // ignore this exception for now since it typically means we cannot find java.lang.Object if (TypeHierarchy.DEBUG) e.printStackTrace(); } finally { reset(); } }
From source file:org.eclipse.jdt.internal.core.JavaModelManager.java
License:Open Source License
/** * Configure the plugin with respect to option settings defined in ".options" file *//*from www . j a v a 2 s . c om*/ public void configurePluginDebugOptions() { if (JavaCore.getPlugin().isDebugging()) { String option = Platform.getDebugOption(BUFFER_MANAGER_DEBUG); if (option != null) BufferManager.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(BUILDER_DEBUG); if (option != null) JavaBuilder.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(COMPILER_DEBUG); if (option != null) Compiler.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(BUILDER_STATS_DEBUG); if (option != null) JavaBuilder.SHOW_STATS = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(COMPLETION_DEBUG); if (option != null) CompletionEngine.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(CP_RESOLVE_DEBUG); if (option != null) JavaModelManager.CP_RESOLVE_VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(CP_RESOLVE_ADVANCED_DEBUG); if (option != null) JavaModelManager.CP_RESOLVE_VERBOSE_ADVANCED = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(CP_RESOLVE_FAILURE_DEBUG); if (option != null) JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(DELTA_DEBUG); if (option != null) DeltaProcessor.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(DELTA_DEBUG_VERBOSE); if (option != null) DeltaProcessor.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(HIERARCHY_DEBUG); if (option != null) TypeHierarchy.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(INDEX_MANAGER_DEBUG); if (option != null) JobManager.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(INDEX_MANAGER_ADVANCED_DEBUG); if (option != null) IndexManager.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(JAVAMODEL_DEBUG); if (option != null) JavaModelManager.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(JAVAMODELCACHE_DEBUG); if (option != null) JavaModelCache.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(POST_ACTION_DEBUG); if (option != null) JavaModelOperation.POST_ACTION_VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(RESOLUTION_DEBUG); if (option != null) NameLookup.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(SEARCH_DEBUG); if (option != null) BasicSearchEngine.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(SELECTION_DEBUG); if (option != null) SelectionEngine.DEBUG = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(ZIP_ACCESS_DEBUG); if (option != null) JavaModelManager.ZIP_ACCESS_VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(SOURCE_MAPPER_DEBUG_VERBOSE); if (option != null) SourceMapper.VERBOSE = option.equalsIgnoreCase(TRUE); option = Platform.getDebugOption(FORMATTER_DEBUG); if (option != null) DefaultCodeFormatter.DEBUG = option.equalsIgnoreCase(TRUE); } // configure performance options if (PerformanceStats.ENABLED) { CompletionEngine.PERF = PerformanceStats.isEnabled(COMPLETION_PERF); SelectionEngine.PERF = PerformanceStats.isEnabled(SELECTION_PERF); DeltaProcessor.PERF = PerformanceStats.isEnabled(DELTA_LISTENER_PERF); JavaModelManager.PERF_VARIABLE_INITIALIZER = PerformanceStats.isEnabled(VARIABLE_INITIALIZER_PERF); JavaModelManager.PERF_CONTAINER_INITIALIZER = PerformanceStats.isEnabled(CONTAINER_INITIALIZER_PERF); ReconcileWorkingCopyOperation.PERF = PerformanceStats.isEnabled(RECONCILE_PERF); } }