Example usage for org.eclipse.jdt.internal.core JavaModelManager ZIP_ACCESS_VERBOSE

List of usage examples for org.eclipse.jdt.internal.core JavaModelManager ZIP_ACCESS_VERBOSE

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core JavaModelManager ZIP_ACCESS_VERBOSE.

Prototype

boolean ZIP_ACCESS_VERBOSE

To view the source code for org.eclipse.jdt.internal.core JavaModelManager ZIP_ACCESS_VERBOSE.

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.MatchLocator.java

License:Open Source License

public static ClassFileReader classFileReader(IType type) {
    IClassFile classFile = type.getClassFile();
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    if (classFile.isOpen())
        return (ClassFileReader) manager.getInfo(type);

    PackageFragment pkg = (PackageFragment) type.getPackageFragment();
    IPackageFragmentRoot root = (IPackageFragmentRoot) pkg.getParent();
    try {//from   www  . ja v  a 2  s  .c o  m
        if (!root.isArchive())
            return Util.newClassFileReader(((JavaElement) type).resource());

        ZipFile zipFile = null;
        try {
            IPath zipPath = root.getPath();
            if (JavaModelManager.ZIP_ACCESS_VERBOSE)
                System.out.println("(" + Thread.currentThread()
                        + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$   //$NON-NLS-2$
            zipFile = manager.getZipFile(zipPath);
            String classFileName = classFile.getElementName();
            String path = Util.concatWith(pkg.names, classFileName, '/');
            return ClassFileReader.read(zipFile, path);
        } finally {
            manager.closeZipFile(zipFile);
        }
    } catch (ClassFormatException e) {
        // invalid class file: return null
    } catch (CoreException e) {
        // cannot read class file: return null
    } catch (IOException e) {
        // cannot read class file: return null
    }
    return null;
}

From source file:org.eclipse.che.jdt.core.ToolFactory.java

License:Open Source License

/**
 * Create a default classfile reader, able to expose the internal representation of a given classfile
 * according to the decoding flag used to initialize the reader.
 * Answer null if the file named zipFileName doesn't represent a valid zip file or if the zipEntryName
 * is not a valid entry name for the specified zip file or if the bytes don't represent a valid
 * .class file according to the JVM specifications.
 * <p/>//from   ww w.j  ava 2  s .c  o m
 * The decoding flags are described in IClassFileReader.
 *
 * @param zipFileName
 *         the name of the zip file
 * @param zipEntryName
 *         the name of the entry in the zip file to be read
 * @param decodingFlag
 *         the flag used to decode the class file reader.
 * @return a default classfile reader
 * @see org.eclipse.jdt.core.util.IClassFileReader
 */
public static IClassFileReader createDefaultClassFileReader(String zipFileName, String zipEntryName,
        int decodingFlag) {
    ZipFile zipFile = null;
    try {
        if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
            System.out.println("(" + Thread.currentThread()
                    + ") [ToolFactory.createDefaultClassFileReader()] Creating ZipFile on " + zipFileName); //$NON-NLS-1$   //$NON-NLS-2$
        }
        zipFile = new ZipFile(zipFileName);
        ZipEntry zipEntry = zipFile.getEntry(zipEntryName);
        if (zipEntry == null) {
            return null;
        }
        if (!zipEntryName.toLowerCase().endsWith(SuffixConstants.SUFFIX_STRING_class)) {
            return null;
        }
        byte classFileBytes[] = Util.getZipEntryByteContent(zipEntry, zipFile);
        return new ClassFileReader(classFileBytes, decodingFlag);
    } catch (ClassFormatException e) {
        return null;
    } catch (IOException e) {
        return null;
    } finally {
        if (zipFile != null) {
            try {
                zipFile.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}

From source file:org.eclipse.jdt.internal.core.JavaModelManager.java

License:Open Source License

public void closeZipFile(ZipFile zipFile) {
    if (zipFile == null)
        return;/*w  w  w  .  j av a 2  s.  com*/
    if (this.zipFiles.get() != null) {
        return; // zip file will be closed by call to flushZipFiles
    }
    try {
        if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
            System.out.println("(" + Thread.currentThread() //$NON-NLS-1$
                    + ") [JavaModelManager.closeZipFile(ZipFile)] Closing ZipFile on " + zipFile.getName()); //$NON-NLS-1$
        }
        zipFile.close();
    } catch (IOException e) {
        // problem occured closing zip file: cannot do much more
    }
}

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  w w w .j av  a  2s. c  o 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.search.matching.MatchLocator.java

License:Open Source License

public static ClassFileReader classFileReader(IType type) {
    IClassFile classFile = type.getClassFile();
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    if (classFile.isOpen())
        return (ClassFileReader) manager.getInfo(type);

    PackageFragment pkg = (PackageFragment) type.getPackageFragment();
    IPackageFragmentRoot root = (IPackageFragmentRoot) pkg.getParent();
    try {//  w  w w.ja v  a 2s . co  m
        if (!root.isArchive())
            return Util.newClassFileReader(((JavaElement) type).resource());

        ZipFile zipFile = null;
        try {
            IPath zipPath = root.getPath();
            if (JavaModelManager.ZIP_ACCESS_VERBOSE)
                System.out.println("(" + Thread.currentThread() //$NON-NLS-1$
                        + ") [MatchLocator.classFileReader()] Creating ZipFile on " + zipPath); //$NON-NLS-1$
            zipFile = manager.getZipFile(zipPath);
            String classFileName = classFile.getElementName();
            String path = Util.concatWith(pkg.names, classFileName, '/');
            return ClassFileReader.read(zipFile, path);
        } finally {
            manager.closeZipFile(zipFile);
        }
    } catch (ClassFormatException e) {
        // invalid class file: return null
    } catch (CoreException e) {
        // cannot read class file: return null
    } catch (IOException e) {
        // cannot read class file: return null
    }
    return null;
}