View | Details | Raw Unified | Return to bug 89977 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/jdt/internal/ui/viewsupport/JavaElementImageProvider.java (-1 / +2 lines)
Lines 33-38 Link Here
33
import org.eclipse.jdt.core.IPackageFragment;
33
import org.eclipse.jdt.core.IPackageFragment;
34
import org.eclipse.jdt.core.IPackageFragmentRoot;
34
import org.eclipse.jdt.core.IPackageFragmentRoot;
35
import org.eclipse.jdt.core.IType;
35
import org.eclipse.jdt.core.IType;
36
import org.eclipse.jdt.core.JavaCore;
36
import org.eclipse.jdt.core.JavaModelException;
37
import org.eclipse.jdt.core.JavaModelException;
37
38
38
import org.eclipse.jdt.ui.JavaElementImageDescriptor;
39
import org.eclipse.jdt.ui.JavaElementImageDescriptor;
Lines 111-117 Link Here
111
			return getJavaImageDescriptor((IJavaElement) element, flags);
112
			return getJavaImageDescriptor((IJavaElement) element, flags);
112
		} else if (element instanceof IFile) {
113
		} else if (element instanceof IFile) {
113
			IFile file= (IFile) element;
114
			IFile file= (IFile) element;
114
			if ("java".equals(file.getFileExtension())) { //$NON-NLS-1$
115
			if (JavaCore.isJavaLikeFileName(file.getName())) {
115
				return getCUResourceImageDescriptor(file, flags); // image for a CU not on the build path
116
				return getCUResourceImageDescriptor(file, flags); // image for a CU not on the build path
116
			}
117
			}
117
			return getWorkbenchImageDescriptor(file, flags);
118
			return getWorkbenchImageDescriptor(file, flags);
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/ExclusionInclusionDialog.java (-8 / +17 lines)
Lines 43-48 Link Here
43
43
44
import org.eclipse.jdt.core.IClasspathEntry;
44
import org.eclipse.jdt.core.IClasspathEntry;
45
import org.eclipse.jdt.core.IJavaProject;
45
import org.eclipse.jdt.core.IJavaProject;
46
import org.eclipse.jdt.core.JavaCore;
46
import org.eclipse.jdt.core.JavaModelException;
47
import org.eclipse.jdt.core.JavaModelException;
47
48
48
import org.eclipse.jdt.internal.corext.util.Messages;
49
import org.eclipse.jdt.internal.corext.util.Messages;
Lines 261-274 Link Here
261
        return new Status(IStatus.INFO, JavaPlugin.getPluginId(),  IStatus.INFO, message, null);
262
        return new Status(IStatus.INFO, JavaPlugin.getPluginId(),  IStatus.INFO, message, null);
262
    }
263
    }
263
    
264
    
