Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 37525
Collapse All | Expand All

(-)core extension/org/eclipse/jdt/internal/corext/util/TypeInfoFactory.java (-14 / +68 lines)
Lines 13-25 Link Here
13
import java.util.Arrays;
13
import java.util.Arrays;
14
import java.util.Comparator;
14
import java.util.Comparator;
15
15
16
import org.eclipse.core.runtime.Path;
17
16
import org.eclipse.core.resources.ResourcesPlugin;
18
import org.eclipse.core.resources.ResourcesPlugin;
17
19
20
import org.eclipse.jdt.core.IJavaElement;
18
import org.eclipse.jdt.core.IJavaModel;
21
import org.eclipse.jdt.core.IJavaModel;
19
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.IJavaProject;
20
import org.eclipse.jdt.core.JavaCore;
23
import org.eclipse.jdt.core.JavaCore;
21
import org.eclipse.jdt.core.JavaModelException;
24
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.search.IJavaSearchScope;
23
25
24
26
25
public class TypeInfoFactory {
27
public class TypeInfoFactory {
Lines 39-50 Link Here
39
	}
41
	}
40
42
41
	public TypeInfo create(char[] packageName, char[] typeName, char[][] enclosingName, int modifiers, String path) {
43
	public TypeInfo create(char[] packageName, char[] typeName, char[][] enclosingName, int modifiers, String path) {
44
		int index= path.length();
45
		int jarSeparator = -1;
46
		int packageLength= packageName.length;
47
		int packageEnd= -1;
48
		loop: while (index-- > 0) {
49
			char c= path.charAt(index);
50
			switch (c) {
51
				case TypeInfo.JAR_SEPARATOR:
52
					jarSeparator= index;
53
					break loop;
54
				case TypeInfo.SEPARATOR :
55
					if (packageEnd == -1) {
56
						packageEnd= index;
57
						break;
58
					} else if (packageEnd-index <= packageLength && packageName[packageLength-(packageEnd-index)] != TypeInfo.PACKAGE_PART_SEPARATOR) {
59
						packageName= null;
60
						while (index-- > 0) {
61
							if (path.charAt(index) == TypeInfo.JAR_SEPARATOR) {
62
								jarSeparator= index;
63
								break;
64
							}
65
						}
66
						break loop;
67
					}
68
					break;
69
				default:
70
					if (packageEnd == -1)
71
						break;
72
					if (packageEnd-index <= packageLength && packageName[packageLength-(packageEnd-index)] != c) {
73
						packageName= null;
74
						while (index-- > 0) {
75
							if (path.charAt(index) == TypeInfo.JAR_SEPARATOR) {
76
								jarSeparator= index;
77
								break;
78
							}
79
						}
80
						break loop;
81
					}
82
					break;
83
			}
84
		}
85
		if (packageName == null)
86
			packageName= packageNameFromPath(path, index, packageEnd);
87
		if (TypeFilter.isFiltered(packageName, typeName))
88
			return null;
42
		String pn= getPackageName(packageName);
89
		String pn= getPackageName(packageName);
43
		String tn= new String(typeName);
90
		String tn= new String(typeName);
44
		TypeInfo result= null;
91
		TypeInfo result= null;
45
		int index= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR);
92
		if (jarSeparator != -1) {
46
		if (index != -1) {
93
			result= createJarFileEntryTypeInfo(pn, tn, enclosingName, modifiers, path, getJarFileEntryTypeInfo(fLast), jarSeparator);
47
			result= createJarFileEntryTypeInfo(pn, tn, enclosingName, modifiers, path, getJarFileEntryTypeInfo(fLast), index);
48
		} else {
94
		} else {
49
			String project= getProject(path);
95
			String project= getProject(path);
50
			if (project != null) {
96
			if (project != null) {
Lines 59-64 Link Here
59
		return result;
105
		return result;
60
	}
106
	}
61
	
107
	
108
	private char[] packageNameFromPath(String path, int jarSeparator, int packageEnd) {
109
		if (jarSeparator == -1) {
110
			IJavaElement openable= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)));
111
			return openable.getParent().getElementName().toCharArray();
112
		}
113
		return path.substring(jarSeparator, packageEnd).replace(TypeInfo.SEPARATOR, TypeInfo.PACKAGE_PART_SEPARATOR).toCharArray();
114
	}
