Package org.eclipse.jdt.core

Examples of org.eclipse.jdt.core.IJavaElement


     */
    private static int getAnonCompilePriority50(IJavaElement javaElement,
        IJavaElement firstAncestor, IJavaElement topAncestor) {

        // search for initializer block
        IJavaElement initBlock = getLastAncestor(javaElement, IJavaElement.INITIALIZER);
        // test is for anon. classes from initializer blocks
        if (initBlock != null) {
            return 10; // from inner from class init
        }

View Full Code Here


        IJavaElement firstAncestor, IJavaElement topAncestor, boolean is50OrHigher) {
        if(is50OrHigher){
            return getAnonCompilePriority50(elt, firstAncestor, topAncestor);
        }

        IJavaElement firstNonAnon = getFirstNonAnonymous(elt, topAncestor);

        // get rid of children from local types
        if(topAncestor != firstNonAnon && isLocal(firstNonAnon)){
            return 5; // local anon. types have same prio as anon. from regular code
        }

        IJavaElement initBlock = getLastAncestor(elt, IJavaElement.INITIALIZER);
        // test is for anon. classes from initializer blocks
        if (initBlock != null) {
            if(isAnyParentLocal(firstAncestor, topAncestor)){
                return 5; // init blocks from local types have same prio as regular
            }
View Full Code Here

        IClassFile classFile = getClassFile();
        if (classFile == null) {
            return null;
        }
        IJavaElement result = null;
        if (isDecompiled()) {
            IDocument document = getDocumentProvider().getDocument(
                getEditorInput());
            try {
                // XXX have test if the requested line is from bytecode or sourcecode?!?
View Full Code Here

        } else {
            int offset = sourceViewer.getVisibleRegion().getOffset();
            caret = offset + styledText.getCaretOffset();
        }

        IJavaElement element = getElementAt(caret);

        if (!(element instanceof ISourceReference)) {
            return null;
        }
        return (ISourceReference) element;
View Full Code Here

     * @param file the class file
     * @return the package fragment root of the given class file
     */
    IPackageFragmentRoot getPackageFragmentRoot(IClassFile file) {

        IJavaElement element= file.getParent();
        while (element != null && element.getElementType() != IJavaElement.PACKAGE_FRAGMENT_ROOT) {
            element= element.getParent();
        }

        return (IPackageFragmentRoot) element;
    }
View Full Code Here

         * Very simple comparision based on init/not init block decision and then on the
         * source code position
         */
        private int compare50(IType m1, IType m2){

            IJavaElement firstAncestor1 = getFirstAncestor(m1);
            IJavaElement firstAncestor2 = getFirstAncestor(m2);

            int compilePrio1 = getCompilePrio(m1, firstAncestor1);
            int compilePrio2 = getCompilePrio(m2, firstAncestor2);

            if (compilePrio1 > compilePrio2) {
View Full Code Here

            IType m2 = (IType) o2;
            if(is50OrHigher){
                return compare50(m1, m2);
            }

            IJavaElement firstAncestor1 = getFirstAncestor(m1);
            IJavaElement firstAncestor2 = getFirstAncestor(m2);

            int compilePrio1 = getCompilePrio(m1, firstAncestor1);
            int compilePrio2 = getCompilePrio(m2, firstAncestor2);

            if (compilePrio1 > compilePrio2) {
View Full Code Here

     * @return editor input as IJavaElement
     */
    public static IJavaElement getJavaInput(IEditorPart part) {
        IEditorInput editorInput = part.getEditorInput();
        if (editorInput != null) {
            IJavaElement input = (IJavaElement) editorInput
                .getAdapter(IJavaElement.class);
            return input;
        }
        return null;
    }
View Full Code Here

        int type = resource.getElementType();
        if (type == IJavaElement.PACKAGE_FRAGMENT
            || type == IJavaElement.PACKAGE_FRAGMENT_ROOT) {
            return name;
        }
        IJavaElement ancestor = resource
            .getAncestor(IJavaElement.PACKAGE_FRAGMENT);
        if (ancestor != null) {
            return ancestor.getElementName();
        }
        return ""; //$NON-NLS-1$
    }
View Full Code Here

    public void run(IAction action) {
        // always only one element!
        IJavaElement[] resources = getSelectedResources();

        // select one from input dialog
        IJavaElement element2 = selectJavaElement();
        if (element2 == null) {
            return;
        }
        try {
            exec(resources[0], element2);
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.