Example usage for org.eclipse.jdt.core.compiler CharOperation NO_STRINGS

List of usage examples for org.eclipse.jdt.core.compiler CharOperation NO_STRINGS

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.compiler CharOperation NO_STRINGS.

Prototype

String[] NO_STRINGS

To view the source code for org.eclipse.jdt.core.compiler CharOperation NO_STRINGS.

Click Source Link

Document

Constant for an empty String array.

Usage

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

License:Open Source License

public String[] getCategories() throws JavaModelException {
    SourceMapper mapper = getSourceMapper();
    if (mapper != null) {
        // ensure the class file's buffer is open so that categories are computed
        ((ClassFile) getClassFile()).getBuffer();

        if (mapper.categories != null) {
            String[] categories = (String[]) mapper.categories.get(this);
            if (categories != null)
                return categories;
        }//from   w  w  w .  j a va 2s.  c  om
    }
    return CharOperation.NO_STRINGS;
}

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

License:Open Source License

protected BinaryMethod(JavaElement parent, JavaModelManager manager, String name, String[] paramTypes) {
    super(parent, manager, name);
    // Assertion disabled since bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=179011
    // Assert.isTrue(name.indexOf('.') == -1);
    if (paramTypes == null) {
        this.parameterTypes = CharOperation.NO_STRINGS;
    } else {//from   www. ja v a  2s. c om
        this.parameterTypes = paramTypes;
    }
}

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

License:Open Source License

public String[] getExceptionTypes() throws JavaModelException {
    if (this.exceptionTypes == null) {
        IBinaryMethod info = (IBinaryMethod) getElementInfo();
        char[] genericSignature = info.getGenericSignature();
        if (genericSignature != null) {
            char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
            this.exceptionTypes = Signature.getThrownExceptionTypes(new String(dotBasedSignature));
        }/*from  w  w  w  .  j  av a 2  s .  co  m*/
        if (this.exceptionTypes == null || this.exceptionTypes.length == 0) {
            char[][] eTypeNames = info.getExceptionTypeNames();
            if (eTypeNames == null || eTypeNames.length == 0) {
                this.exceptionTypes = CharOperation.NO_STRINGS;
            } else {
                eTypeNames = ClassFile.translatedNames(eTypeNames);
                this.exceptionTypes = new String[eTypeNames.length];
                for (int j = 0, length = eTypeNames.length; j < length; j++) {
                    // 1G01HRY: ITPJCORE:WINNT - method.getExceptionType not in correct format
                    int nameLength = eTypeNames[j].length;
                    char[] convertedName = new char[nameLength + 2];
                    System.arraycopy(eTypeNames[j], 0, convertedName, 1, nameLength);
                    convertedName[0] = 'L';
                    convertedName[nameLength + 1] = ';';
                    this.exceptionTypes[j] = new String(convertedName);
                }
            }
        }
    }
    return this.exceptionTypes;
}

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

License:Open Source License

/**
 * @see org.eclipse.jdt.core.IMethod#getTypeParameterSignatures()
 * @since 3.0//from  w  w w . jav a2 s.c  om
 * @deprecated
 */
public String[] getTypeParameterSignatures() throws JavaModelException {
    IBinaryMethod info = (IBinaryMethod) getElementInfo();
    char[] genericSignature = info.getGenericSignature();
    if (genericSignature == null)
        return CharOperation.NO_STRINGS;
    char[] dotBasedSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
    char[][] typeParams = Signature.getTypeParameters(dotBasedSignature);
    return CharOperation.toStrings(typeParams);
}

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

License:Open Source License

public String[] getSuperInterfaceNames() throws JavaModelException {
    IBinaryType info = (IBinaryType) getElementInfo();
    char[][] names = info.getInterfaceNames();
    int length;//from  ww  w. jav  a 2  s.c om
    if (names == null || (length = names.length) == 0) {
        return CharOperation.NO_STRINGS;
    }
    names = ClassFile.translatedNames(names);
    String[] strings = new String[length];
    for (int i = 0; i < length; i++) {
        strings[i] = new String(names[i]);
    }
    return strings;
}

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