115
62
	private static JarFileEntryTypeInfo getJarFileEntryTypeInfo(TypeInfo info) {
116
	private static JarFileEntryTypeInfo getJarFileEntryTypeInfo(TypeInfo info) {
63
		if (info == null || info.getElementType() != TypeInfo.JAR_FILE_ENTRY_TYPE_INFO)
117
		if (info == null || info.getElementType() != TypeInfo.JAR_FILE_ENTRY_TYPE_INFO)
64
			return null;
118
			return null;
Lines 71-89 Link Here
71
		return (IFileTypeInfo)info;
125
		return (IFileTypeInfo)info;
72
	}
126
	}
73
	
127
	
74
	private TypeInfo createJarFileEntryTypeInfo(String packageName, String typeName, char[][] enclosingName, int modifiers, String path, JarFileEntryTypeInfo last, int index) {
128
	private TypeInfo createJarFileEntryTypeInfo(String packageName, String typeName, char[][] enclosingName, int modifiers, String path, JarFileEntryTypeInfo last, int jarSeparator) {
75
		String jar= path.substring(0, index);
129
		String jar= path.substring(0, jarSeparator);
76
		String rest= path.substring(index + 1);
130
		String rest= path.substring(jarSeparator + 1);
77
		index= rest.lastIndexOf(TypeInfo.SEPARATOR);
131
		jarSeparator= rest.lastIndexOf(TypeInfo.SEPARATOR);
78
		if (index != -1) {
132
		if (jarSeparator != -1) {
79
			rest= rest.substring(index + 1);
133
			rest= rest.substring(jarSeparator + 1);
80
		}
134
		}
81
		String file= null;
135
		String file= null;
82
		String extension= null;
136
		String extension= null;
83
		index= rest.lastIndexOf(TypeInfo.EXTENSION_SEPARATOR);
137
		jarSeparator= rest.lastIndexOf(TypeInfo.EXTENSION_SEPARATOR);
84
		if (index != -1) {
138
		if (jarSeparator != -1) {
85
			file= rest.substring(0, index);
139
			file= rest.substring(0, jarSeparator);
86
			extension= rest.substring(index + 1);
140
			extension= rest.substring(jarSeparator + 1);
87
		} else {
141
		} else {
88
			return null;
142
			return null;
89
		}
143
		}
(-)core extension/org/eclipse/jdt/internal/corext/util/TypeInfo.java (+1 lines)
Lines 57-62 Link Here
57
	static final char SEPARATOR= '/';
57
	static final char SEPARATOR= '/';
58
	static final char EXTENSION_SEPARATOR= '.';
58
	static final char EXTENSION_SEPARATOR= '.';
59
	static final char PACKAGE_PART_SEPARATOR='.';
59
	static final char PACKAGE_PART_SEPARATOR='.';
60
	static final char JAR_SEPARATOR= '|'; //IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR.charAt(0);
60
	
61
	
61
	static final String EMPTY_STRING= ""; //$NON-NLS-1$
62
	static final String EMPTY_STRING= ""; //$NON-NLS-1$
62
	
63
	
(-)ui/org/eclipse/jdt/internal/ui/dialogs/TypeInfoViewer.java (-3 / +2 lines)
Lines 69-75 Link Here
69
import org.eclipse.jdt.internal.corext.Assert;
69
import org.eclipse.jdt.internal.corext.Assert;
70
import org.eclipse.jdt.internal.corext.util.Messages;
70
import org.eclipse.jdt.internal.corext.util.Messages;
71
import org.eclipse.jdt.internal.corext.util.Strings;
71
import org.eclipse.jdt.internal.corext.util.Strings;
72
import org.eclipse.jdt.internal.corext.util.TypeFilter;
73
import org.eclipse.jdt.internal.corext.util.TypeInfo;
72
import org.eclipse.jdt.internal.corext.util.TypeInfo;
74
import org.eclipse.jdt.internal.corext.util.TypeInfoFactory;
73
import org.eclipse.jdt.internal.corext.util.TypeInfoFactory;
75
import org.eclipse.jdt.internal.corext.util.TypeInfoFilter;
74
import org.eclipse.jdt.internal.corext.util.TypeInfoFilter;
Lines 126-134 Link Here
126
		public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
125
		public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
127
			if (fStop)
126
			if (fStop)
128
				return;
127
				return;
129
			if (TypeFilter.isFiltered(packageName, simpleTypeName))
130
				return;
131
			TypeInfo type= fFactory.create(packageName, simpleTypeName, enclosingTypeNames, modifiers, path);
128
			TypeInfo type= fFactory.create(packageName, simpleTypeName, enclosingTypeNames, modifiers, path);
129
			if (type == null)
130
				return;
132
			if (fHistory.contains(type))
131
			if (fHistory.contains(type))
133
				return;
132
				return;
134
			if (fFilter.matchesFilterExtension(type))
133
			if (fFilter.matchesFilterExtension(type))

Return to bug 37525