Java Code Examples for org.eclipse.jdt.core.IJavaProject#findType()

The following examples show how to use org.eclipse.jdt.core.IJavaProject#findType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroovyDocumentUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static void refreshUserLibrary(Repository repository) {
    try {
        FunctionsRepositoryFactory.getUserFunctionCatgory().removeAllFunctions();
        GroovyRepositoryStore store = repository.getRepositoryStore(GroovyRepositoryStore.class);
        IJavaProject javaProject = repository.getJavaProject();
        for (IRepositoryFileStore artifact : store.getChildren()) {
            IType type = javaProject.findType(artifact.getDisplayName().replace("/", "."));
            if (type != null) {
                for (IMethod m : type.getMethods()) {
                    if (m.getFlags() == (Flags.AccStatic | Flags.AccPublic)) {
                        FunctionsRepositoryFactory.getUserFunctionCatgory()
                                .addFunction(new GroovyFunction(m, FunctionsRepositoryFactory.getUserFunctionCatgory()));
                    }
                }
            }
        }
    } catch (Exception e) {
        GroovyPlugin.logError(e);
    }
}
 
Example 2
Source File: JavaSetterOperatorConstraint.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private IStatus validateMethodExists(final IValidationContext ctx, final Operator operator,
        final String leftOperandType) throws JavaModelException {
    final IJavaProject javaProject = javaProject();
    final IType type = javaProject.findType(leftOperandType);
    if (type == null) {
        return ctx.createFailureStatus(NLS.bind(Messages.failedToRetrieveLeftOperandType, leftOperandType));
    }
    final String parameterType = operator.getInputTypes().get(0);
    final String methodName = operator.getExpression();
    final Optional<IMethod> foundMethod = tryFind(JDTMethodHelper.allPublicMethodWithOneParameter(type), methodWith(methodName, parameterType));
    if (!foundMethod.isPresent()) {
        return ctx.createFailureStatus(NLS.bind(Messages.methodDoesnotExistInLeftOperandType,
                new String[] { methodName, parameterType, leftOperandName(operator) }));
    }
    return ctx.createSuccessStatus();
}
 
Example 3
Source File: HoverHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testInvalidJavadoc() throws Exception {
	importProjects("maven/aspose");
	IProject project = null;
	ICompilationUnit unit = null;
	try {
		project = ResourcesPlugin.getWorkspace().getRoot().getProject("aspose");
		IJavaProject javaProject = JavaCore.create(project);
		IType type = javaProject.findType("org.sample.TestJavadoc");
		unit = type.getCompilationUnit();
		unit.becomeWorkingCopy(null);
		String uri = JDTUtils.toURI(unit);
		TextDocumentIdentifier textDocument = new TextDocumentIdentifier(uri);
		TextDocumentPositionParams position = new TextDocumentPositionParams(textDocument, new Position(8, 24));
		Hover hover = handler.hover(position, monitor);
		assertNotNull(hover);
		assertNotNull(hover.getContents());
		assertEquals(1, hover.getContents().getLeft().size());
		assertEquals("com.aspose.words.Document.Document(String fileName) throws Exception", hover.getContents().getLeft().get(0).getRight().getValue());
	} finally {
		if (unit != null) {
			unit.discardWorkingCopy();
		}
	}
}
 
Example 4
Source File: JDTUtils.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Resolves the field described by the receiver and returns it if found. Returns
 * <code>null</code> if no corresponding member can be found.
 *
 * @param proposal
 *            - completion proposal
 * @param javaProject
 *            - Java project
 *
 * @return the resolved field or <code>null</code> if none is found
 * @throws JavaModelException
 *             if accessing the java model fails
 */
