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

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

Introduction

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

Prototype

public synchronized String intern(String s) 

Source Link

Usage

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

License:Open Source License

/**
 * Creates a class path entry of the specified kind with the given path.
 *//*from  w w w.ja v  a 2  s . c o  m*/
public ClasspathEntry(int contentKind, int entryKind, IPath path, IPath[] inclusionPatterns,
        IPath[] exclusionPatterns, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath,
        IPath specificOutputLocation, IClasspathEntry referencingEntry, boolean isExported,
        IAccessRule[] accessRules, boolean combineAccessRules, IClasspathAttribute[] extraAttributes) {

    this.contentKind = contentKind;
    this.entryKind = entryKind;
    this.path = path;
    this.inclusionPatterns = inclusionPatterns;
    this.exclusionPatterns = exclusionPatterns;
    this.referencingEntry = referencingEntry;

    int length;
    if (accessRules != null && (length = accessRules.length) > 0) {
        AccessRule[] rules = new AccessRule[length];
        System.arraycopy(accessRules, 0, rules, 0, length);
        byte classpathEntryType;
        String classpathEntryName;
        JavaModelManager manager = JavaModelManager.getJavaModelManager();
        if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling
            classpathEntryType = AccessRestriction.PROJECT;
            classpathEntryName = manager.intern(getPath().segment(0));
        } else {
            classpathEntryType = AccessRestriction.LIBRARY;
            Object target = JavaModel.getWorkspaceTarget(path);
            if (target == null) {
                classpathEntryName = manager.intern(path.toOSString());
            } else {
                classpathEntryName = manager.intern(path.makeRelative().toString());
            }
        }
        this.accessRuleSet = new AccessRuleSet(rules, classpathEntryType, classpathEntryName);
    }
    //      else { -- implicit!
    //         this.accessRuleSet = null;
    //      }

    this.combineAccessRules = combineAccessRules;
    this.extraAttributes = extraAttributes;

    if (inclusionPatterns != INCLUDE_ALL && inclusionPatterns.length > 0) {
        this.fullInclusionPatternChars = UNINIT_PATTERNS;
    }
    if (exclusionPatterns.length > 0) {
        this.fullExclusionPatternChars = UNINIT_PATTERNS;
    }
    this.sourceAttachmentPath = sourceAttachmentPath;
    this.sourceAttachmentRootPath = sourceAttachmentRootPath;
    this.specificOutputLocation = specificOutputLocation;
    this.isExported = isExported;
}

From source file:net.sf.j2s.core.builder.State.java

License:Open Source License

private static AccessRuleSet readRestriction(DataInputStream in) throws IOException {
    int length = in.readInt();
    if (length == 0)
        return null; // no restriction specified
    AccessRule[] accessRules = new AccessRule[length];
    for (int i = 0; i < length; i++) {
        char[] pattern = readName(in);
        int problemId = in.readInt();
        accessRules[i] = new ClasspathAccessRule(pattern, problemId);
    }//from   w  w w .  jav a  2 s  .co m
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    return new AccessRuleSet(accessRules, in.readByte(), manager.intern(in.readUTF()));
}

From source file:org.eclipse.ajdt.core.parserbridge.AJCompilationUnitStructureRequestor.java

License:Open Source License

