Java Code Examples for org.eclipse.xtext.ui.XtextProjectHelper#hasNature()

The following examples show how to use org.eclipse.xtext.ui.XtextProjectHelper#hasNature() . 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: ProjectOpenedOrClosedListener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void resourceChanged(final IResourceChangeEvent event) {
	if (workspace != null && workspace.isAutoBuilding()) {
		if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
			try {
				final Set<IProject> toUpdate = findNewProjectsToBuild(event);
				scheduleBuildIfNecessary(toUpdate);
			} catch (CoreException e) {
				log.error(e.getMessage(), e);
			}
		} else if ((event.getType() == IResourceChangeEvent.PRE_CLOSE || event.getType() == IResourceChangeEvent.PRE_DELETE)) {
			if (event.getResource() instanceof IProject && (XtextProjectHelper.hasNature((IProject) event.getResource())
					|| event.getResource().isAccessible() && event.getResource().isHidden())) {
				scheduleRemoveProjectJob((IProject) event.getResource());
			}
		}
	}
}
 
Example 2
Source File: ProjectOpenedOrClosedListener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.17
 */
protected boolean visitResourceDelta(IResourceDelta delta, final Set<IProject> accumulator) {
	if (delta.getResource() instanceof IWorkspaceRoot)
		return true;
	if (delta.getResource() instanceof IProject) {
		IProject project = (IProject) delta.getResource();
		if ((delta.getKind() & IResourceDelta.CHANGED) != 0 && project.isOpen()) {
			if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
				accumulator.add(project);
			}
			if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
				if ((delta.findMember(new Path(".project")) != null) && XtextProjectHelper.hasNature(project)
						&& XtextProjectHelper.hasBuilder(project))
					accumulator.add(project);
				else if (!XtextProjectHelper.hasNature(project)) {
					scheduleRemoveProjectJobIfNecessary(project, delta);
				}
			}
		}
	}
	return false;
}
 
Example 3
Source File: QueuedBuildData.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public void queueURI(URI uri) {
	Iterable<Pair<IStorage, IProject>> iterable = mapper.getStorages(uri);
	boolean associatedWithProject = false;
	for (Pair<IStorage, IProject> pair : iterable) {
		IProject project = pair.getSecond();
		if (XtextProjectHelper.hasNature(project) && XtextProjectHelper.hasBuilder(project)) {
			String projectName = project.getName();
			LinkedHashSetQueue<URI> list = projectNameToChangedResource.get(projectName);
			if (list == null) {
				list = new LinkedHashSetQueue<>();
				projectNameToChangedResource.put(projectName, list);
			}
			list.add(uri);
			associatedWithProject = true;
		}
	}
	if (!associatedWithProject) {
		this.uris.add(uri);
	}
}
 
Example 4
Source File: JdtToBeBuiltComputer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected boolean isBuiltByUpstream(IPackageFragmentRoot root, IProject project, IProject[] projectsInCorrectBuildOrder) {
	for (IProject p : projectsInCorrectBuildOrder) {
		if (p.equals(project))
			return false;
		if (XtextProjectHelper.hasNature(p) && XtextProjectHelper.hasBuilder(p)) {
			IJavaProject javaProject = JavaCore.create(p);
			if (javaProject.exists()) {
				if (javaProject.isOnClasspath(root)) {
					if (log.isTraceEnabled())
						log.trace("Build of project '"+project.getName()+"' skips indexing classpath entry '"+root.getPath()+"' because it already indexed by "+javaProject.getElementName());
					return true;
				}
			}
		}
	}
	return false;
}
 
Example 5
Source File: XtextBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.19
 */
protected void pollQueuedBuildData() {
	boolean needRebuild = false;
	if (pollQueuedBuildData(getProject())) {
		needRebuild = true;
	}
	for(IProject project: interestingProjects) {
		if (!XtextProjectHelper.hasNature(project)) {
			if (pollQueuedBuildData(project)) {
				needRebuild = true;
			}	
		}
	}
	if(needRebuild) {
		needRebuild();
	}
}
 
