<commit_before>//
//  JLScope.swift
//  Chromatism
//
//  Created by <NAME> on 2014-07-14.
//  Copyright (c) 2014 anviking. All rights reserved.
//

import UIKit

public class JLScope: NSObject, Printable, Equatable {
    init() {
        super.init()
    }
    
    subscript(scopes: JLScope...) -> JLScope {
        self.subscopes = scopes
            return self
    }
    
    var attributedString: NSMutableAttributedString!
    var multiline = false
    var theme: JLColorTheme?

    var indexSet = NSMutableIndexSet()
    var subscopes = [JLScope]()
    
    func addSubscope(subscope: JLScope) {
        self.subscopes += subscope
    }
    
    func perform() {
        perform(NSIndexSet(indexesInRange: NSMakeRange(0, attributedString.length)))
    }
    
    func perform(indexSet: NSIndexSet) {

        // Create a copy of the indexSet and call perform to subscopes
        // The results of the subscope is removed from the indexSet copy before the next subscope is performed
        let indexSetCopy = indexSet.mutableCopy() as NSMutableIndexSet
        performSubscopes(attributedString, indexSet: indexSetCopy)
        self.indexSet = indexSet.mutableCopy() as NSMutableIndexSet
    }
    
    // Will change indexSet
    func performSubscopes(attributedString: NSMutableAttributedString, indexSet: NSMutableIndexSet) {
        
        for (index, scope) in enumerate(subscopes) {
            scope.theme = theme
            
            var oldSet = scope.indexSet
            scope.invalidateAttributesInIndexes(indexSet)
            scope.perform(indexSet)
            var newSet = scope.indexSet
            
            indexSet -= newSet
            if scope.multiline {
                indexSet += NSIndexSetDelta(oldSet, newSet).deletions
            }
        }
    }
    
    // MARK:
    
    func invalidateAttributesInIndexes(indexSet: NSIndexSet) {

    }
    
    func shiftIndexesAtLoaction(location: Int, by delta: Int) {
        indexSet.shiftIndexesStartingAtIndex(location, by: delta)
    }
    
    // MARK: Printable
    override public var description: String {
    return "JLScope"
    }
    
}
<commit_msg>Perform again logic<commit_after>//
//  JLScope.swift
//  Chromatism
//
//  Created by <NAME> on 2014-07-14.
//  Copyright (c) 2014 anviking. All rights reserved.
//

import UIKit

public class JLScope: NSObject, Printable, Equatable {
    init() {
        super.init()
    }
    
    subscript(scopes: JLScope...) -> JLScope {
        self.subscopes = scopes
            return self
    }
    
    var attributedString: NSMutableAttributedString!
    var multiline = false
    var theme: JLColorTheme?

    var indexSet = NSMutableIndexSet()
    var subscopes = [JLScope]()
    
    func addSubscope(subscope: JLScope) {
        self.subscopes += subscope
    }
    
    func perform() {
        perform(NSIndexSet(indexesInRange: NSMakeRange(0, attributedString.length)))
    }
    
    func perform(indexSet: NSIndexSet) {

        // Create a copy of the indexSet and call perform to subscopes
        // The results of the subscope is removed from the indexSet copy before the next subscope is performed
        let indexSetCopy = indexSet.mutableCopy() as NSMutableIndexSet
        performSubscopes(attributedString, indexSet: indexSetCopy)
        self.indexSet = indexSet.mutableCopy() as NSMutableIndexSet
    }
    
    // Will change indexSet
    func performSubscopes(attributedString: NSMutableAttributedString, indexSet: NSMutableIndexSet) {
        
        var deletions = NSMutableIndexSet()
        for (index, scope) in enumerate(subscopes) {
            scope.theme = theme
            
            var oldSet = scope.indexSet
            scope.invalidateAttributesInIndexes(indexSet)
            scope.perform(indexSet)
            var newSet = scope.indexSet
            
            indexSet -= newSet
            if scope.multiline {
                deletions += NSIndexSetDelta(oldSet, newSet).deletions
            }
        }
        if deletions.count > 0 {
            perform(deletions + indexSet)
        }
    }
    
    // MARK:
    
    func invalidateAttributesInIndexes(indexSet: NSIndexSet) {

    }
    
    func shiftIndexesAtLoaction(location: Int, by delta: Int) {
        indexSet.shiftIndexesStartingAtIndex(location, by: delta)
    }
    
    // MARK: Printable
    override public var description: String {
    return "JLScope"
    }
    
}

{'fraction_non_alphanumeric': 0.08070333633904418, 'fraction_numerical': 0.006086564472497746, 'mean_word_length': 2.1535181236673773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2472841', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1279, 'n_words': 314}