264
    private String completeName(String name) {
265
	/**
265
        if (!name.endsWith(".java")) { //$NON-NLS-1$
266
	 * Add a '/' at the end of the name if
266
            name= name + "/"; //$NON-NLS-1$
267
	 * it does not end with '.java', or other Java-like extension.
267
            name= name.replace('.', '/');
268
	 * 
268
            return name;
269
	 * @param name append '/' at the end if
269
        }
270
	 * necessary
270
        return name;
271
	 * @return modified string
271
    }
272
	 */
273
	private static String completeName(String name) {
274
		if (!JavaCore.isJavaLikeFileName(name)) {
275
			name= name + "/"; //$NON-NLS-1$
276
			name= name.replace('.', '/');
277
			return name;
278
		}
279
		return name;
280
	}
272
	
281
	
273
	private boolean canEdit(List selected) {
282
	private boolean canEdit(List selected) {
274
		return selected.size() == 1;
283
		return selected.size() == 1;
(-)ui/org/eclipse/jdt/internal/ui/text/correction/ReorgCorrectionsSubProcessor.java (-2 / +1 lines)
Lines 115-122 Link Here
115
			String currTypeName= buffer.getText(problem.getOffset(), problem.getLength());
115
			String currTypeName= buffer.getText(problem.getOffset(), problem.getLength());
116
			
116
			
117
			proposals.add(new CorrectMainTypeNameProposal(cu, context, currTypeName, 5));
117
			proposals.add(new CorrectMainTypeNameProposal(cu, context, currTypeName, 5));
118
			
118
			String newCUName= currTypeName + JavaModelUtil.getCompilationUnitExtension(cu);
119
			String newCUName= currTypeName + ".java"; //$NON-NLS-1$
120
			ICompilationUnit newCU= ((IPackageFragment) (cu.getParent())).getCompilationUnit(newCUName);
119
			ICompilationUnit newCU= ((IPackageFragment) (cu.getParent())).getCompilationUnit(newCUName);
121
			if (!newCU.exists() && !isLinked && !JavaConventions.validateCompilationUnitName(newCUName).matches(IStatus.ERROR)) {
120
			if (!newCU.exists() && !isLinked && !JavaConventions.validateCompilationUnitName(newCUName).matches(IStatus.ERROR)) {
122
				RenameCompilationUnitChange change= new RenameCompilationUnitChange(cu, newCUName);
121
				RenameCompilationUnitChange change= new RenameCompilationUnitChange(cu, newCUName);
(-)core extension/org/eclipse/jdt/internal/corext/buildpath/ClasspathModifier.java (-2 / +2 lines)
Lines 1691-1704 Link Here
1691
1691
1692
	/**
1692
	/**
1693
	 * Add a '/' at the end of the name if
1693
	 * Add a '/' at the end of the name if
1694
	 * it does not end with '.java'.
1694
	 * it does not end with '.java', or other Java-like extension.
1695
	 * 
1695
	 * 
1696
	 * @param name append '/' at the end if
1696
	 * @param name append '/' at the end if
1697
	 * necessary
1697
	 * necessary
1698
	 * @return modified string
1698
	 * @return modified string
1699
	 */
1699
	 */
1700
	private static String completeName(String name) {
1700
	private static String completeName(String name) {
1701
		if (!name.endsWith(".java")) { //$NON-NLS-1$
1701
		if (!JavaCore.isJavaLikeFileName(name)) {
1702
			name= name + "/"; //$NON-NLS-1$
1702
			name= name + "/"; //$NON-NLS-1$
1703
			name= name.replace('.', '/');
1703
			name= name.replace('.', '/');
1704
			return name;
1704
			return name;
(-)ui/org/eclipse/jdt/internal/ui/wizards/ClassPathDetector.java (-1 / +1 lines)
Lines 370-376 Link Here
370
		
370
		
371
		if (proxy.getType() == IResource.FILE) {
371
		if (proxy.getType() == IResource.FILE) {
372
			String name= proxy.getName();
372
			String name= proxy.getName();
373
			if (hasExtension(name, ".java") && isValidCUName(name)) { //$NON-NLS-1$
373
			if (isValidCUName(name)) {
374
				visitCompilationUnit((IFile) proxy.requestResource());
374
				visitCompilationUnit((IFile) proxy.requestResource());
375
			} else if (hasExtension(name, ".class")) { //$NON-NLS-1$
375
			} else if (hasExtension(name, ".class")) { //$NON-NLS-1$
376
				fClassFiles.add(proxy.requestResource());
376
				fClassFiles.add(proxy.requestResource());
(-)ui/org/eclipse/jdt/internal/ui/jarpackager/JarFileExportOperation.java (-2 / +3 lines)
Lines 677-683 Link Here
677
677
678
	/**
678
	/**
679
	 * Answers whether the given resource is a Java file.
679
	 * Answers whether the given resource is a Java file.
680
	 * The resource must be a file whose file name ends with ".java".
680
	 * The resource must be a file whose file name ends with ".java",
681
	 * or an extension defined as Java source.
681
	 * 
682
	 * 
682
	 * @return a <code>true<code> if the given resource is a Java file
683
	 * @return a <code>true<code> if the given resource is a Java file
683
	 */
684
	 */
Lines 685-691 Link Here
685
		return file != null
686
		return file != null
686
			&& file.getType() == IResource.FILE
687
			&& file.getType() == IResource.FILE
687
			&& file.getFileExtension() != null
688
			&& file.getFileExtension() != null
688
			&& file.getFileExtension().equalsIgnoreCase("java"); //$NON-NLS-1$
689
			&& JavaCore.isJavaLikeFileName(file.getName());
689
	}
690
	}
690
691
691
	/**
692
	/**
(-)core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java (-1 / +14 lines)
Lines 817-821 Link Here
817
		return defaultCompliance;
817
		return defaultCompliance;
818
	}
818
	}
819
819
820
820
	/**
821
	 * Return the extension of a compilation unit, which is
822
	 * usually (but not always) ".java"
823
	 * @param cu a compilation unit
824
	 * @return the extension for the compilation unit
825
	 */
826
	public static String getCompilationUnitExtension(ICompilationUnit cu) {
827
		String name = cu.getElementName();
828
		int i = name.lastIndexOf('.');
829
		if (i != -1) {
830
			return name.substring(i);
831
		}
832
		return ".java"; //$NON-NLS-1$
833
	}
821
}
834
}
(-)core refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RenameTypeProcessor.java (-3 / +6 lines)
Lines 836-844 Link Here
836
			if (willRenameCU()) {
836
			if (willRenameCU()) {
837
				IResource resource= ResourceUtil.getResource(fType);
837
				IResource resource= ResourceUtil.getResource(fType);
838
				if (resource != null && resource.isLinked()) {
838
				if (resource != null && resource.isLinked()) {
839
					result.add(new RenameResourceChange(ResourceUtil.getResource(fType), getNewElementName() + ".java")); //$NON-NLS-1$)
839
					String ext = '.' + resource.getFileExtension();
840
					result.add(new RenameResourceChange(ResourceUtil.getResource(fType), getNewElementName() + ext));
840
				} else {
841
				} else {
841
					result.add(new RenameCompilationUnitChange(fType.getCompilationUnit(), getNewElementName() + ".java")); //$NON-NLS-1$
842
					String ext = JavaModelUtil.getCompilationUnitExtension(fType.getCompilationUnit());
843
					result.add(new RenameCompilationUnitChange(fType.getCompilationUnit(), getNewElementName() + ext));
842
				}
844
				}
843
			}
845
			}
844
			monitor.worked(1);
846
			monitor.worked(1);
Lines 861-867 Link Here
861
	}
863
	}
862
	
864
	
863
	private boolean willRenameCU() throws CoreException{
865
	private boolean willRenameCU() throws CoreException{
864
		if (! (Checks.isTopLevel(fType) && fType.getCompilationUnit().getElementName().equals(fType.getElementName() + ".java"))) //$NON-NLS-1$
866
		String name = JavaCore.removeJavaLikeExtension(fType.getCompilationUnit().getElementName());
867
		if (! (Checks.isTopLevel(fType) && name.equals(fType.getElementName())))
865
			return false;
868
			return false;
866
		if (! checkNewPathValidity().isOK())
869
		if (! checkNewPathValidity().isOK())
867
			return false;
870
			return false;
(-)ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/RenameCuWizard.java (-4 / +4 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.ui.refactoring.reorg;
11
package org.eclipse.jdt.internal.ui.refactoring.reorg;
12
12
13
13
14
import org.eclipse.jdt.core.JavaCore;
15
14
import org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
16
import org.eclipse.jdt.internal.corext.refactoring.rename.RenameCompilationUnitProcessor;
15
import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating;
17
import org.eclipse.jdt.internal.corext.refactoring.tagging.INameUpdating;
16
18
Lines 35-41 Link Here
35
	}
37
	}
36
	
38
	
37
	protected RefactoringStatus validateNewName(String newName) {
39
	protected RefactoringStatus validateNewName(String newName) {
38
		String fullName= newName + ".java";  //$NON-NLS-1$
40
		String fullName= newName + JAVA_FILE_EXT;
39
		return super.validateNewName(fullName);
41
		return super.validateNewName(fullName);
40
	}
42
	}
41
	
43
	
Lines 47-55 Link Here
47
			protected String getNewName(INameUpdating nameUpdating) {
49
			protected String getNewName(INameUpdating nameUpdating) {
48
				String result= nameUpdating.getNewElementName();
50
				String result= nameUpdating.getNewElementName();
49
				// If renaming a CU we have to remove the java file extension
51
				// If renaming a CU we have to remove the java file extension
50
				if (result != null && result.endsWith(JAVA_FILE_EXT))
52
				return JavaCore.removeJavaLikeExtension(result);
51
					result= result.substring(0, result.length() - JAVA_FILE_EXT.length());
52
				return result;
53
			}
53
			}
54
		};
54
		};
55
	}
55
	}
(-)ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/newsourcepage/DialogPackageExplorerActionGroup.java (-2 / +2 lines)
Lines 41-50 Link Here
41
import org.eclipse.jdt.core.JavaCore;
41
import org.eclipse.jdt.core.JavaCore;
42
import org.eclipse.jdt.core.JavaModelException;
42
import org.eclipse.jdt.core.JavaModelException;
43
43
44
import org.eclipse.jdt.internal.corext.buildpath.CreateFolderOperation;
45
import org.eclipse.jdt.internal.corext.buildpath.AddSelectedSourceFolderOperation;
44
import org.eclipse.jdt.internal.corext.buildpath.AddSelectedSourceFolderOperation;
46
import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifier;
45
import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifier;
47
import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifierOperation;
46
import org.eclipse.jdt.internal.corext.buildpath.ClasspathModifierOperation;
47
import org.eclipse.jdt.internal.corext.buildpath.CreateFolderOperation;
48
import org.eclipse.jdt.internal.corext.buildpath.EditFiltersOperation;
48
import org.eclipse.jdt.internal.corext.buildpath.EditFiltersOperation;
49
import org.eclipse.jdt.internal.corext.buildpath.EditOutputFolderOperation;
49
import org.eclipse.jdt.internal.corext.buildpath.EditOutputFolderOperation;
50
import org.eclipse.jdt.internal.corext.buildpath.ExcludeOperation;
50
import org.eclipse.jdt.internal.corext.buildpath.ExcludeOperation;
Lines 621-627 Link Here
621
    private static int getFileType(IFile file, IJavaProject project) throws JavaModelException {
621
    private static int getFileType(IFile file, IJavaProject project) throws JavaModelException {
622
        if (ClasspathModifier.isArchive(file, project))
622
        if (ClasspathModifier.isArchive(file, project))
623
            return ARCHIVE;
623
            return ARCHIVE;
624
        if (!file.getName().endsWith(".java")) //$NON-NLS-1$
624
        if (!JavaCore.isJavaLikeFileName(file.getName()))
625
            return FILE;
625
            return FILE;
626
        IContainer fileParent= file.getParent();
626
        IContainer fileParent= file.getParent();
627
		if (fileParent.getFullPath().equals(project.getPath())) {
627
		if (fileParent.getFullPath().equals(project.getPath())) {
(-)ui/org/eclipse/jdt/internal/ui/javadocexport/JavadocOptionsManager.java (-1 / +1 lines)
Lines 518-524 Link Here
518
			StringTokenizer tokenizer= new StringTokenizer(sourcefiles, ","); //$NON-NLS-1$
518
			StringTokenizer tokenizer= new StringTokenizer(sourcefiles, ","); //$NON-NLS-1$
519
			while (tokenizer.hasMoreTokens()) {
519
			while (tokenizer.hasMoreTokens()) {
520
				String name= tokenizer.nextToken().trim();
520
				String name= tokenizer.nextToken().trim();
521
				if (name.endsWith(".java")) { //$NON-NLS-1$
521
				if (JavaCore.isJavaLikeFileName(name)) {
522
					IPath path= makeAbsolutePathFromRelative(new Path(name));
522
					IPath path= makeAbsolutePathFromRelative(new Path(name));
523
					//if unable to create an absolute path the the resource skip it
523
					//if unable to create an absolute path the the resource skip it
524
					if (path != null) {
524
					if (path != null) {

Return to bug 89977