public static IField resolveField(CompletionProposal proposal, IJavaProject javaProject) throws JavaModelException {
	char[] declarationSignature = proposal.getDeclarationSignature();
	// for synthetic fields on arrays, declaration signatures may be null
	// TODO remove when https://bugs.eclipse.org/bugs/show_bug.cgi?id=84690 gets fixed
	if (declarationSignature == null) {
		return null;
	}
	String typeName = SignatureUtil.stripSignatureToFQN(String.valueOf(declarationSignature));
	IType type = javaProject.findType(typeName);
	if (type != null) {
		String name = String.valueOf(proposal.getName());
		IField field = type.getField(name);
		if (field.exists()) {
			return field;
		}
	}

	return null;
}
 
Example 5
Source File: XbaseEditorOpenClassFileTest.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testOpenFileFromSmapJarWithAttachedSource() {
  try {
    boolean _supportsEditorOverride = this.supportsEditorOverride();
    boolean _not = (!_supportsEditorOverride);
    if (_not) {
      return;
    }
    final IProject project = WorkbenchTestHelper.createPluginProject("my.example.project");
    final IJavaProject jp = JavaCore.create(project);
    final IPackageFragmentRoot root = this.addJarToClassPath(jp, "smap-binary.jar", "smap-sources.jar");
    Assert.assertNotNull(root);
    final IType type = jp.findType("de.itemis.HelloXtend");
    Assert.assertNotNull(type);
    final String result = this.getEditorContents(type);
    this.assertContains("println(\'Hello Xtend!\')", result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: AbstractXbaseContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected static void doInitBigDecimalFeatures(IJavaProject javaProject) throws JavaModelException {
	IType bigDecimalType = javaProject.findType(BigDecimal.class.getName());
	Set<String> featuresOrTypes = Sets.newHashSet();
	List<String> features = Lists.newArrayList();
	List<String> staticFeatures = Lists.newArrayList();
	addMethods(bigDecimalType, features, staticFeatures, featuresOrTypes);
	// compareTo(T) is actually overridden by compareTo(String) but contained twice in String.class#getMethods
	features.remove("compareTo()");
	Set<String> featuresAsSet = Sets.newHashSet(features);
	Set<String> staticFeaturesAsSet = Sets.newHashSet(staticFeatures);
	Set<String> types = Sets.newHashSet();
	addFields(bigDecimalType, features, staticFeatures, featuresAsSet, staticFeaturesAsSet, types);
	// Object extensions
	features.add("identityEquals()");
	BIGDECIMAL_FEATURES = features.toArray(new String[features.size()]);
	STATIC_BIGDECIMAL_FEATURES = staticFeatures.toArray(new String[staticFeatures.size()]);
}
 
Example 7
Source File: JdtTypeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
private boolean isParameterNamesAvailable() throws Exception {
	ASTParser parser = ASTParser.newParser(AST.JLS3);
	parser.setIgnoreMethodBodies(true);
	IJavaProject javaProject = projectProvider.getJavaProject(resourceSet);
	parser.setProject(javaProject);
	IType type = javaProject.findType("org.eclipse.xtext.common.types.testSetups.TestEnum");
	IBinding[] bindings = parser.createBindings(new IJavaElement[] { type }, null);
	ITypeBinding typeBinding = (ITypeBinding) bindings[0];
	IMethodBinding[] methods = typeBinding.getDeclaredMethods();
	for(IMethodBinding method: methods) {
		if (method.isConstructor()) {
			IMethod element = (IMethod) method.getJavaElement();
			if (element.exists()) {
				String[] parameterNames = element.getParameterNames();
				if (parameterNames.length == 1 && parameterNames[0].equals("string")) {
					return true;
				}
			} else {
				return false;
			}
		}
	}
	return false;
}
 
Example 8
Source File: Jdt2Ecore.java    From sarl with Apache License 2.0 5 votes vote down vote up
/** Create a {@link TypeFinder} wrapper for the given Java project.
 *
 * <p>The wrapper invokes {@link IJavaProject#findType(String)} on the given project.
 *
 * @param project the project to wrap.
 * @return the type finder based on the given Java project.
 */
public TypeFinder toTypeFinder(final IJavaProject project) {
	return new TypeFinder() {
		@Override
		public IType findType(String typeName) throws JavaModelException {
			return project.findType(typeName);
		}
	};
}
 
Example 9
Source File: ClassFileDocumentProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles the deletion of the element underlying the given class file editor input.
 * @param input the editor input
 */
protected void handleDeleted(IClassFileEditorInput input) {
	if (input == null) {
		fireElementDeleted(input);
		return;
	}

	if (input.exists())
		return;

	IClassFile cf= input.getClassFile();
	try {
		/*
		 * Let's try to find the class file - maybe the JAR changed
		 */
		IType type= cf.getType();
		IJavaProject project= cf.getJavaProject();
		if (project != null) {
			type= project.findType(type.getFullyQualifiedName());
			if (type != null) {
				IEditorInput editorInput= EditorUtility.getEditorInput(type.getParent());
				if (editorInput instanceof IClassFileEditorInput) {
					fireInputChanged((IClassFileEditorInput)editorInput);
					return;
				}
			}
		}
	} catch (JavaModelException x) {
		// Don't log and fall through: element deleted
	}

	fireElementDeleted(input);

}
 
Example 10
Source File: JavaProjectPipelineOptionsHierarchy.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link JavaProjectPipelineOptionsHierarchy}. This can be a long-running method,
 * as it fetches the type hierarchy of the provided project.
 *
 * @throws JavaModelException
 */
public JavaProjectPipelineOptionsHierarchy(
    IJavaProject project, MajorVersion version, IProgressMonitor monitor)
    throws JavaModelException {
  IType rootType = project.findType(PipelineOptionsNamespaces.rootType(version));
  Preconditions.checkNotNull(rootType, "project has no PipelineOptions type");
  Preconditions.checkArgument(rootType.exists(), "PipelineOptions does not exist in project");

  // Flatten the class hierarchy, recording all the classes present
  this.hierarchy = rootType.newTypeHierarchy(monitor);

  this.project = project;
  this.majorVersion = version;
  this.knownTypes = new HashMap<>();
}
 
Example 11
Source File: JavaDocImageExtractionTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public void ensureSourceOfClassIsDownloaded(String classpathName) throws Exception {
	IJavaProject javaProject = JavaCore.create(project);
	IType type = javaProject.findType(classpathName); //eg: reactor.core.publisher.Mono
	IClassFile classFile = ((BinaryType) type).getClassFile();
	String source = new SourceContentProvider().getSource(classFile, new NullProgressMonitor());
	if (source == null) {
		JobHelpers.waitForDownloadSourcesJobs(JobHelpers.MAX_TIME_MILLIS);
		source = new SourceContentProvider().getSource(classFile, new NullProgressMonitor());
	}
	assertNotNull(source);
}
 
Example 12
Source File: XtendUIValidator.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isSameProject(XAnnotation annotation, JvmType annotationType) throws JavaModelException {
	IJavaProject project = projectProvider.getJavaProject(annotation.eResource().getResourceSet());
	if (annotationType.eResource().getURI().isPlatformResource()) {
		String projectName = annotationType.eResource().getURI().segments()[1];
		return project.getProject().getName().equals(projectName);
	} else { // assume java type resource
		IType type = project.findType(annotationType.getIdentifier());
		if (type != null && type.getUnderlyingResource() instanceof IFile) {
			return isInSourceFolder(project, (IFile) type.getUnderlyingResource());
		}
		return false;
	}
}
 
Example 13
Source File: XbaseEditorOpenClassFileTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOpenEditor_NameConflict02() {
  try {
    boolean _supportsEditorOverride = this.supportsEditorOverride();
    boolean _not = (!_supportsEditorOverride);
    if (_not) {
      return;
    }
    final IJavaProject jp = JavaCore.create(this.project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("// Xtend");
    _builder.newLine();
    _builder.append("package myPackage");
    _builder.newLine();
    _builder.append("class Foo {}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myPackage/Foo.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("// Java");
    _builder_1.newLine();
    _builder_1.append("package otherPackage;");
    _builder_1.newLine();
    _builder_1.append("public class Foo {}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("otherPackage/Foo.java", _builder_1.toString());
    this.addJarToProject(this.project, 
      this.createJar(_mappedTo, _mappedTo_1));
    IResourcesSetupUtil.waitForBuild();
    final IType type = jp.findType("myPackage.Foo");
    Assert.assertNotNull(type);
    final String result = this.getEditorContents(type);
    this.assertContains("package myPackage;", result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 14
Source File: AbstractXbaseContentAssistTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected static void doInitClassFeatures(IJavaProject javaProject) throws JavaModelException {
	IType classType = javaProject.findType(Class.class.getName());
	Set<String> featuresOrTypes = Sets.newHashSet();
	List<String> features = Lists.newArrayList();
	List<String> staticFeatures = Lists.newArrayList();
	addMethods(classType, features, staticFeatures, featuresOrTypes);
	Set<String> featuresAsSet = Sets.newHashSet(features);
	Set<String> staticFeaturesAsSet = Sets.newHashSet(staticFeatures);
	Set<String> types = Sets.newHashSet();
	addFields(classType, features, staticFeatures, featuresAsSet, staticFeaturesAsSet, types);
	// Object extensions
	features.add("identityEquals()");
	CLASS_FEATURES = features.toArray(new String[features.size()]);
	STATIC_CLASS_FEATURES = staticFeatures.toArray(new String[staticFeatures.size()]);
}
 
Example 15
Source File: XbaseEditorOpenClassFileTest.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testOpenEditor_NameConflict() {
  try {
    boolean _supportsEditorOverride = this.supportsEditorOverride();
    boolean _not = (!_supportsEditorOverride);
    if (_not) {
      return;
    }
    final IJavaProject jp = JavaCore.create(this.project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("// Xtend");
    _builder.newLine();
    _builder.append("package myPackage");
    _builder.newLine();
    _builder.append("class Foo {}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myPackage/Foo.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("// Java");
    _builder_1.newLine();
    _builder_1.append("package otherPackage;");
    _builder_1.newLine();
    _builder_1.append("public class Foo {}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("otherPackage/Foo.java", _builder_1.toString());
    this.addJarToProject(this.project, 
      this.createJar(_mappedTo, _mappedTo_1));
    IResourcesSetupUtil.waitForBuild();
    final IType type = jp.findType("otherPackage.Foo");
    Assert.assertNotNull(type);
    final String result = this.getEditorContents(type);
    this.assertContains("// Java", result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 16
Source File: CompletionsProvider.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
private IType resolveType(StackFrame frame) throws CoreException, DebugException {
    ISourceLookUpProvider sourceProvider = context.getProvider(ISourceLookUpProvider.class);
    if (sourceProvider instanceof JdtSourceLookUpProvider) {
        IJavaProject project = JdtUtils.findProject(frame, ((JdtSourceLookUpProvider) sourceProvider).getSourceContainers());
        if (project != null) {
            return project.findType(JdtUtils.getDeclaringTypeName(frame));
        }
    }
    return null;
}
 
Example 17
Source File: ExpressionReturnTypeFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param currentReturnType
 * @param targetReturnType
 * @return true if currentReturnType is in the targetReturnType hierarchy or if one of the both types is unknown
 */
public boolean compatibleReturnTypes(final String currentReturnType, final String targetReturnType) {
    if (Objects.equals(currentReturnType, targetReturnType)) {
        return true;
    }
    if (currentReturnType == null || targetReturnType == null) {
        return false;
    }
    try {
        final Class<?> currentReturnTypeClass = Class.forName(currentReturnType);
        final Class<?> targetReturnTypeClass = Class.forName(targetReturnType);
        return currentReturnTypeClass.isAssignableFrom(targetReturnTypeClass);
    } catch (final ClassNotFoundException e) {
        final IJavaContainer javaContainer = javaContainer();
        final IJavaProject javaProject = javaContainer.getJavaProject();
        if (javaProject != null) {
            try {
                final IType currentType = javaProject.findType(currentReturnType);
                final IType targetType = javaProject.findType(targetReturnType);
                if (currentType != null && targetType != null) {
                    return javaContainer.getJdtTypeHierarchyManager().getTypeHierarchy(currentType)
                            .contains(targetType);
                }
            } catch (final JavaModelException e1) {
                BonitaStudioLog.error(e1);
            }
        }
        BonitaStudioLog.debug("Failed to determine the compatibility between " + targetReturnType + " and "
                + currentReturnType, ExpressionEditorPlugin.PLUGIN_ID);
    }
    return true;
}
 
Example 18
Source File: XbaseEditorOpenClassFileTest.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testOpenEditor_NameConflict03() {
  try {
    boolean _supportsEditorOverride = this.supportsEditorOverride();
    boolean _not = (!_supportsEditorOverride);
    if (_not) {
      return;
    }
    final IJavaProject jp = JavaCore.create(this.project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("// Xtend");
    _builder.newLine();
    _builder.append("package myPackage");
    _builder.newLine();
    _builder.append("class Foo2 {}");
    _builder.newLine();
    Pair<String, String> _mappedTo = Pair.<String, String>of("myPackage/Foo.xtend", _builder.toString());
    StringConcatenation _builder_1 = new StringConcatenation();
    _builder_1.append("// Java");
    _builder_1.newLine();
    _builder_1.append("package otherPackage;");
    _builder_1.newLine();
    _builder_1.append("public class Foo {}");
    _builder_1.newLine();
    Pair<String, String> _mappedTo_1 = Pair.<String, String>of("otherPackage/Foo.java", _builder_1.toString());
    this.addJarToProject(this.project, 
      this.createJar(_mappedTo, _mappedTo_1));
    IResourcesSetupUtil.waitForBuild();
    final IType type = jp.findType("myPackage.Foo2");
    Assert.assertNotNull(type);
    final String result = this.getEditorContents(type);
    StringConcatenation _builder_2 = new StringConcatenation();
    _builder_2.append("// Xtend");
    _builder_2.newLine();
    _builder_2.append("package myPackage");
    _builder_2.newLine();
    _builder_2.append("class Foo2 {}");
    _builder_2.newLine();
    this.assertContains(_builder_2.toString(), result);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 19
Source File: AdvancedOrganizeImportsHandlerTest.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
@Test
public void testAmbiguousStaticImports() throws Exception {
	importProjects("maven/salut4");
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("salut4");
	assertTrue(ProjectUtils.isMavenProject(project));
	String[] favourites = JavaLanguageServerPlugin.getPreferencesManager().getPreferences().getJavaCompletionFavoriteMembers();
	try {
		List<String> list = new ArrayList<>();
		list.add("org.junit.jupiter.api.Assertions.*");
		list.add("org.junit.jupiter.api.Assumptions.*");
		list.add("org.junit.jupiter.api.DynamicContainer.*");
		list.add("org.junit.jupiter.api.DynamicTest.*");
		list.add("org.hamcrest.MatcherAssert.*");
		list.add("org.hamcrest.Matchers.*");
		list.add("org.mockito.Mockito.*");
		list.add("org.mockito.ArgumentMatchers.*");
		list.add("org.mockito.Answers.*");
		list.add("org.mockito.hamcrest.MockitoHamcrest.*");
		list.add("org.mockito.Matchers.*");
		JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setJavaCompletionFavoriteMembers(list);
		IJavaProject javaProject = JavaCore.create(project);
		IType type = javaProject.findType("org.sample.MyTest");
		ICompilationUnit unit = type.getCompilationUnit();
		TextEdit edit = OrganizeImportsHandler.organizeImports(unit, (selections) -> {
			return new ImportCandidate[0];
		});
		assertNotNull(edit);
		JavaModelUtil.applyEdit(unit, edit, true, null);
		/* @formatter:off */
		String expected = "package org.sample;\n" +
				"\n" +
				"import static org.hamcrest.MatcherAssert.assertThat;\n" +
				"import static org.junit.jupiter.api.Assertions.assertEquals;\n" +
				"\n" +
				"import org.junit.jupiter.api.Test;\n" +
				"\n" +
				"public class MyTest {\n" +
				"    @Test\n" +
				"    public void test() {\n" +
				"        assertEquals(1, 1, \"message\");\n" +
				"        assertThat(\"test\", true);\n" +
				"        any();\n" +
				"    }\n" +
				"}\n";
		//@formatter:on
		compareSource(expected, unit.getSource());
	} finally {
		JavaLanguageServerPlugin.getPreferencesManager().getPreferences().setJavaCompletionFavoriteMembers(Arrays.asList(favourites));
	}
}
 
Example 20
Source File: JavaElementLinks.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private static IType resolvePackageInfoType(IPackageFragment pack, String refTypeName) throws JavaModelException {
		// Note: The scoping rules of JLS7 6.3 are broken for package-info.java, see https://bugs.eclipse.org/216451#c4
		// We follow the javadoc tool's implementation and only support fully-qualified type references:
		IJavaProject javaProject= pack.getJavaProject();
		return javaProject.findType(refTypeName, (IProgressMonitor) null);
		
		// This implementation would make sense, but the javadoc tool doesn't support it:
//		IClassFile classFile= pack.getClassFile(JavaModelUtil.PACKAGE_INFO_CLASS);
//		if (classFile.exists()) {
//			return resolveType(classFile.getType(), refTypeName);
//		}
//		
//		// check if refTypeName is a qualified name
//		int firstDot= refTypeName.indexOf('.');
//		if (firstDot != -1) {
//			String typeNameRest= refTypeName.substring(firstDot + 1);
//			String simpleTypeName= refTypeName.substring(0, firstDot);
//			IType simpleType= resolvePackageInfoType(pack, simpleTypeName);
//			if (simpleType != null) {
//				// a type-qualified name
//				return resolveType(simpleType, typeNameRest);
//			} else {
//				// a fully-qualified name
//				return javaProject.findType(refTypeName, (IProgressMonitor) null);
//			}
//		}
//		
//		ICompilationUnit cu= pack.getCompilationUnit(JavaModelUtil.PACKAGE_INFO_JAVA);
//		if (! cu.exists()) {
//			// refTypeName is a simple name in the package-info.java from the source attachment. Sorry, we give up here...
//			return null;
//		}
//		
//		// refTypeName is a simple name in a CU. Let's play the shadowing rules of JLS7 6.4.1:
//		// 1) single-type import
//		// 2) enclosing package
//		// 3) java.lang.* (JLS7 7.3)
//		// 4) on-demand import
//		IImportDeclaration[] imports= cu.getImports();
//		for (int i= 0; i < imports.length; i++) {
//			IImportDeclaration importDecl= imports[i];
//			String name= importDecl.getElementName();
//			if (Flags.isStatic(importDecl.getFlags())) {
//				imports[i]= null;
//			} else 	if (! importDecl.isOnDemand()) {
//				if (name.endsWith('.' + refTypeName)) {
//					// 1) single-type import
//					IType type= javaProject.findType(name, (IProgressMonitor) null);
//					if (type != null)
//						return type;
//				}
//				imports[i]= null;
//			}
//		}
//		
//		// 2) enclosing package
//		IType type= javaProject.findType(pack.getElementName() + '.' + refTypeName, (IProgressMonitor) null);
//		if (type != null)
//			return type;
//		
//		// 3) java.lang.* (JLS7 7.3)
//		type= javaProject.findType("java.lang." + refTypeName, (IProgressMonitor) null); //$NON-NLS-1$
//		if (type != null)
//			return type;
//		
//		// 4) on-demand import
//		for (int i= 0; i < imports.length; i++) {
//			IImportDeclaration importDecl= imports[i];
//			if (importDecl != null) {
//				String name= importDecl.getElementName();
//				name= name.substring(0, name.length() - 1); //remove the *
//				type= javaProject.findType(name + refTypeName, (IProgressMonitor) null);
//				if (type != null)
//					return type;
//			}
//		}
//		return null;
	}