Example 6
Source File: N4JSEclipseProject.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected boolean checkExists() {
	if (XtextProjectHelper.hasNature(project)) {
		return project.getFile(IN4JSProject.PACKAGE_JSON).exists();
	}
	return false;
}
 
Example 7
Source File: ProjectStateChangeListener.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private boolean collectAffectedProjects(IResourceDelta delta, Set<IProject> accumulator) {
	IResource resource = delta.getResource();
	if (resource instanceof IProject && "RemoteSystemsTempFiles".equals(resource.getName())) {
		return false;
	}
	if (resource instanceof IWorkspaceRoot)
		return true;
	if (resource instanceof IProject) {
		IProject project = (IProject) resource;
		if ("RemoteSystemsTempFiles".equals(resource.getName())) {
			return false;
		}
		if ((delta.getKind() & IResourceDelta.CHANGED) != 0 && project.isOpen()) {
			if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
				accumulator.add(project);
			}
			if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
				if ((delta.findMember(new Path(".project")) != null) && XtextProjectHelper.hasNature(project)
						&& XtextProjectHelper.hasBuilder(project)) {
					accumulator.add(project);
				}
			}
		}
		return true;
	}
	if (resource instanceof IFolder) {
		if (N4JSGlobals.NODE_MODULES.equals(resource.getName())) {
			accumulator.add(resource.getProject());
		} else if ((delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.REMOVED)
				&& isSourceContainerModification(resource)) {
			accumulator.add(resource.getProject());
		}
	}
	return false;
}
 
Example 8
Source File: StatechartDiagramEditor.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void checkXtextNature() {
	IFileEditorInput editorInput = (IFileEditorInput) getEditorInput();
	if ((editorInput == null) || (editorInput.getFile() == null)) {
		return;
	}
	IProject project = editorInput.getFile().getProject();
	if ((project != null) && !XtextProjectHelper.hasNature(project) && project.isAccessible()
			&& !project.isHidden()) {
		addNature(project);
	}
}
 
Example 9
Source File: AbstractProjectsStateHelper.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isAccessibleXtextProject(IProject p) {
	return p != null && XtextProjectHelper.hasNature(p) && XtextProjectHelper.hasBuilder(p);
}
 
Example 10
Source File: ToggleXtextNatureAction.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public boolean hasNature(IProject project) {
	return XtextProjectHelper.hasNature(project);
}
 
Example 11
Source File: ToggleXtextNatureCommand.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public boolean hasNature(IProject project) {
	return XtextProjectHelper.hasNature(project);
}
 
Example 12
Source File: DebugSourceInstallingCompilationParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean isActive(IJavaProject project) {
	return XtextProjectHelper.hasNature(project.getProject());
}
 
Example 13
Source File: BuildScheduler.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean isBuildable(IProject project) {
	return XtextProjectHelper.hasNature(project) && XtextProjectHelper.hasBuilder(project);
}
 
Example 14
Source File: DerivedResourceCleanerJob.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
protected boolean shouldBeProcessed(IProject project) {
	return XtextProjectHelper.hasNature(project) && XtextProjectHelper.hasBuilder(project) && (folderNameToClean == null || project.getFolder(folderNameToClean).exists());
}
 
Example 15
Source File: N4JSEclipseModel.java    From n4js with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Low-level method for deciding whether a given project residing in the Eclipse workspace is to be treated as an
 * "N4JS project", i.e. whether N4JS-related implementations should take not of this project or simply ignore it
 * entirely. For example, this affects whether methods such as {@link IN4JSCore#findAllProjects()} will return this
 * project or not.
 * <p>
 * In particular, this method requires that the given project is properly configured as an Xtext project.
 * <p>
 * This method is not intended to be used with projects residing in the {@link ExternalLibraryWorkspace}, which are
 * by definition always relevant to N4JS.
 */
private boolean isRelevantToN4JS(IProject project) {
	return project != null
			&& project.isAccessible() // includes #isOpen() as a requirement
			&& XtextProjectHelper.hasNature(project)
			&& XtextProjectHelper.hasBuilder(project);
}