License:Open Source License

/**
 * @see org.eclipse.jdt.core.IType#getSuperInterfaceTypeSignatures()
 * @since 3.0/*from  ww w.j  a va  2 s.co  m*/
 */
public String[] getSuperInterfaceTypeSignatures() throws JavaModelException {
    IBinaryType info = (IBinaryType) getElementInfo();
    char[] genericSignature = info.getGenericSignature();
    if (genericSignature != null) {
        ArrayList interfaces = new ArrayList();
        int signatureLength = genericSignature.length;
        // skip type parameters
        int index = 0;
        if (genericSignature[0] == '<') {
            int count = 1;
            while (count > 0 && ++index < signatureLength) {
                switch (genericSignature[index]) {
                case '<':
                    count++;
                    break;
                case '>':
                    count--;
                    break;
                }
            }
            index++;
        }
        // skip superclass
        index = org.eclipse.jdt.internal.compiler.util.Util.scanClassTypeSignature(genericSignature, index) + 1;
        while (index < signatureLength) {
            int start = index;
            index = org.eclipse.jdt.internal.compiler.util.Util.scanClassTypeSignature(genericSignature, start)
                    + 1;
            char[] interfaceSig = CharOperation.subarray(genericSignature, start, index);
            interfaces.add(new String(ClassFile.translatedName(interfaceSig)));
        }
        int size = interfaces.size();
        String[] result = new String[size];
        interfaces.toArray(result);
        return result;
    } else {
        char[][] names = info.getInterfaceNames();
        int length;
        if (names == null || (length = names.length) == 0) {
            return CharOperation.NO_STRINGS;
        }
        names = ClassFile.translatedNames(names);
        String[] strings = new String[length];
        for (int i = 0; i < length; i++) {
            strings[i] = new String(Signature.createTypeSignature(names[i], true));
        }
        return strings;
    }
}

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

License:Open Source License

/**
 * @see org.eclipse.jdt.core.IType#getTypeParameterSignatures()
 * @since 3.0/* ww w .  j  av  a  2  s  .  com*/
 */
public String[] getTypeParameterSignatures() throws JavaModelException {
    IBinaryType info = (IBinaryType) getElementInfo();
    char[] genericSignature = info.getGenericSignature();
    if (genericSignature == null)
        return CharOperation.NO_STRINGS;

    char[] dotBaseSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.');
    char[][] typeParams = Signature.getTypeParameters(dotBaseSignature);
    return CharOperation.toStrings(typeParams);
}

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

License:Open Source License

private IMemberValuePair[] getTargetElementTypes(long tagBits) {
    ArrayList values = new ArrayList();
    String elementType = new String(
            CharOperation.concatWith(TypeConstants.JAVA_LANG_ANNOTATION_ELEMENTTYPE, '.')) + '.';
    if ((tagBits & TagBits.AnnotationForType) != 0) {
        values.add(elementType + new String(TypeConstants.TYPE));
    }//from w  ww.  j  av a  2s  . co m
    if ((tagBits & TagBits.AnnotationForField) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_FIELD));
    }
    if ((tagBits & TagBits.AnnotationForMethod) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_METHOD));
    }
    if ((tagBits & TagBits.AnnotationForParameter) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_PARAMETER));
    }
    if ((tagBits & TagBits.AnnotationForConstructor) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_CONSTRUCTOR));
    }
    if ((tagBits & TagBits.AnnotationForLocalVariable) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_LOCAL_VARIABLE));
    }
    if ((tagBits & TagBits.AnnotationForAnnotationType) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_ANNOTATION_TYPE));
    }
    if ((tagBits & TagBits.AnnotationForPackage) != 0) {
        values.add(elementType + new String(TypeConstants.UPPER_PACKAGE));
    }
    final Object value;
    if (values.size() == 0) {
        if ((tagBits & TagBits.AnnotationTarget) != 0)
            value = CharOperation.NO_STRINGS;
        else
            return Annotation.NO_MEMBER_VALUE_PAIRS;
    } else if (values.size() == 1) {
        value = values.get(0);
    } else {
        value = values.toArray(new String[values.size()]);
    }
    return new IMemberValuePair[] { new IMemberValuePair() {
        public int getValueKind() {
            return IMemberValuePair.K_QUALIFIED_NAME;
        }

        public Object getValue() {
            return value;
        }

        public String getMemberName() {
            return new String(TypeConstants.VALUE);
        }
    } };
}

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

