List of usage examples for org.eclipse.jdt.internal.core ClassFile ClassFile
protected ClassFile(PackageFragment parent, String nameWithoutExtension)
From source file:org.eclipse.jdt.internal.core.JarPackageFragment.java
License:Open Source License
/** * Compute the children of this package fragment. Children of jar package fragments * can only be IClassFile (representing .class files). *//* w w w . ja v a 2s . c o m*/ private IJavaElement[] computeChildren(ArrayList namesWithoutExtension) { int size = namesWithoutExtension.size(); if (size == 0) return NO_ELEMENTS; IJavaElement[] children = new IJavaElement[size]; for (int i = 0; i < size; i++) { String nameWithoutExtension = (String) namesWithoutExtension.get(i); children[i] = new ClassFile(this, nameWithoutExtension); } return children; }
From source file:org.eclipse.jdt.internal.core.PackageFragment.java
License:Open Source License
/** * @see IPackageFragment#getClassFile(String) * @exception IllegalArgumentException if the name does not end with ".class" */// w ww . j a v a 2 s .c om public IClassFile getClassFile(String classFileName) { if (!org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(classFileName)) { throw new IllegalArgumentException(Messages.bind(Messages.element_invalidClassFileName, classFileName)); } // don't hold on the .class file extension to save memory // also make sure to not use substring as the resulting String may hold on the underlying char[] which might be much bigger than necessary int length = classFileName.length() - 6; char[] nameWithoutExtension = new char[length]; classFileName.getChars(0, length, nameWithoutExtension, 0); return new ClassFile(this, new String(nameWithoutExtension)); }
From source file:org.eclipse.jdt.internal.core.SourceMapper.java
License:Open Source License
/** * Returns the type with the given <code>typeName</code>. Returns inner classes * as well.//from w w w . j a v a2 s . c om */ protected IType getType(String typeName) { if (typeName.length() == 0) { IJavaElement classFile = this.binaryType.getParent(); String classFileName = classFile.getElementName(); StringBuffer newClassFileName = new StringBuffer(); int lastDollar = classFileName.lastIndexOf('$'); for (int i = 0; i <= lastDollar; i++) newClassFileName.append(classFileName.charAt(i)); newClassFileName.append(Integer.toString(this.anonymousCounter)); PackageFragment pkg = (PackageFragment) classFile.getParent(); return new BinaryType(new ClassFile(pkg, newClassFileName.toString()), typeName); } else if (this.binaryType.getElementName().equals(typeName)) return this.binaryType; else return this.binaryType.getType(typeName); }