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

The following examples show how to use org.eclipse.xtext.ui.XtextProjectHelper#hasBuilder() . 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
/**
 * @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 2
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 3
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 4
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 5
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 6
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 7
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 8
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);
}