org.eclipse.core.internal.resources.Project Java Examples
The following examples show how to use
org.eclipse.core.internal.resources.Project.
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: BuildManagerAccess.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
/** * Obtain the configured Xtext builder for the given project, if any. */ public static XtextBuilder findBuilder(IProject project) { try { if (project.isAccessible()) { Project casted = (Project) project; IBuildConfiguration activeBuildConfig = casted.getActiveBuildConfig(); for (ICommand command : casted.internalGetDescription().getBuildSpec(false)) { if (XtextBuilder.BUILDER_ID.equals(command.getBuilderName())) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (workspace instanceof Workspace) { BuildManager buildManager = ((Workspace) workspace).getBuildManager(); XtextBuilder result = (XtextBuilder) getBuilder.invoke(buildManager, activeBuildConfig, command, -1, new MultiStatus(Activator.PLUGIN_ID, 0, null, null)); return result; } } } } return null; } catch (IllegalAccessException | InvocationTargetException | CoreException e) { throw new RuntimeException(e); } }
Example #2
Source File: AddModuleHandlerTest.java From tlaplus with MIT License | 5 votes |
public void testCreateModuleStoreRelativePath() throws IOException, CoreException { // Need a per invocation temp directory to avoid writing to the same // .project file over and over again. final File tempDirectory = createTempDirectory(); // Create... final File specFile = new File(tempDirectory + File.separator + "TestSpecName.tla"); specFile.createNewFile(); final Spec spec = Spec.createNewSpec("TestSpecName", specFile.getAbsolutePath(), false, new NullProgressMonitor()); final AddModuleHandler addModuleHandler = new AddModuleHandler(); final File moduleFileRaw = new File(tempDirectory + File.separator + "TestModuleName.tla"); moduleFileRaw.createNewFile(); final IFile moduleFile = addModuleHandler.createModuleFile(spec, "TestModuleName", new Path(moduleFileRaw.getAbsolutePath())); // ...check assertNotNull(moduleFile); assertTrue(moduleFile.isAccessible()); assertTrue(moduleFile.isLinked()); // could use non-internal alternative // project.getWorkspace().loadProjectDescription(path) instead, but then // need to known path to .project file assertTrue(spec.getProject() instanceof Project); final Project project = (Project) spec.getProject(); final ProjectDescription description = project.internalGetDescription(); final ProjectDescription pd = (ProjectDescription) description; final HashMap<IPath, LinkDescription> links = pd.getLinks(); assertEquals(2, links.size()); // spec + module for (LinkDescription linkDescription : links.values()) { final URI uri = linkDescription.getLocationURI(); assertTrue(uri.toASCIIString().startsWith(ResourceHelper.PARENT_ONE_PROJECT_LOC)); } }