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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/SourceType.java (-3 / +5 lines)
Lines 767-775 Link Here
767
 * @see IType
767
 * @see IType
768
 */
768
 */
769
public ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaModelException {
769
public ITypeHierarchy newTypeHierarchy(IProgressMonitor monitor) throws JavaModelException {
770
	CreateTypeHierarchyOperation op= new CreateTypeHierarchyOperation(this, null, SearchEngine.createWorkspaceScope(), true);
770
	
771
	op.runOperation(monitor);
771
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=228845, The new type hierarchy should consider changes in primary
772
	return op.getResult();
772
	// working copy.
773
	 
774
	return newTypeHierarchy(DefaultWorkingCopyOwner.PRIMARY, monitor);
773
}
775
}
774
/*
776
/*
775
 * @see IType#newTypeHierarchy(ICompilationUnit[], IProgressMonitor)
777
 * @see IType#newTypeHierarchy(ICompilationUnit[], IProgressMonitor)
(-)src/org/eclipse/jdt/core/tests/model/HierarchyOnWorkingCopiesTests.java (+39 lines)
Lines 104-108 Link Here
104
		}
104
		}
105
	}
105
	}
106
}
106
}
107
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=228845
108
//make sure uncommitted changes to primary working copy shows up in hierarchy 
109
public void test228845() throws CoreException {
110
	String newContents =
111
		"package x.y;\n" +
112
		"public class A extends B {\n" +
113
		"}";
114
	
115
	ICompilationUnit primaryCu = this.copy.getPrimary();
116
	primaryCu.becomeWorkingCopy(null);
117
	
118
	primaryCu.getBuffer().setContents(newContents);
119
	primaryCu.reconcile(ICompilationUnit.NO_AST, false, null, null);
120
			
121
	IFile file = null;
122
	try {
123
		file = this.createFile(
124
			"P/src/x/y/B.java",
125
			"package x.y;\n" +
126
			"public class B {\n" +
127
			"}");
128
129
		IType type = this.getCompilationUnit("P/src/x/y/B.java").getType("B");
130
		ITypeHierarchy h = type.newTypeHierarchy(null);  // no working copies explicitly passed, should still honor primary working copies.
131
132
		assertHierarchyEquals(
133
			"Focus: B [in B.java [in x.y [in src [in P]]]]\n" +
134
			"Super types:\n" +
135
			"  Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" +
136
			"Sub types:\n" +
137
			"  A [in [Working copy] A.java [in x.y [in src [in P]]]]\n",
138
			h);
139
	} finally {
140
		primaryCu.discardWorkingCopy();
141
		if (file != null) {
142
			this.deleteResource(file);
143
		}
144
	}
145
}
107
146
108
}
147
}

Return to bug 228845