Java Code Examples for org.eclipse.core.runtime.SubMonitor#done()

The following examples show how to use org.eclipse.core.runtime.SubMonitor#done() . 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
@Override
public IStatus stage(IPath stagingDirectory, IPath safeWorkDirectory,
    MessageConsoleStream stdoutOutputStream, MessageConsoleStream stderrOutputStream,
    IProgressMonitor monitor) {
  SubMonitor subMonitor = SubMonitor.convert(monitor, 100);

  boolean result = stagingDirectory.toFile().mkdirs();
  if (!result) {
    return StatusUtil.error(this, "Could not create staging directory " + stagingDirectory);
  }

  try {
    IPath deployArtifact = getDeployArtifact(safeWorkDirectory, subMonitor.newChild(40));
    CloudSdkStagingHelper.stageFlexible(appEngineDirectory, deployArtifact, stagingDirectory,
        subMonitor.newChild(60));
    return Status.OK_STATUS;
  } catch (AppEngineException | CoreException ex) {
    return StatusUtil.error(this, Messages.getString("deploy.job.staging.failed"), ex);
  } finally {
    subMonitor.done();
  }
}
 
Example 2
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, projectFactories.size());
	try {
		IWorkbench workbench = PlatformUI.getWorkbench();
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		for (ProjectFactory projectFactory : projectFactories) {
			projectFactory.setWorkbench(workbench);
			projectFactory.setWorkspace(workspace);
			projectFactory.createProject(subMonitor, null);
			subMonitor.worked(1);
		}
	} finally {
		subMonitor.done();
	}
}
 
Example 3
Source Project: sarl   File: ImportMavenSarlProjectsJob.java    License: Apache License 2.0 6 votes vote down vote up
/** Create the operation for creating the projects.
 *
 * @return the operation.
 */
protected AbstractCreateMavenProjectsOperation createOperation() {
	return new AbstractCreateMavenProjectsOperation() {
		@SuppressWarnings("synthetic-access")
		@Override
		protected List<IProject> doCreateMavenProjects(IProgressMonitor progressMonitor) throws CoreException {
			final SubMonitor monitor = SubMonitor.convert(progressMonitor, 101);
			try {
				final List<IMavenProjectImportResult> results = MavenImportUtils.runFixedImportJob(
						true,
						getProjects(),
						getImportConfiguration(),
						new MavenProjectWorkspaceAssigner(getWorkingSets()),
						monitor.newChild(100));
				return toProjects(results);
			} finally {
				restorePom();
				monitor.done();
			}
		}
	};
}
 
Example 4
Source Project: sarl   File: NewSarlEventWizardPage.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("all")
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 3);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlEventBuilder event = scriptBuilder.addSarlEvent(getTypeName());
	event.setExtends(getSuperClass());
	event.setDocumentation(comment);
	mon.worked(1);
	if (event.getSarlEvent().getExtends() != null) {
		createInheritedMembers(
				Event.class.getCanonicalName(),
				event.getSarlEvent(),
				false,
				() -> event.addSarlConstructor(),
				null,
				getSuperClass());
	}
	mon.worked(2);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example 5
private void buildEnding(List<IBuildParticipant> participants, IProgressMonitor monitor)
{
	if (participants == null)
	{
		return;
	}
	SubMonitor sub = SubMonitor.convert(monitor, participants.size());
	for (IBuildParticipant participant : participants)
	{
		participant.buildEnding(sub.newChild(1));
	}
	sub.done();
}
 
Example 6
/**
 * Call this method after the {@link ExternalLibraryWorkspace#updateState()} adapted the changes of the
 * {@code node_modules} folder. Due to this adaption, new folders are already represented as external projects and
 * can be build and added to the index.
 */
