List of usage examples for org.eclipse.jdt.internal.core JavaModelManager CP_RESOLVE_VERBOSE_FAILURE
boolean CP_RESOLVE_VERBOSE_FAILURE
To view the source code for org.eclipse.jdt.internal.core JavaModelManager CP_RESOLVE_VERBOSE_FAILURE.
Click Source Link
From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
private static void resolvedChainedLibraries(IPath jarPath, HashSet visited, ArrayList result) { if (visited.contains(jarPath)) return;/*from w w w. j a v a 2s . com*/ visited.add(jarPath); JavaModelManager manager = JavaModelManager.getJavaModelManager(); if (manager.isNonChainingJar(jarPath)) return; List calledFileNames = getCalledFileNames(jarPath); if (calledFileNames == null) { manager.addNonChainingJar(jarPath); } else { Iterator calledFilesIterator = calledFileNames.iterator(); IPath directoryPath = jarPath.removeLastSegments(1); while (calledFilesIterator.hasNext()) { String calledFileName = (String) calledFilesIterator.next(); if (!directoryPath.isValidPath(calledFileName)) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " //$NON-NLS-1$//$NON-NLS-2$ + jarPath.toOSString()); } } else { IPath calledJar = directoryPath.append(new Path(calledFileName)); // Ignore if segment count is Zero (https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150) if (calledJar.segmentCount() == 0) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " //$NON-NLS-1$//$NON-NLS-2$ + jarPath.toOSString()); } continue; } resolvedChainedLibraries(calledJar, visited, result); result.add(calledJar); } } } }
From source file:com.codenvy.ide.ext.java.server.internal.core.ClasspathEntry.java
License:Open Source License
private static List getCalledFileNames(IPath jarPath) { Object target = JavaModel.getTarget(jarPath, true/*check existence, otherwise the manifest cannot be read*/); if (!(target instanceof IFile || target instanceof File)) return null; JavaModelManager manager = JavaModelManager.getJavaModelManager(); ZipFile zip = null;/*from w ww . j av a 2s. co m*/ InputStream inputStream = null; List calledFileNames = null; try { zip = manager.getZipFile(jarPath); ZipEntry manifest = zip.getEntry("META-INF/MANIFEST.MF"); //$NON-NLS-1$ if (manifest == null) return null; // non-null implies regular file ManifestAnalyzer analyzer = new ManifestAnalyzer(); inputStream = zip.getInputStream(manifest); boolean success = analyzer.analyzeManifestContents(inputStream); calledFileNames = analyzer.getCalledFileNames(); if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ } return null; } else if (analyzer.getClasspathSectionsCount() > 1) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Multiple Class-Path headers in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ } return null; } } catch (CoreException e) { // not a zip file if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Could not read Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ e.printStackTrace(); } } catch (IOException e) { // not a zip file if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Could not read Class-Path header in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ e.printStackTrace(); } } finally { if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { // best effort } } manager.closeZipFile(zip); } return calledFileNames; }
From source file:org.eclipse.che.jdt.internal.core.ClasspathEntry.java
License:Open Source License
private static void resolvedChainedLibraries(IPath jarPath, HashSet visited, ArrayList result) { if (visited.contains(jarPath)) return;/* w w w . j a va 2 s. c o m*/ visited.add(jarPath); JavaModelManager manager = JavaModelManager.getJavaModelManager(); if (manager.isNonChainingJar(jarPath)) return; List calledFileNames = getCalledFileNames(jarPath); if (calledFileNames == null) { manager.addNonChainingJar(jarPath); } else { Iterator calledFilesIterator = calledFileNames.iterator(); IPath directoryPath = jarPath.removeLastSegments(1); while (calledFilesIterator.hasNext()) { String calledFileName = (String) calledFilesIterator.next(); if (!directoryPath.isValidPath(calledFileName)) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } } else { IPath calledJar = directoryPath.append(new Path(calledFileName)); // Ignore if segment count is Zero (https://bugs.eclipse.org/bugs/show_bug.cgi?id=308150) if (calledJar.segmentCount() == 0) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { Util.verbose("Invalid Class-Path entry " + calledFileName + " in manifest of jar file: " + jarPath.toOSString()); //$NON-NLS-1$ //$NON-NLS-2$ } continue; } resolvedChainedLibraries(calledJar, visited, result); result.add(calledJar); } } } }
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 av a2s . co m*/ 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); } }
From source file:org.eclipse.jdt.internal.core.JavaProject.java
License:Open Source License
public ResolvedClasspath resolveClasspath(IClasspathEntry[] rawClasspath, IClasspathEntry[] referencedEntries, boolean usePreviousSession, boolean resolveChainedLibraries) throws JavaModelException { JavaModelManager manager = JavaModelManager.getJavaModelManager(); ExternalFoldersManager externalFoldersManager = JavaModelManager.getExternalManager(); ResolvedClasspath result = new ResolvedClasspath(); Map knownDrives = new HashMap(); Map referencedEntriesMap = new HashMap(); List rawLibrariesPath = new ArrayList(); LinkedHashSet resolvedEntries = new LinkedHashSet(); if (resolveChainedLibraries) { for (int index = 0; index < rawClasspath.length; index++) { IClasspathEntry currentEntry = rawClasspath[index]; if (currentEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { rawLibrariesPath// w w w . java 2 s .co m .add(ClasspathEntry.resolveDotDot(getProject().getLocation(), currentEntry.getPath())); } } if (referencedEntries != null) { // The Set is required to keep the order intact while the referencedEntriesMap (Map) // is used to map the referenced entries with path LinkedHashSet referencedEntriesSet = new LinkedHashSet(); for (int index = 0; index < referencedEntries.length; index++) { IPath path = referencedEntries[index].getPath(); if (!rawLibrariesPath.contains(path) && referencedEntriesMap.get(path) == null) { referencedEntriesMap.put(path, referencedEntries[index]); referencedEntriesSet.add(referencedEntries[index]); } } if (referencedEntriesSet.size() > 0) { result.referencedEntries = new IClasspathEntry[referencedEntriesSet.size()]; referencedEntriesSet.toArray(result.referencedEntries); } } } int length = rawClasspath.length; for (int i = 0; i < length; i++) { IClasspathEntry rawEntry = rawClasspath[i]; IClasspathEntry resolvedEntry = rawEntry; switch (rawEntry.getEntryKind()) { case IClasspathEntry.CPE_VARIABLE: try { resolvedEntry = manager.resolveVariableEntry(rawEntry, usePreviousSession); } catch (ClasspathEntry.AssertionFailedException e) { // Catch the assertion failure and set status instead // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=55992 result.unresolvedEntryStatus = new JavaModelStatus(IJavaModelStatusConstants.INVALID_PATH, e.getMessage()); break; } if (resolvedEntry == null) { result.unresolvedEntryStatus = new JavaModelStatus( IJavaModelStatusConstants.CP_VARIABLE_PATH_UNBOUND, this, rawEntry.getPath()); } else { // If the entry is already present in the rawReversetMap, it means the entry and the chained libraries // have already been processed. So, skip it. if (resolveChainedLibraries && resolvedEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY && result.rawReverseMap.get(resolvedEntry.getPath()) == null) { // resolve Class-Path: in manifest ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries(); for (int j = 0, length2 = extraEntries.length; j < length2; j++) { if (!rawLibrariesPath.contains(extraEntries[j].getPath())) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=305037 // referenced entries for variable entries could also be persisted with extra attributes, so addAsChainedEntry = true addToResult(rawEntry, extraEntries[j], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, true, knownDrives); } } } addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives); } break; case IClasspathEntry.CPE_CONTAINER: IClasspathContainer container = usePreviousSession ? manager.getPreviousSessionContainer(rawEntry.getPath(), this) : JavaCore.getClasspathContainer(rawEntry.getPath(), this); if (container == null) { result.unresolvedEntryStatus = new JavaModelStatus( IJavaModelStatusConstants.CP_CONTAINER_PATH_UNBOUND, this, rawEntry.getPath()); break; } IClasspathEntry[] containerEntries = container.getClasspathEntries(); if (containerEntries == null) { if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { JavaModelManager.getJavaModelManager().verbose_missbehaving_container_null_entries(this, rawEntry.getPath()); } break; } // container was bound for (int j = 0, containerLength = containerEntries.length; j < containerLength; j++) { ClasspathEntry cEntry = (ClasspathEntry) containerEntries[j]; if (cEntry == null) { if (JavaModelManager.CP_RESOLVE_VERBOSE || JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { JavaModelManager.getJavaModelManager().verbose_missbehaving_container(this, rawEntry.getPath(), containerEntries); } break; } // if container is exported or restricted, then its nested entries must in turn be exported (21749) and/or propagate restrictions cEntry = cEntry.combineWith((ClasspathEntry) rawEntry); if (cEntry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { // resolve ".." in library path cEntry = cEntry.resolvedDotDot(getProject().getLocation()); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=313965 // Do not resolve if the system attribute is set to false if (resolveChainedLibraries && JavaModelManager.getJavaModelManager().resolveReferencedLibrariesForContainers && result.rawReverseMap.get(cEntry.getPath()) == null) { // resolve Class-Path: in manifest ClasspathEntry[] extraEntries = cEntry.resolvedChainedLibraries(); for (int k = 0, length2 = extraEntries.length; k < length2; k++) { if (!rawLibrariesPath.contains(extraEntries[k].getPath())) { addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives); } } } } addToResult(rawEntry, cEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives); } break; case IClasspathEntry.CPE_LIBRARY: // resolve ".." in library path resolvedEntry = ((ClasspathEntry) rawEntry).resolvedDotDot(getProject().getLocation()); if (resolveChainedLibraries && result.rawReverseMap.get(resolvedEntry.getPath()) == null) { // resolve Class-Path: in manifest ClasspathEntry[] extraEntries = ((ClasspathEntry) resolvedEntry).resolvedChainedLibraries(); for (int k = 0, length2 = extraEntries.length; k < length2; k++) { if (!rawLibrariesPath.contains(extraEntries[k].getPath())) { addToResult(rawEntry, extraEntries[k], result, resolvedEntries, externalFoldersManager, referencedEntriesMap, true, knownDrives); } } } addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives); break; default: addToResult(rawEntry, resolvedEntry, result, resolvedEntries, externalFoldersManager, referencedEntriesMap, false, knownDrives); break; } } result.resolvedClasspath = new IClasspathEntry[resolvedEntries.size()]; resolvedEntries.toArray(result.resolvedClasspath); return result; }