Search in sources :

Example 96 with IJavaProject

use of org.eclipse.jdt.core.IJavaProject in project xtext-eclipse by eclipse.

the class JdtAwareProjectByResourceProvider method getProjectContext.

@Override
public IProject getProjectContext(Resource resource) {
    IProject result = super.getProjectContext(resource);
    if (result != null) {
        return result;
    }
    IJavaProject javaProject = javaProjectProvider.getJavaProject(resource.getResourceSet());
    if (javaProject != null && javaProject.exists()) {
        return javaProject.getProject();
    }
    return null;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject)

Example 97 with IJavaProject

use of org.eclipse.jdt.core.IJavaProject in project xtext-eclipse by eclipse.

the class AbstractXbaseContentAssistBugTest method getJavaProject.

@Override
public IJavaProject getJavaProject(final ResourceSet resourceSet) {
    final String projectName = this.getProjectName();
    IJavaProject javaProject = JavaProjectSetupUtil.findJavaProject(projectName);
    if (((javaProject == null) || (!javaProject.exists()))) {
        try {
            this.demandCreateProject = AbstractXbaseUITestCase.createPluginProject(projectName);
            javaProject = JavaProjectSetupUtil.findJavaProject(projectName);
        } catch (final Throwable _t) {
            if (_t instanceof CoreException) {
                final CoreException e = (CoreException) _t;
                String _message = e.getMessage();
                String _plus = ("cannot create java project due to: " + _message);
                String _plus_1 = (_plus + " / ");
                String _plus_2 = (_plus_1 + e);
                Assert.fail(_plus_2);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    }
    return javaProject;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 98 with IJavaProject

use of org.eclipse.jdt.core.IJavaProject in project xtext-eclipse by eclipse.

the class Bug403554Test method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    final IJavaProject project = this.getJavaProject(null);
    IType type = project.findType(ArrayList.class.getName());
    IMethod method = type.getMethod("subList", new String[] { "I", "I" });
    while ((!method.exists())) {
        {
            String superclassName = type.getSuperclassName();
            final int idx = superclassName.indexOf("<");
            if ((idx != (-1))) {
                superclassName = superclassName.substring(0, idx);
            }
            type = project.findType(superclassName);
            method = type.getMethod("subList", new String[] { "I", "I" });
        }
    }
    this.declarator = type.getElementName();
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) ArrayList(java.util.ArrayList) IMethod(org.eclipse.jdt.core.IMethod) IType(org.eclipse.jdt.core.IType)

Example 99 with IJavaProject

use of org.eclipse.jdt.core.IJavaProject in project xtext-eclipse by eclipse.

the class ContentAssistInBlockTest method getJavaProject.

@Override
public IJavaProject getJavaProject(ResourceSet resourceSet) {
    IJavaProject javaProject = findJavaProject(PROJECT_NAME);
    if (javaProject == null || !javaProject.exists()) {
        try {
            demandCreateProject = AbstractXbaseUITestCase.createPluginProject(PROJECT_NAME);
            javaProject = findJavaProject(PROJECT_NAME);
        } catch (CoreException e) {
            fail("cannot create java project due to: " + e.getMessage() + " / " + e);
        }
    }
    return javaProject;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException)

Example 100 with IJavaProject

use of org.eclipse.jdt.core.IJavaProject in project xtext-eclipse by eclipse.

the class ContentAssistTest method getJavaProject.

@Override
public IJavaProject getJavaProject(ResourceSet resourceSet) {
    IJavaProject javaProject = findJavaProject(PROJECT_NAME);
    if (javaProject == null || !javaProject.exists()) {
        try {
            demandCreateProject = AbstractXbaseUITestCase.createPluginProject(PROJECT_NAME);
            javaProject = findJavaProject(PROJECT_NAME);
        } catch (CoreException e) {
            fail("cannot create java project due to: " + e.getMessage() + " / " + e);
        }
    }
    return javaProject;
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

IJavaProject (org.eclipse.jdt.core.IJavaProject)743 IProject (org.eclipse.core.resources.IProject)178 IFile (org.eclipse.core.resources.IFile)149 Test (org.junit.Test)146 CoreException (org.eclipse.core.runtime.CoreException)127 JavaModelException (org.eclipse.jdt.core.JavaModelException)124 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)123 IPath (org.eclipse.core.runtime.IPath)110 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)103 ArrayList (java.util.ArrayList)87 IFolder (org.eclipse.core.resources.IFolder)78 IResource (org.eclipse.core.resources.IResource)75 IJavaElement (org.eclipse.jdt.core.IJavaElement)63 IType (org.eclipse.jdt.core.IType)63 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)62 Path (org.eclipse.core.runtime.Path)57 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)56 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)47 StringInputStream (org.eclipse.xtext.util.StringInputStream)39 HashMap (java.util.HashMap)38