private void buildChangesIndex(IProgressMonitor monitor, Collection<LibraryChange> changeSet,
		RegisterResult cleanResults) {

	SubMonitor subMonitor = convert(monitor, 10);
	try {

		Set<FileURI> toBeUpdated = getToBeBuildProjects(changeSet);
		for (FileURI cleanedPrjLoc : cleanResults.externalProjectsDone) {
			ExternalProject project = externalLibraryWorkspace.getProject(cleanedPrjLoc);
			if (project != null) {
				toBeUpdated.add(cleanedPrjLoc);
			}
		}

		subMonitor.setTaskName("Building new projects...");
		RegisterResult buildResult = externalLibraryWorkspace.registerProjects(subMonitor.split(9), toBeUpdated);
		printRegisterResults(buildResult, "built");

		Set<SafeURI<?>> toBeScheduled = new HashSet<>();
		toBeScheduled.addAll(cleanResults.affectedWorkspaceProjects);
		toBeScheduled.addAll(buildResult.affectedWorkspaceProjects);
		externalLibraryWorkspace.scheduleWorkspaceProjects(subMonitor.split(1), toBeScheduled);

	} finally {
		subMonitor.done();
	}
}
 
Example 7
Source Project: sarl   File: SARLProjectConfigurator.java    License: Apache License 2.0 5 votes vote down vote up
/** Add the natures to the given project.
 *
 * @param project the project.
 * @param monitor the monitor.
 * @param natureIdentifiers the identifiers of the natures to add to the project.
 * @return the status if the operation.
 * @since 0.8
 */
public static IStatus addNatures(IProject project, IProgressMonitor monitor, String... natureIdentifiers) {
	if (project != null && natureIdentifiers != null && natureIdentifiers.length > 0) {
		try {
			final SubMonitor subMonitor = SubMonitor.convert(monitor, natureIdentifiers.length + 2);
			final IProjectDescription description = project.getDescription();
			final List<String> natures = new LinkedList<>(Arrays.asList(description.getNatureIds()));

			for (final String natureIdentifier : natureIdentifiers) {
				if (!Strings.isNullOrEmpty(natureIdentifier) && !natures.contains(natureIdentifier)) {
					natures.add(0, natureIdentifier);
				}
				subMonitor.worked(1);
			}

			final String[] newNatures = natures.toArray(new String[natures.size()]);
			final IStatus status = ResourcesPlugin.getWorkspace().validateNatureSet(newNatures);
			subMonitor.worked(1);

			// check the status and decide what to do
			if (status.getCode() == IStatus.OK) {
				description.setNatureIds(newNatures);
				project.setDescription(description, subMonitor.newChild(1));
			}
			subMonitor.done();
			return status;
		} catch (CoreException exception) {
			return SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, exception);
		}
	}
	return SARLEclipsePlugin.getDefault().createOkStatus();
}
 
Example 8
Source Project: sarl   File: NewSarlAgentWizardPage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 4);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlAgentBuilder agent = scriptBuilder.addSarlAgent(getTypeName());
	agent.setExtends(getSuperClass());
	agent.setDocumentation(comment);
	mon.worked(1);
	createStandardSARLEventTemplates(Messages.NewSarlAgentWizardPage_3,
		name -> agent.addSarlBehaviorUnit(name),
		name -> agent.addSarlCapacityUses(name));
	mon.worked(2);
	if (agent.getSarlAgent().getExtends() != null) {
		createInheritedMembers(
			Agent.class.getCanonicalName(),
			agent.getSarlAgent(),
			true,
			() -> agent.addSarlConstructor(),
			name -> agent.addOverrideSarlAction(name),
			getSuperClass());
	}
	mon.worked(3);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example 9
@Override
protected void execute(IProgressMonitor monitor) throws CoreException,
		InvocationTargetException, InterruptedException {
	SubMonitor sm = SubMonitor.convert(monitor);
	sm.setWorkRemaining(delegates.size()*10);
	for (AbstractNativeBinaryBuildDelegate delegate : delegates) {
		if(monitor.isCanceled()){ 
			break; 
		}
		delegate.setRelease(true);
		delegate.buildNow(sm.newChild(10));
		try {
			File buildArtifact = delegate.getBuildArtifact();
			File destinationFile = new File(destinationDir, buildArtifact.getName());
			if(destinationFile.exists()){
				String callback = overwriteQuery.queryOverwrite(destinationFile.toString());
				if(IOverwriteQuery.NO.equals(callback)){
					continue;
				}
				if(IOverwriteQuery.CANCEL.equals(callback)){
					break;
				}
			}
			File artifact = delegate.getBuildArtifact();
			if(artifact.isDirectory()){
				FileUtils.copyDirectoryToDirectory(artifact, destinationDir);
			}else{
				FileUtils.copyFileToDirectory(artifact, destinationDir);
			}
			sm.done();
		} catch (IOException e) {
			HybridCore.log(IStatus.ERROR, "Error on NativeBinaryExportOperation", e);
		}
	}
	monitor.done(); 
}
 
