<commit_before>/*******************************************************************************
 * Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.resource

import com.google.inject.Inject
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtext.service.OperationCanceledError
import org.eclipse.xtext.service.OperationCanceledManager
import org.eclipse.xtext.util.CancelIndicator
import org.eclipse.xtext.util.concurrent.IUnitOfWork
import org.eclipse.xtext.util.concurrent.CancelableUnitOfWork
import org.eclipse.emf.ecore.resource.Resource

/**
 * @author <NAME> - Initial contribution and API
 * 
 * @since 2.8
 */
class OutdatedStateManager {
	
	@Inject OperationCanceledManager canceledManager
	
	val cancelationAllowed = new ThreadLocal<Boolean>{
		override initialValue() {
			true
		}
	}
	
	/**
	 * Created a fresh CancelIndicator
	 */
	def CancelIndicator newCancelIndiciator(ResourceSet rs) {
		if (rs instanceof XtextResourceSet) {
			val cancelationAllowed = this.cancelationAllowed.get 
			val current = rs.modificationStamp
			return [ 
				cancelationAllowed && (rs.isOutdated || current != rs.modificationStamp)
			]
		} else {
			CancelIndicator.NullImpl
		}
	}
	
	/**
	 * Checks whether the given ResourceSet is in an outdated state and
	 * throws an {@link OperationCanceledError} if so.
	 */ 
	def void checkCanceled(ResourceSet rs) {<commit_msg>[xtext][tests] Fixed regression in Quickfix test<commit_after>/*******************************************************************************
 * Copyright (c) 2014 itemis AG (http://www.itemis.eu) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package org.eclipse.xtext.resource

import com.google.inject.Inject
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtext.service.OperationCanceledError
import org.eclipse.xtext.service.OperationCanceledManager
import org.eclipse.xtext.util.CancelIndicator
import org.eclipse.xtext.util.concurrent.IUnitOfWork
import org.eclipse.xtext.util.concurrent.CancelableUnitOfWork
import org.eclipse.emf.ecore.resource.Resource

/**
 * @author <NAME> - Initial contribution and API
 * 
 * @since 2.8
 */
class OutdatedStateManager {
	
	@Inject OperationCanceledManager canceledManager
	
	val cancelationAllowed = new ThreadLocal<Boolean>{
		override initialValue() {
			true
		}
	}
	
	/**
	 * Created a fresh CancelIndicator
	 */
	def CancelIndicator newCancelIndiciator(ResourceSet rs) {
		if (rs instanceof XtextResourceSet) {
			val boolean cancelationAllowed = this.cancelationAllowed.get 
			val current = rs.modificationStamp
			return [ 
				cancelationAllowed && (rs.isOutdated || current != rs.modificationStamp)
			]
		} else {
			CancelIndicator.NullImpl
		}
	}
	
	/**
	 * Checks whether the given ResourceSet is in an outdated state and
	 * throws an {@link OperationCanceledError} if so.
	 */ 
	def void checkCanceled(ResourceSet rs) {
{'fraction_non_alphanumeric': 0.17056009006473402, 'fraction_numerical': 0.005629045876723895, 'mean_word_length': 4.778861788617887, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6747476', 'n_tokens_mistral': 1041, 'n_tokens_neox': 963, 'n_words': 252}