Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaElement


   * the wizard page.
   *
   * @param selection Selection used to initialize the fields
   */
  public void init(IStructuredSelection selection) {
    IJavaElement jelem = getInitialJavaElement(selection);
    initContainerPage(jelem);
    initAspectPage(jelem);
    doStatusUpdate();
  }
View Full Code Here


    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
     */
    public void launch(IEditorPart editor, String mode) {
        IEditorInput input = editor.getEditorInput();
        IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class);
        if (je != null) {
            searchAndLaunch(new Object[] { je}, mode, true);
        } else {
            MessageDialog.openError(getShell(), "Launch failed", "The active editor does not contain a main type.");
        }
View Full Code Here

    private IJavaElement[] getJavaElements(Object[] objects) {
        List list = new ArrayList(objects.length);
        for (int i = 0; i < objects.length; i++) {
            Object object = objects[i];
            if (object instanceof IAdaptable) {
                IJavaElement element = (IJavaElement) ((IAdaptable) object).getAdapter(IJavaElement.class);
                if (element != null) {
                    list.add(element);
                }
            }
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
     */
    public void setDefaults(ILaunchConfigurationWorkingCopy config) {
        IJavaElement javaElement = getContext();
        if (javaElement != null) {
            initializeJavaProject(javaElement, config);
        } else {
            // We set empty attributes for project & main type so that when one config is
            // compared to another, the existence of empty attributes doesn't cause an
View Full Code Here

    private void setInput(ITextEditor editor) {
        javaEditor = null;
        setJavaInput(null);
        lastDecompiledResult = null;
        if (editor != null) {
            IJavaElement javaElem = EclipseUtils.getJavaInput(editor);
            if (javaElem == null) {
                return;
            }
            setJavaInput(javaElem);
            javaEditor = editor;
View Full Code Here

    protected void refreshView() {
        if (!isActive()) {
            return;
        }

        IJavaElement childEl = getCurrentJavaElement();
        if (childEl == null && javaInput == null) {
            setInput(javaEditor);
            childEl = javaInput;
        }
View Full Code Here

    /**
     * @return IJavaElement which fits in the current selection in java editor
     */
    private IJavaElement getCurrentJavaElement() {
        IJavaElement childEl = null;
        try {
            childEl = JdtUtils.getElementAtOffset(javaInput, currentSelection);
            if (childEl != null) {
                switch (childEl.getElementType()) {
                    case IJavaElement.METHOD :
                    case IJavaElement.FIELD :
                    case IJavaElement.INITIALIZER :
                    case IJavaElement.TYPE :
                        break;
                    case IJavaElement.LOCAL_VARIABLE :
                        childEl = childEl.getAncestor(IJavaElement.METHOD);
                        break;
                    default :
                        childEl = null;
                        break;
                }
View Full Code Here

     * @return return null if type is not known or bytecode is not written or cannot be
     * found
     */
    private DecompiledClass decompileBytecode(IJavaElement childEl) {
        // check here for inner classes too
        IJavaElement type = JdtUtils.getEnclosingType(childEl);
        if (type == null) {
            type = javaInput;
        }
        if (type == null) {
            return null;
        }
        InputStream is = JdtUtils.createInputStream(type);
        if (is == null) {
            return null;
        }
        DecompiledClass decompiledClass = null;
        int available = 0;
        try {
            ClassLoader cl = null;
            if (modes.get(BCOConstants.F_SHOW_ANALYZER)) {
                cl = JdtUtils.getClassLoader(type);
            }

            String fieldName = null;
            String methodName = null;
            /*
             * find out, which name we should use for selected element
             */
            if (modes.get(BCOConstants.F_SHOW_ONLY_SELECTED_ELEMENT)
                && childEl != null) {
                if (childEl.getElementType() == IJavaElement.FIELD) {
                    fieldName = childEl.getElementName();
                } else {
                    methodName = JdtUtils.getMethodSignature(childEl);
                }
            }
            available = is.available();
            decompiledClass = DecompilerClassVisitor.getDecompiledClass(
                is, fieldName, methodName, modes, cl);
        } catch (Exception e) {
            try {
                // check if compilation unit is ok - then this is the user problem
                if (type.isStructureKnown()) {
                    BytecodeOutlinePlugin.error("Cannot decompile: " + type, e);
                } else {
                    BytecodeOutlinePlugin.log(e, IStatus.ERROR);
                }
            } catch (JavaModelException e1) {
View Full Code Here

    public static IJavaElement getMethod(IParent parent, String signature){
        try {
            IJavaElement[] children = parent.getChildren();
            for (int i = 0; i < children.length; i++) {
                IJavaElement javaElement = children[i];
                switch (javaElement.getElementType()) {
                    case IJavaElement.INITIALIZER :
                        // fall through
                    case IJavaElement.METHOD :
                        if(signature.equals(getMethodSignature(javaElement))){
                            return javaElement;
View Full Code Here

    }

    public IJavaElement getJavaElement(int decompiledLine, IClassFile clazz) {
        DecompiledMethod method = getMethod(decompiledLine);
        if (method != null) {
            IJavaElement javaElement = (IJavaElement) methodToJavaElt
                .get(method);
            if (javaElement == null) {
                javaElement = JdtUtils.getMethod(clazz, method.getSignature());
                if (javaElement != null) {
                    methodToJavaElt.put(method, javaElement);
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.IJavaElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.