Example 10
/**
 * Overridden in order to change BundleVendor. {@inheritDoc}
 */
@SuppressWarnings("PMD.InsufficientStringBufferDeclaration")
@Override
protected void createManifest(final IProject project, final IProgressMonitor progressMonitor) throws CoreException {
  final StringBuilder content = new StringBuilder("Manifest-Version: 1.0\n");
  content.append("Bundle-ManifestVersion: 2\n");
  content.append("Bundle-Name: " + projectName + "\n");
  content.append("Bundle-Vendor: %Bundle-Vendor\n");
  content.append("Bundle-Version: 1.0.0.qualifier\n");
  content.append("Bundle-SymbolicName: " + projectName + ";singleton:=true\n");
  if (null != activatorClassName) {
    content.append("Bundle-Activator: " + activatorClassName + "\n");
  }
  content.append("Bundle-ActivationPolicy: lazy\n");

  addToContent(content, requiredBundles, "Require-Bundle");
  addToContent(content, exportedPackages, "Export-Package");
  addToContent(content, importedPackages, "Import-Package");

  content.append("Bundle-RequiredExecutionEnvironment: JavaSE-1.7\n");

  final IFolder metaInf = project.getFolder("META-INF");
  SubMonitor subMonitor = SubMonitor.convert(progressMonitor, 2);
  try {
    if (metaInf.exists()) {
      metaInf.delete(false, progressMonitor);
    }
    metaInf.create(false, true, subMonitor.newChild(1));
    createFile("MANIFEST.MF", metaInf, content.toString(), subMonitor.newChild(1));
  } finally {
    subMonitor.done();
  }
}
 
Example 11
public Change createChange(String name, ResourceRelocationContext.ChangeType type, IProgressMonitor pm)
		throws CoreException, OperationCanceledException {
	if (uriChanges.isEmpty()) {
		return null;
	}

	SubMonitor subMonitor = SubMonitor.convert(pm);
	// Declaring the task and its effort in 'SubMonitor.convert(...)' doesn't yield the expected UI updates
	// so let's do it separately; the total effort of '5' is chosen for weighting the subsequent efforts
	subMonitor.beginTask("Preparing the refactoring...", 5);

	IChangeSerializer changeSerializer = changeSerializerProvider.get();
	ResourceSet resourceSet = resourceSetProvider.get(project);

	ResourceRelocationContext context = new ResourceRelocationContext(type, uriChanges, issues, changeSerializer, resourceSet);
	boolean persistedIndexUsageRequested = isPersistedIndexUsageRequested(context);

	// TODO check preconditions like all editors being saved if 'persistedIndexUsageRequested' == true

	initializeResourceSet(persistedIndexUsageRequested, context);
	executeParticipants(context, subMonitor.split(1));

	ChangeConverter changeConverter = changeConverterFactory.create(name, //
			(it) -> {
				return (!(it instanceof MoveResourceChange || it instanceof RenameResourceChange)
						|| !excludedResources.contains(it.getModifiedElement()));
			}, issues);

	SubMonitor modificationApplicationMonitor = subMonitor.split(4); // remaining effort is assigned to 'changeSerializer's work
	changeSerializer.setProgressMonitor(modificationApplicationMonitor);
	changeSerializer.applyModifications(changeConverter);
	modificationApplicationMonitor.done();
	return changeConverter.getChange();
}
 
Example 12
@Override
protected void generateTypeContent(ISourceAppender appender, IJvmTypeProvider typeProvider,
		String comment, IProgressMonitor monitor) throws Exception {
	final SubMonitor mon = SubMonitor.convert(monitor, 2);
	final ScriptSourceAppender scriptBuilder = this.codeBuilderFactory.buildScript(
			getPackageFragment().getElementName(), typeProvider);
	final ISarlEnumerationBuilder annotation = scriptBuilder.addSarlEnumeration(getTypeName());
	annotation.setDocumentation(comment);
	mon.worked(1);
	scriptBuilder.build(appender);
	mon.done();
}
 
