@Override public void acceptSearchMatch(SearchMatch match) throws CoreException { Object element= match.getElement(); if (element instanceof IPackageFragment) { packageFragments.add((IPackageFragment) element); } else if (element instanceof IType) { IType enclosingType= (IType) element; packageFragments.add(enclosingType.getPackageFragment()); } } };
@Override public String getText(Object element) { return super.getText(((IType)element).getPackageFragment()); } }
protected void appendTopLevelType(final IType type, IProgressMonitor subProgressMonitor) throws JavaModelException { String packageName= type.getPackageFragment().getElementName(); if (packageName.length() > 0) { fBuffer.append("package "); //$NON-NLS-1$ fBuffer.append(packageName); fBuffer.append(";\n"); //$NON-NLS-1$ } appendTypeDeclaration(type, subProgressMonitor); }
private static void appendTypePath(IType type, StringBuffer buf) { IPackageFragment pack= type.getPackageFragment(); appendModulePath(pack, buf); String packPath= pack.getElementName().replace('.', '/'); String typePath= type.getTypeQualifiedName('.'); if (packPath.length() > 0) { buf.append(packPath); buf.append('/'); } buf.append(typePath); buf.append(".html"); //$NON-NLS-1$ }
private void cacheType(IType type, IFile file) { this.moveResourceCount++; IPackageFragmentRoot root = (IPackageFragmentRoot) type.getPackageFragment().getParent(); cacheFile(root, file); }
/** * Returns the package name of the stored type. * * @see #getType() * @see IType#getPackageFragment() * * @throws NullPointerException if matched type is <code> null</code> * @return the package name */ public String getPackageName() { return getType().getPackageFragment().getElementName(); }
/** * Returns the package name of the stored type. * * @see #getType() * @see IType#getPackageFragment() * * @throws NullPointerException if matched type is <code> null</code> * @return the package name */ public String getPackageName() { return getType().getPackageFragment().getElementName(); }
/** * Returns the package name of the stored type. * * @see #getType() * @see IType#getPackageFragment() * * @throws NullPointerException if matched type is <code> null</code> * @return the package name */ public String getPackageName() { return getType().getPackageFragment().getElementName(); }
/** * Returns the package name of the stored type. * * @see #getType() * @see IType#getPackageFragment() * * @throws NullPointerException if matched type is <code> null</code> * @return the package name */ public String getPackageName() { return getType().getPackageFragment().getElementName(); }
/** * Returns the fully qualified name of a type's container. (package name or enclosing type name) */ public static String getTypeContainerName(IType type) { IType outerType= type.getDeclaringType(); if (outerType != null) { return getFullyQualifiedName(outerType); } else { return type.getPackageFragment().getElementName(); } }
private RefactoringStatus checkTypesInPackage() throws CoreException { IType type = Checks.findTypeInPackage(fType.getPackageFragment(), getNewElementName()); if (type == null || !type.exists()) { return null; } String msg = Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_exists, new String[] { getNewElementLabel(), JavaElementLabels.getElementLabel(fType.getPackageFragment(), JavaElementLabels.ALL_DEFAULT) }); return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(type)); }
private static ICompilationUnit getNewCompilationUnit(IType type, String newName) { ICompilationUnit cu = type.getCompilationUnit(); if (isPrimaryType(type)) { IPackageFragment parent = type.getPackageFragment(); String renamedCUName = JavaModelUtil.getRenamedCUName(cu, newName); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
private RefactoringStatus checkTypesInPackage() throws CoreException { IType type= Checks.findTypeInPackage(fType.getPackageFragment(), getNewElementName()); if (type == null || ! type.exists()) return null; String msg= Messages.format(RefactoringCoreMessages.RenameTypeRefactoring_exists, new String[] {getNewElementLabel(), JavaElementLabels.getElementLabel(fType.getPackageFragment(), JavaElementLabels.ALL_DEFAULT)}); return RefactoringStatus.createErrorStatus(msg, JavaStatusContext.create(type)); }
private ICompilationUnit getNewCompilationUnit() { ICompilationUnit cu= fType.getCompilationUnit(); if (isPrimaryType()) { IPackageFragment parent= fType.getPackageFragment(); String renamedCUName= JavaModelUtil.getRenamedCUName(cu, getNewElementName()); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
private ICompilationUnit getNewCompilationUnit() { ICompilationUnit cu= fType.getCompilationUnit(); if (isPrimaryType()) { IPackageFragment parent= fType.getPackageFragment(); String renamedCUName= JavaModelUtil.getRenamedCUName(cu, getNewElementName()); return parent.getCompilationUnit(renamedCUName); } else { return cu; } }
private Change createCompilationUnitForMovedType(IProgressMonitor pm) throws CoreException { ICompilationUnit newCuWC= null; try { newCuWC= fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())).getWorkingCopy(null); String source= createSourceForNewCu(newCuWC, pm); return new CreateCompilationUnitChange(fType.getPackageFragment().getCompilationUnit(JavaModelUtil.getRenamedCUName(fType.getCompilationUnit(), fType.getElementName())), source, null); } finally { if (newCuWC != null) newCuWC.discardWorkingCopy(); } }
private void computeQualifiedNameMatches(IProgressMonitor pm) { IPackageFragment fragment= fType.getPackageFragment(); if (fQualifiedNameSearchResult == null) fQualifiedNameSearchResult= new QualifiedNameSearchResult(); QualifiedNameFinder.process(fQualifiedNameSearchResult, fType.getFullyQualifiedName(), fragment.getElementName() + "." + getNewElementName(), //$NON-NLS-1$ fFilePatterns, fType.getJavaProject().getProject(), pm); }
private IType resolveType(String qualifiedTypeName) throws JavaModelException{ IType type= getDeclaringType().getJavaProject().findType(qualifiedTypeName); if (type == null) type= getDeclaringType().getJavaProject().findType(getDeclaringType().getPackageFragment().getElementName(), qualifiedTypeName); return type; }
private IType resolveType(String qualifiedTypeName) throws JavaModelException{ IType type= getDeclaringType().getJavaProject().findType(qualifiedTypeName); if (type == null) type= getDeclaringType().getJavaProject().findType(getDeclaringType().getPackageFragment().getElementName(), qualifiedTypeName); return type; }
private void initialize() throws JavaModelException { fQualifiedTypeName= JavaModelUtil.concatenateName(fType.getPackageFragment().getElementName(), fType.getElementName()); fEnclosingInstanceFieldName= getInitialNameForEnclosingInstanceField(); fSourceRewrite= new CompilationUnitRewrite(fType.getCompilationUnit()); fIsInstanceFieldCreationPossible= !(JdtFlags.isStatic(fType) || fType.isAnnotation() || fType.isEnum()); fIsInstanceFieldCreationMandatory= fIsInstanceFieldCreationPossible && isInstanceFieldCreationMandatory(); fCreateInstanceField= fIsInstanceFieldCreationMandatory; }