List of usage examples for org.eclipse.jdt.core IMethod getTypeRoot
ITypeRoot getTypeRoot();
From source file:ca.uvic.chisel.javasketch.internal.ast.groups.ASTLoopGroupCalculator.java
License:Open Source License
private static IDocument getDocumentFor(IJavaElement element) { try {/* ww w. ja v a2 s .c om*/ if (element instanceof IMethod) { IMethod method = (IMethod) element; String source = null; ITypeRoot root = method.getTypeRoot(); source = root.getSource(); if (source != null) { return new Document(source); } } } catch (CoreException e) { SketchPlugin.getDefault().log(e); } return null; }
From source file:rabbit.ui.internal.treebuilders.JavaDataTreeBuilderTest.java
License:Apache License
@Override public void shouldCorrectlyBuildMultiplePaths() { WorkspaceStorage ws2 = new WorkspaceStorage(new Path(".b"), null); LocalDate date2 = date.minusDays(2); IMethod method2 = (IMethod) JavaCore.create("=Proj2/src2<com.example2{My.java[My~getDefault"); Duration duration2 = duration.minus(100); ICategory[] categories = { Category.WORKSPACE, Category.JAVA_TYPE_ROOT }; List<TreePath> expected = asList(newPath(ws, method.getTypeRoot(), duration), newPath(ws2, method2.getTypeRoot(), duration2)); IJavaData data2 = mock(IJavaData.class); given(data2.get(IJavaData.DATE)).willReturn(date2); given(data2.get(IJavaData.DURATION)).willReturn(duration2); given(data2.get(IJavaData.JAVA_ELEMENT)).willReturn(method2); given(data2.get(IJavaData.WORKSPACE)).willReturn(ws2); ICategoryProvider provider = mock(ICategoryProvider.class); given(provider.getSelected()).willReturn(asList(categories)); ITreePathBuilder builder = create(provider); IJavaDataProvider input = mock(IJavaDataProvider.class); given(input.get()).willReturn(asList(data, data2)); List<TreePath> actual = builder.build(input); assertThat(actual.size(), equalTo(expected.size())); assertThat(toString(actual, expected), actual, hasItems(expected.toArray(new TreePath[0]))); }