Example 13
private Collection<IProblem> processComments(BuildContext context, IParseRootNode rootNode, IProgressMonitor monitor)
{
	IParseNode[] comments = rootNode.getCommentNodes();
	if (ArrayUtil.isEmpty(comments))
	{
		return Collections.emptyList();
	}

	SubMonitor sub = SubMonitor.convert(monitor, comments.length);
	Collection<IProblem> tasks = new ArrayList<IProblem>(comments.length);
	try
	{
		String source = context.getContents();
		String filePath = context.getURI().toString();
		for (IParseNode commentNode : comments)
		{
			if (commentNode instanceof HTMLCommentNode)
			{
				tasks.addAll(processCommentNode(filePath, source, 0, commentNode, COMMENT_ENDING));
			}
			sub.worked(1);
		}
	}
	finally
	{
		sub.done();
	}
	return tasks;
}
 
Example 14
public void search(URI uri, IProgressMonitor monitor) {
	int numResources = Iterables.size(resourceDescriptions.getAllResourceDescriptions());
	SubMonitor subMonitor = SubMonitor.convert(monitor, numResources / 10);
	subMonitor.subTask("Find references in EMF resources");
	try {
		int i = 0;
		for (IResourceDescription resourceDescription : resourceDescriptions.getAllResourceDescriptions()) {
			URI resourceURI = resourceDescription.getURI();
			IResourceServiceProvider resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(resourceURI);
			if(resourceServiceProvider != null) {
				IJavaSearchParticipation javaSearchParticipation = resourceServiceProvider
						.get(IJavaSearchParticipation.class);
				if(javaSearchParticipation == null || javaSearchParticipation.canContainJvmReferences(resourceURI))
					searchIn(uri, resourceDescription);
			}
			if (++i % 10 == 0) {
				if (subMonitor.isCanceled()) {
					return; // not throwing OperationCanceledException, as the client in JDT doesn't seem to handle it properly
				}
				subMonitor.worked(1);
			}
		}
		for(ResourceSet resourceSet: projectToResourceSet.values()) {
			resourceSet.getResources().clear();
			resourceSet.eAdapters().clear();
		}
	} finally {
		subMonitor.done();
	}
}
 
Example 15
@Override
public void initializeProjects(final Collection<IPath> rootPaths, IProgressMonitor monitor) throws CoreException, OperationCanceledException {
	SubMonitor subMonitor = SubMonitor.convert(monitor, 100);
	cleanInvalidProjects(rootPaths, subMonitor.split(20));
	createJavaProject(getDefaultProject(), subMonitor.split(10));
	cleanupResources(getDefaultProject());
	importProjects(rootPaths, subMonitor.split(70));
	subMonitor.done();
}
 
Example 16
@Override
public void importToWorkspace(IProgressMonitor monitor) throws CoreException {
	if (!applies(monitor)) {
		return;
	}
	SubMonitor subMonitor = SubMonitor.convert(monitor, directories.size());
	JavaLanguageServerPlugin.logInfo("Importing Eclipse project(s)");
	directories.forEach(d -> importDir(d, subMonitor.newChild(1)));
	subMonitor.done();
}
 
