@Override protected ISourceReference getSourceReference(IPackageFragment pkg, String sourcename) throws CoreException { int idx = sourcename.lastIndexOf('.'); if (idx != -1) { sourcename = sourcename.substring(0, idx); } return pkg.getClassFile(sourcename + ".class"); //$NON-NLS-1$ } }
protected IClassFile transplantHandle(IPackageFragment parent, IClassFile element) { return parent.getClassFile(element.getElementName()); }
protected IClassFile transplantHandle(IPackageFragment parent, IClassFile element) { return parent.getClassFile(element.getElementName()); }
protected IClassFile transplantHandle(IPackageFragment parent, IClassFile element) { return parent.getClassFile(element.getElementName()); }
protected IClassFile transplantHandle(IPackageFragment parent, IClassFile element) { return parent.getClassFile(element.getElementName()); }
public IType getType(String typeName) { IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + typeName + SUFFIX_STRING_class); //$NON-NLS-1$ return new BinaryType((JavaElement)classFile, typeName); } public ITypeParameter getTypeParameter(String typeParameterName) {
@Override public IType getType(String typeName) { IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + typeName + SUFFIX_STRING_class); //$NON-NLS-1$ return new BinaryType((JavaElement)classFile, typeName); } @Override
public IType getType(String typeName) { IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + typeName + SUFFIX_STRING_class); //$NON-NLS-1$ return new BinaryType((JavaElement)classFile, typeName); } public ITypeParameter getTypeParameter(String typeParameterName) {
public IType getType(String typeName) { IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + typeName + SUFFIX_STRING_class); //$NON-NLS-1$ return new BinaryType((JavaElement)classFile, typeName); } public ITypeParameter getTypeParameter(String typeParameterName) {
public IType getType(String typeName) { IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + typeName + SUFFIX_STRING_class); //$NON-NLS-1$ return new BinaryType((JavaElement)classFile, typeName); } public ITypeParameter getTypeParameter(String typeParameterName) {
public IType getType(String typeName) { IClassFile classFile= getPackageFragment().getClassFile(getTypeQualifiedName() + "$" + typeName + SUFFIX_STRING_class); //$NON-NLS-1$ return new BinaryType((JavaElement)classFile, typeName); } public ITypeParameter getTypeParameter(String typeParameterName) {
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.lastIndexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
private static IClassFile getClassFile(char[] fileName) { int jarSeparator = CharOperation.indexOf(IDependent.JAR_FILE_ENTRY_SEPARATOR, fileName); int pkgEnd = CharOperation.lastIndexOf('/', fileName); // pkgEnd is exclusive if (pkgEnd == -1) pkgEnd = CharOperation.lastIndexOf(File.separatorChar, fileName); if (jarSeparator != -1 && pkgEnd < jarSeparator) // if in a jar and no slash, it is a default package -> pkgEnd should be equal to jarSeparator pkgEnd = jarSeparator; if (pkgEnd == -1) return null; IPackageFragment pkg = getPackageFragment(fileName, pkgEnd, jarSeparator); if (pkg == null) return null; int start; return pkg.getClassFile(new String(fileName, start = pkgEnd + 1, fileName.length - start)); }
/** * Creates an IType from the given simple top level type name. */ protected IType createTypeHandle(String simpleTypeName) { Openable openable = this.currentPossibleMatch.openable; if (openable instanceof CompilationUnit) return ((CompilationUnit) openable).getType(simpleTypeName); IType binaryType = ((ClassFile) openable).getType(); String binaryTypeQualifiedName = binaryType.getTypeQualifiedName(); if (simpleTypeName.equals(binaryTypeQualifiedName)) return binaryType; // answer only top-level types, sometimes the classFile is for a member/local type // type name may be null for anonymous (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791) String classFileName = simpleTypeName.length() == 0 ? binaryTypeQualifiedName : simpleTypeName; IClassFile classFile = binaryType.getPackageFragment().getClassFile(classFileName + SuffixConstants.SUFFIX_STRING_class); return classFile.getType(); } protected boolean encloses(IJavaElement element) {
/** * Creates an IType from the given simple top level type name. */ protected IType createTypeHandle(String simpleTypeName) { Openable openable = this.currentPossibleMatch.openable; if (openable instanceof CompilationUnit) return ((CompilationUnit) openable).getType(simpleTypeName); IType binaryType = ((ClassFile) openable).getType(); String binaryTypeQualifiedName = binaryType.getTypeQualifiedName(); if (simpleTypeName.equals(binaryTypeQualifiedName)) return binaryType; // answer only top-level types, sometimes the classFile is for a member/local type // type name may be null for anonymous (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791) String classFileName = simpleTypeName.length() == 0 ? binaryTypeQualifiedName : simpleTypeName; IClassFile classFile = binaryType.getPackageFragment().getClassFile(classFileName + SuffixConstants.SUFFIX_STRING_class); return classFile.getType(); } protected boolean encloses(IJavaElement element) {