Example usage for org.eclipse.jdt.core JavaCore getPlugin

List of usage examples for org.eclipse.jdt.core JavaCore getPlugin

Introduction

In this page you can find the example usage for org.eclipse.jdt.core JavaCore getPlugin.

Prototype

public static Plugin getPlugin() 

Source Link

Document

Returns the single instance of the Java core plug-in runtime class.

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFile.java

License:Open Source License

public IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize) throws JavaModelException {
    JavaElement pkg = (JavaElement) getParent();
    if (pkg instanceof JarPackageFragment) {
        try {//from   ww w  .j  a v  a2 s . co  m
            IBinaryType info = getJarBinaryTypeInfo((PackageFragment) pkg, fullyInitialize);
            if (info == null) {
                throw newNotPresentException();
            }
            return info;
        } catch (ClassFormatException cfe) {
            //the structure remains unknown
            if (JavaCore.getPlugin().isDebugging()) {
                cfe.printStackTrace(System.err);
            }
            return null;
        } catch (IOException ioe) {
            throw new JavaModelException(ioe, IJavaModelStatusConstants.IO_EXCEPTION);
        } catch (CoreException e) {
            if (e instanceof JavaModelException) {
                throw (JavaModelException) e;
            } else {
                throw new JavaModelException(e);
            }
        }
    } else {
        //      byte[] contents = Util.getResourceContentsAsByteArray(file);
        //      try {
        //         return new ClassFileReader(contents, file.getFullPath().toString().toCharArray(), fullyInitialize);
        //      } catch (ClassFormatException cfe) {
        //         //the structure remains unknown
        //         return null;
        //      }
        throw new UnsupportedOperationException();
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.DeltaProcessingState.java

License:Open Source License

private File getTimeStampsFile() {
    return JavaCore.getPlugin().getStateLocation().append("externalLibsTimeStamps").toFile(); //$NON-NLS-1$
}

From source file:com.liferay.ide.sdk.core.SDKHelper.java

License:Open Source License

@Override
protected void addUserEntries(RuntimeClasspathModel model) throws CoreException {
    IPath[] antLibs = sdk.getAntLibraries();

    for (IPath antLib : antLibs) {
        if (antLib.toFile().exists()) {
            model.addEntry(RuntimeClasspathModel.USER, new LiferayRuntimeClasspathEntry(
                    JavaCore.newLibraryEntry(antLib.makeAbsolute(), null, null)));
        }//from w  w w. j a v  a  2 s  .  c o  m
    }

    //IDE-862 need to add Eclipse's own jdt.core that contains the necessary classes.
    try {
        File bundleFile = FileLocator.getBundleFile(JavaCore.getPlugin().getBundle());

        if (bundleFile.exists()) {
            model.addEntry(RuntimeClasspathModel.USER, new LiferayRuntimeClasspathEntry(
                    JavaCore.newLibraryEntry(new Path(bundleFile.getAbsolutePath()), null, null)));
        }
    } catch (Exception e) {
    }
}

From source file:it.xsemantics.build.tools.InternalBuilder.java

License:Open Source License

private void clearJdtIndex() {
    File jdtMetadata = JavaCore.getPlugin().getStateLocation().toFile();
    boolean success = false;
    try {/*  w  w  w .j a v  a2 s.c o  m*/
        cleanFolder(jdtMetadata);
        success = true;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    printMessage("Clean up index " + jdtMetadata.getAbsolutePath() + ": " + (success ? "success" : "fail"));
}

From source file:net.sf.commonclipse.Generator.java

License:Apache License

/**
 * Returns the indent of the given string.
 * @param line the text line//w  w w .j ava2 s.com
 * @return indent level
 */
public int computeIndent(String line) {
    Preferences preferences = JavaCore.getPlugin().getPluginPreferences();
    int tabWidth = preferences.getInt(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);

    int result = 0;
    int blanks = 0;
    int size = line.length();
    for (int i = 0; i < size; i++) {
        char c = line.charAt(i);
        if (c == '\t') {
            result++;
            blanks = 0;
        } else if (Character.isWhitespace(c) && !(c == '\n' || c == '\r')) {
            blanks++;
            if (blanks == tabWidth) {
                result++;
                blanks = 0;
            }
        } else {
            return result;
        }
    }
    return result;
}

From source file:org.codehaus.jdt.groovy.integration.LanguageSupportFactory.java

License:Open Source License

private static void log(Exception e) {
    if (JavaCore.getPlugin() == null || JavaCore.getPlugin().getLog() == null) {
        System.err.println("Error creating Groovy language support:"); //$NON-NLS-1$
        e.printStackTrace(System.err);
    } else {//from   w w w. j  a v  a2  s  . c  om
        Util.log(e, "Error creating Groovy language support"); //$NON-NLS-1$
    }
}

From source file:org.eclipse.ajdt.internal.ui.ajde.UIMessageHandler.java

License:Open Source License

/**
 * returns -1 if problem is not a task and the tasks priority otherwise
 * takes case sensitivity into account though this does not seem to
 * supported by the current compiler (AJDT 1.1.10)
 *///from   w w w .  ja v a  2s  .  co  m
private int getTaskPriority(ProblemTracker p) {
    if (p == null)
        return -1;

    String message = p.message;

    Preferences pref = JavaCore.getPlugin().getPluginPreferences();
    String tags = pref.getString("org.eclipse.jdt.core.compiler.taskTags"); //$NON-NLS-1$
    String caseSens = pref.getString("org.eclipse.jdt.core.compiler.taskCaseSensitive"); //$NON-NLS-1$
    String priorities = pref.getString("org.eclipse.jdt.core.compiler.taskPriorities"); //$NON-NLS-1$

    boolean caseSensitive;
    if (caseSens.equals("disabled")) { //$NON-NLS-1$
        caseSensitive = false;
    } else {
        caseSensitive = true;
    }

    StringTokenizer tagTokens = new StringTokenizer(tags, ","); //$NON-NLS-1$
    StringTokenizer priorityTokens = new StringTokenizer(priorities, ","); //$NON-NLS-1$
    while (tagTokens.hasMoreTokens()) {
        String prio = priorityTokens.nextToken();
        String token = tagTokens.nextToken();
        if (caseSensitive) {
            if (message.startsWith(token))
                return getPrioritiyFlag(prio);
        } else {
            if (token.length() <= message.length()) {
                String temp = message.substring(0, token.length());
                if (token.compareToIgnoreCase(temp) == 0)
                    return getPrioritiyFlag(prio);
            }
        }

    }
    return -1;
}

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  .  ja  v a 2s.  com*/
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.JavaModelManager.java

License:Open Source License

private File getVariableAndContainersFile() {
    return JavaCore.getPlugin().getStateLocation().append("variablesAndContainers.dat").toFile(); //$NON-NLS-1$
}

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

License:Open Source License

/**
  * Returns the name of the variables for which an CP variable initializer is registered through an extension point
  *//*from   www.j a va2 s . c o  m*/
public static String[] getRegisteredVariableNames() {

    Plugin jdtCorePlugin = JavaCore.getPlugin();
    if (jdtCorePlugin == null)
        return null;

    ArrayList variableList = new ArrayList(5);
    IExtensionPoint extension = Platform.getExtensionRegistry().getExtensionPoint(JavaCore.PLUGIN_ID,
            JavaModelManager.CPVARIABLE_INITIALIZER_EXTPOINT_ID);
    if (extension != null) {
        IExtension[] extensions = extension.getExtensions();
        for (int i = 0; i < extensions.length; i++) {
            IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
            for (int j = 0; j < configElements.length; j++) {
                String varAttribute = configElements[j].getAttribute("variable"); //$NON-NLS-1$
                if (varAttribute != null)
                    variableList.add(varAttribute);
            }
        }
    }
    String[] variableNames = new String[variableList.size()];
    variableList.toArray(variableNames);
    return variableNames;
}