Example 17
private static RefactorWorkspaceEdit moveCU(String[] sourceUris, String targetUri, boolean updateReferences, IProgressMonitor monitor) {
	URI targetURI = JDTUtils.toURI(targetUri);
	if (targetURI == null) {
		return new RefactorWorkspaceEdit("Failed to move the files because of illegal uri '" + targetUri + "'.");
	}

	List<IJavaElement> elements = new ArrayList<>();
	for (String uri : sourceUris) {
		ICompilationUnit unit = JDTUtils.resolveCompilationUnit(uri);
		if (unit == null) {
			continue;
		}

		elements.add(unit);
	}

	SubMonitor submonitor = SubMonitor.convert(monitor, "Moving File...", 100);
	try {
		IResource[] resources = ReorgUtils.getResources(elements);
		IJavaElement[] javaElements = ReorgUtils.getJavaElements(elements);
		IContainer[] targetContainers = ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(targetURI);
		if (targetContainers == null || targetContainers.length == 0) {
			return new RefactorWorkspaceEdit("Failed to move the files because cannot find the target folder '" + targetUri + "' in the workspace.");
		} else if ((resources == null || resources.length == 0) && (javaElements == null || javaElements.length == 0)) {
			return new RefactorWorkspaceEdit("Failed to move the files because cannot find any resources or Java elements associated with the files.");
		}

		// For multi-module scenario, findContainersForLocationURI API may return a container array, need put the result from the nearest project in front.
		Arrays.sort(targetContainers, (Comparator<IContainer>) (IContainer a, IContainer b) -> {
			return a.getFullPath().toPortableString().length() - b.getFullPath().toPortableString().length();
		});
		IJavaElement targetElement = null;
		for (IContainer container : targetContainers) {
			targetElement = JavaCore.create(container);
			if (targetElement instanceof IPackageFragmentRoot) {
				targetElement = ((IPackageFragmentRoot) targetElement).getPackageFragment("");
			}

			if (targetElement != null) {
				break;
			}
		}

		if (targetElement == null) {
			JavaLanguageServerPlugin.logError("Failed to move the files because cannot find the package associated with the path '" + targetUri + "'.");
			return new RefactorWorkspaceEdit("Failed to move the files because cannot find the package associated with the path '" + targetUri + "'.");
		}

		IReorgDestination packageDestination = ReorgDestinationFactory.createDestination(targetElement);
		WorkspaceEdit edit = move(resources, javaElements, packageDestination, updateReferences, submonitor);
		if (edit == null) {
			return new RefactorWorkspaceEdit("Cannot enable move operation.");
		}

		return new RefactorWorkspaceEdit(edit);
	} catch (CoreException e) {
		JavaLanguageServerPlugin.logException("Failed to move the files.", e);
		return new RefactorWorkspaceEdit("Failed to move the files because of " + e.toString());
	} finally {
		submonitor.done();
	}
}
 
Example 18
@Override
public IStatus run(IProgressMonitor monitor)
{
	SubMonitor sub = SubMonitor.convert(monitor, files.size());
	if (sub.isCanceled())
	{
		return Status.CANCEL_STATUS;
	}
	if (!project.isAccessible() || getContainerURI() == null)
	{
		return Status.CANCEL_STATUS;
	}

	Index index = getIndex();
	if (index == null)
	{
		IdeLog.logError(IndexPlugin.getDefault(),
				MessageFormat.format("Index is null for container: {0}", getContainerURI())); //$NON-NLS-1$
		return Status.CANCEL_STATUS;
	}
	try
	{
		// Cleanup indices for files
		for (IFile file : files)
		{
			if (monitor.isCanceled())
			{
				return Status.CANCEL_STATUS;
			}
			index.remove(file.getLocationURI());
			sub.worked(1);
		}
	}
	finally
	{
		try
		{
			index.save();
		}
		catch (IOException e)
		{
			IdeLog.logError(IndexPlugin.getDefault(), e);
		}
		sub.done();
	}
	return Status.OK_STATUS;
}
 
Example 19
Source Project: sarl   File: SARLProjectConfigurator.java    License: Apache License 2.0 4 votes vote down vote up
/** Configure the SARL project.
 *
 * <p>This function does the following:<ul>
 * <li>Add the SARL nature to the project;</li>
 * <li>Create the standard SARL folders if {@code createFolders} is evaluated to true;</li>
 * <li>Set the output configuration of the project from the
 * {@link SARLPreferences#setSpecificSARLConfigurationFor(IProject, IPath) general SARL configuration};</li>
 * <li>Reset the Java configuration in order to follow the SARL configuration, if {@code configureJabvaNature}
 * is evaluated to true.</li>
 * </ul>
 *
 * @param project the project.
 * @param addNatures indicates if the natures must be added to the project by calling {@link #addSarlNatures(IProject, IProgressMonitor)}.
 * @param configureJavaNature indicates if the Java configuration elements must be configured.
 * @param createFolders indicates if the folders must be created or not.
 * @param monitor the monitor.
 * @see #addSarlNatures(IProject, IProgressMonitor)
 * @see #configureSARLSourceFolders(IProject, boolean, IProgressMonitor)
 */