private AspectElementInfo createAspectElementInfo(AspectTypeInfo typeInfo, AspectElement handle) {
    AspectElementInfo info = typeInfo.anonymousMember ? new AspectElementInfo() {
        public boolean isAnonymousMember() {
            return true;
        }//from  w  w w .java2s .c  om
    } : new AspectElementInfo();

    // AJ pieces
    info.setAJKind(IProgramElement.Kind.ASPECT);
    info.setAJAccessibility(CompilationUnitTools.getAccessibilityFromModifierCode(typeInfo.modifiers));
    info.setAJModifiers(CompilationUnitTools.getModifiersFromModifierCode(typeInfo.modifiers));
    info.setPrivileged(typeInfo.isPrivilegedAspect);

    // JDT pieces - copied from super
    info.setHandle(handle);
    info.setSourceRangeStart(typeInfo.declarationStart);
    info.setFlags(typeInfo.modifiers);
    info.setNameSourceStart(typeInfo.nameSourceStart);
    info.setNameSourceEnd(typeInfo.nameSourceEnd);
    JavaModelManager manager = JavaModelManager.getJavaModelManager();
    char[] superclass = typeInfo.superclass;
    info.setSuperclassName(superclass == null ? null : manager.intern(superclass));
    char[][] superinterfaces = typeInfo.superinterfaces;
    for (int i = 0, length = superinterfaces == null ? 0 : superinterfaces.length; i < length; i++)
        superinterfaces[i] = manager.intern(superinterfaces[i]);
    info.setSuperInterfaceNames(superinterfaces);
    info.addCategories(handle, typeInfo.categories);
    this.newElements.put(handle, info);

    if (typeInfo.typeParameters != null) {
        for (int i = 0, length = typeInfo.typeParameters.length; i < length; i++) {
            org.eclipse.jdt.internal.compiler.ISourceElementRequestor.TypeParameterInfo typeParameterInfo = typeInfo.typeParameters[i];
            acceptTypeParameter(typeParameterInfo, info);
        }
    }
    if (typeInfo.annotations != null) {
        int length = typeInfo.annotations.length;
        this.unitInfo.annotationNumber += length;
        for (int i = 0; i < length; i++) {
            org.eclipse.jdt.internal.compiler.ast.Annotation annotation = typeInfo.annotations[i];
            acceptAnnotation(annotation, info, handle);
        }
    }
    if (typeInfo.childrenCategories != null) {
        Iterator<Map.Entry<IJavaElement, char[][]>> iterator = typeInfo.childrenCategories.entrySet()
                .iterator();
        while (iterator.hasNext()) {
            Map.Entry<IJavaElement, char[][]> entry = iterator.next();
            info.addCategories(entry.getKey(), entry.getValue());
        }
    }
    return info;
}

From source file:org.eclipse.che.jdt.internal.core.ClasspathEntry.java

License:Open Source License

/**
 * Creates a class path entry of the specified kind with the given path.
 *///from   ww w  .  j  a v a2 s .c o  m
public ClasspathEntry(int contentKind, int entryKind, IPath path, IPath[] inclusionPatterns,
        IPath[] exclusionPatterns, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath,
        IPath specificOutputLocation, IClasspathEntry referencingEntry, boolean isExported,
        IAccessRule[] accessRules, boolean combineAccessRules, IClasspathAttribute[] extraAttributes) {

    this.contentKind = contentKind;
    this.entryKind = entryKind;
    this.path = path;
    this.inclusionPatterns = inclusionPatterns;
    this.exclusionPatterns = exclusionPatterns;
    this.referencingEntry = referencingEntry;

    int length;
    if (accessRules != null && (length = accessRules.length) > 0) {
        AccessRule[] rules = new AccessRule[length];
        System.arraycopy(accessRules, 0, rules, 0, length);
        byte classpathEntryType;
        String classpathEntryName;
        JavaModelManager manager = JavaModelManager.getJavaModelManager();
        if (this.entryKind == CPE_PROJECT || this.entryKind == CPE_SOURCE) { // can be remote source entry when reconciling
            classpathEntryType = AccessRestriction.PROJECT;
            classpathEntryName = manager.intern(getPath().segment(0));
        } else {
            classpathEntryType = AccessRestriction.LIBRARY;
            //                Object target = JavaModel.getWorkspaceTarget(path);
            //                if (target == null) {
            classpathEntryName = manager.intern(path.toOSString());
            //                } else {
            //                    classpathEntryName = manager.intern(path.makeRelative().toString());
            //                }
        }
        this.accessRuleSet = new AccessRuleSet(rules, classpathEntryType, classpathEntryName);
    }
    //      else { -- implicit!
    //         this.accessRuleSet = null;
    //      }

    this.combineAccessRules = combineAccessRules;
    this.extraAttributes = extraAttributes;

    if (inclusionPatterns != INCLUDE_ALL && inclusionPatterns.length > 0) {
        this.fullInclusionPatternChars = UNINIT_PATTERNS;
    }
    if (exclusionPatterns.length > 0) {
        this.fullExclusionPatternChars = UNINIT_PATTERNS;
    }
    this.sourceAttachmentPath = sourceAttachmentPath;
    this.sourceAttachmentRootPath = sourceAttachmentRootPath;
    this.specificOutputLocation = specificOutputLocation;
    this.isExported = isExported;
}