License:Open Source License

/**
 * Convert these type names to signatures.
 *
 * @see org.eclipse.jdt.core.Signature/*from w  ww  .ja  va 2s.  c  om*/
 */
protected static String[] convertTypeNamesToSigs(char[][] typeNames) {
    if (typeNames == null)
        return CharOperation.NO_STRINGS;
    int n = typeNames.length;
    if (n == 0)
        return CharOperation.NO_STRINGS;
    //   JavaModelManager manager = JavaModelManager.getJavaModelManager();
    String[] typeSigs = new String[n];
    for (int i = 0; i < n; ++i) {
        typeSigs[i] = Signature.createTypeSignature(typeNames[i], false);
    }
    return typeSigs;
}

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

License:Open Source License

private void updateIndex(Openable element, IResourceDelta delta) {

    IndexManager indexManager = this.manager.indexManager;
    if (indexManager == null)
        return;/*from   ww w.j ava  2 s.c o m*/

    switch (element.getElementType()) {
    case IJavaElement.JAVA_PROJECT:
        switch (delta.getKind()) {
        case IResourceDelta.ADDED:
            indexManager.indexAll((JavaProject) element.getJavaProject());
            break;
        case IResourceDelta.REMOVED:
            indexManager.removeIndexFamily(element.getJavaProject().getProject().getFullPath());
            // NB: Discarding index jobs belonging to this project was done during PRE_DELETE
            break;
        // NB: Update of index if project is opened, closed, or its java nature is added or removed
        //     is done in updateCurrentDeltaAndIndex
        }
        break;
    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
        if (element instanceof JarPackageFragmentRoot) {
            JarPackageFragmentRoot root = (JarPackageFragmentRoot) element;
            // index jar file only once (if the root is in its declaring project)
            IPath jarPath = root.getPath();
            switch (delta.getKind()) {
            case IResourceDelta.ADDED:
                // index the new jar
                indexManager.indexLibrary(jarPath, root.getIndexPath());
                break;
            case IResourceDelta.CHANGED:
                // first remove the index so that it is forced to be re-indexed
                indexManager.removeIndex(jarPath);
                // then index the jar
                indexManager.indexLibrary(jarPath, root.getIndexPath());
                break;
            case IResourceDelta.REMOVED:
                // the jar was physically removed: remove the index
                indexManager.discardJobs(jarPath.toString());
                indexManager.removeIndex(jarPath);
                break;
            }
            break;
        }
        int kind = delta.getKind();
        if (kind == IResourceDelta.ADDED || kind == IResourceDelta.REMOVED
                || (kind == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.LOCAL_CHANGED) != 0)) {
            PackageFragmentRoot root = (PackageFragmentRoot) element;
            updateRootIndex(root, CharOperation.NO_STRINGS, delta);
            break;
        }
        // don't break as packages of the package fragment root can be indexed below
        // $FALL-THROUGH$
    case IJavaElement.PACKAGE_FRAGMENT:
        switch (delta.getKind()) {
        case IResourceDelta.CHANGED:
            if ((delta.getFlags() & IResourceDelta.LOCAL_CHANGED) == 0)
                break;
            // $FALL-THROUGH$
        case IResourceDelta.ADDED:
        case IResourceDelta.REMOVED:
            IPackageFragment pkg = null;
            if (element instanceof IPackageFragmentRoot) {
                PackageFragmentRoot root = (PackageFragmentRoot) element;
                pkg = root.getPackageFragment(CharOperation.NO_STRINGS);
            } else {
                pkg = (IPackageFragment) element;
            }
            RootInfo rootInfo = rootInfo(pkg.getParent().getPath(), delta.getKind());
            boolean isSource = rootInfo == null // if null, defaults to source
                    || rootInfo.entryKind == IClasspathEntry.CPE_SOURCE;
            IResourceDelta[] children = (IResourceDelta[]) delta.getAffectedChildren();
            for (int i = 0, length = children.length; i < length; i++) {
                IResourceDelta child = children[i];
                IResource resource = child.getResource();
                // TODO (philippe) Why do this? Every child is added anyway as the delta is walked
                if (resource instanceof IFile) {
                    String name = resource.getName();
                    if (isSource) {
                        if (org.eclipse.jdt.internal.core.util.Util.isJavaLikeFileName(name)) {
                            Openable cu = (Openable) pkg.getCompilationUnit(name);
                            updateIndex(cu, child);
                        }
                    } else if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(name)) {
                        Openable classFile = (Openable) pkg.getClassFile(name);
                        updateIndex(classFile, child);
                    }
                }
            }
            break;
        }
        break;
    case IJavaElement.CLASS_FILE:
        //            IFile file = (IFile) delta.getResource();
        //            IJavaProject project = element.getJavaProject();
        //            PackageFragmentRoot root = element.getPackageFragmentRoot();
        //            IPath binaryFolderPath = root.isExternal() && !root.isArchive() ? root.resource().getFullPath() : root.getPath();
        //            // if the class file is part of the binary output, it has been created by
        //            // the java builder -> ignore
        //            try {
        //               if (binaryFolderPath.equals(project.getOutputLocation())) {
        //                  break;
        //               }
        //            } catch (JavaModelException e) {
        //               // project doesn't exist: ignore
        //            }
        //            switch (delta.getKind()) {
        //               case IResourceDelta.CHANGED :
        //                  // no need to index if the content has not changed
        //                  int flags = delta.getFlags();
        //                  if ((flags & IResourceDelta.CONTENT) == 0 && (flags & IResourceDelta.ENCODING) == 0)
        //                     break;
        //                  // $FALL-THROUGH$
        //               case IResourceDelta.ADDED :
        //                  indexManager.addBinary(file, binaryFolderPath);
        //                  break;
        //               case IResourceDelta.REMOVED :
        //                  String containerRelativePath = Util.relativePath(file.getFullPath(), binaryFolderPath.segmentCount());
        //                  indexManager.remove(containerRelativePath, binaryFolderPath);
        //                  break;
        //            }
        break;
    case IJavaElement.COMPILATION_UNIT:
        File file = delta.getFile();
        switch (delta.getKind()) {
        case IResourceDelta.CHANGED:
            // no need to index if the content has not changed
            int flags = delta.getFlags();
            if ((flags & IResourceDelta.CONTENT) == 0 && (flags & IResourceDelta.ENCODING) == 0)
                break;
            // $FALL-THROUGH$
        case IResourceDelta.ADDED:
            indexManager.addSource(file.toPath(), element.getJavaProject().getPath(),
                    getSourceElementParser(element));
            // Clean file from secondary types cache but do not update indexing secondary type cache as it will be updated through indexing itself
            this.manager.secondaryTypesRemoving(file, false);
            break;
        case IResourceDelta.REMOVED:
            indexManager.remove(
                    file.getPath().substring(element.getJavaProject().getPath().toOSString().length()),
                    element.getJavaProject().getPath());
            // Clean file from secondary types cache and update indexing secondary type cache as indexing cannot remove secondary types from cache
            this.manager.secondaryTypesRemoving(file, true);
            break;
        }
    }
}