public static void configureSARLProject(IProject project, boolean addNatures,
		boolean configureJavaNature, boolean createFolders, IProgressMonitor monitor) {
	try {
		final SubMonitor subMonitor = SubMonitor.convert(monitor, 11);
		// Add Natures
		final IStatus status = Status.OK_STATUS;
		if (addNatures) {
			addSarlNatures(project, subMonitor.newChild(1));
			if (status != null && !status.isOK()) {
				SARLEclipsePlugin.getDefault().getLog().log(status);
			}
		}

		// Ensure SARL specific folders.
		final OutParameter<IFolder[]> sourceFolders = new OutParameter<>();
		final OutParameter<IFolder[]> testSourceFolders = new OutParameter<>();
		final OutParameter<IFolder[]> generationFolders = new OutParameter<>();
		final OutParameter<IFolder[]> testGenerationFolders = new OutParameter<>();
		final OutParameter<IFolder> generationFolder = new OutParameter<>();
		final OutParameter<IFolder> testGenerationFolder = new OutParameter<>();
		final OutParameter<IFolder> outputFolder = new OutParameter<>();
		final OutParameter<IFolder> testOutputFolder = new OutParameter<>();
		ensureSourceFolders(project, createFolders, subMonitor,
				sourceFolders, testSourceFolders,
				generationFolders, testGenerationFolders,
				generationFolder, testGenerationFolder,
				outputFolder, testOutputFolder);

		// SARL specific configuration
		final IFolder testGenerationFolderFolder = testGenerationFolder.get();
		final IPath testGenerationFolderPath = testGenerationFolderFolder == null ? null
				: testGenerationFolderFolder.getProjectRelativePath();
		SARLPreferences.setSpecificSARLConfigurationFor(project,
				generationFolder.get().getProjectRelativePath(),
				testGenerationFolderPath);
		subMonitor.worked(1);

		// Create the Java project
		if (configureJavaNature) {

			if (!addNatures) {
				addNatures(project, subMonitor.newChild(1), JavaCore.NATURE_ID);
			}

			final IJavaProject javaProject = JavaCore.create(project);
			subMonitor.worked(1);

			// Build path
			BuildPathsBlock.flush(
					buildClassPathEntries(javaProject,
							sourceFolders.get(),
							testSourceFolders.get(),
							generationFolders.get(),
							testGenerationFolders.get(),
							testOutputFolder.get().getFullPath(),
							false, true),
					outputFolder.get().getFullPath(), javaProject, null, subMonitor.newChild(1));
		}
		subMonitor.done();
	} catch (CoreException exception) {
		SARLEclipsePlugin.getDefault().log(exception);
	}
}
 
Example 20
public Map<ProjectionAnnotation, Position> emitFoldingRegions(boolean initialReconcile, IProgressMonitor monitor,
		IParseRootNode parseNode) throws BadLocationException
{
	this.initialReconcile = initialReconcile;
	fLines = new ArrayList<Integer>();
	int lineCount = getDocument().getNumberOfLines();
	if (lineCount <= 1) // Quick hack fix for minified files. We need at least two lines to have folding!
	{
		return Collections.emptyMap();
	}
	SubMonitor sub = null;
	try
	{
		if (parseNode == null)
		{
			return Collections.emptyMap();
		}
		int length = parseNode.getChildCount();
		if (parseNode instanceof IParseRootNode)
		{
			IParseRootNode prn = (IParseRootNode) parseNode;
			IParseNode[] comments = prn.getCommentNodes();
			if (comments != null && comments.length > 0)
			{
				length += comments.length;
			}
		}
		sub = SubMonitor.convert(monitor, Messages.CommonReconcilingStrategy_FoldingTaskName, length);
		SubMonitor subMonitor = sub.newChild(length);
		Map<ProjectionAnnotation, Position> positions = getPositions(subMonitor, parseNode);
		// In case the getPositions call canceled the monitor, we cancel the 'parent' monitor as well.
		// This will cause the system to skip a foldings update (see CommonReconcilingStrategy#calculatePositions).
		if (subMonitor.isCanceled())
		{
			monitor.setCanceled(true);
		}
		return positions;
	}
	finally
	{
		fLines = null;
		if (sub != null)
		{
			sub.done();
		}
	}
}