<commit_before>//
//  ViewInspector.swift
//  TestViewHierarchy
//
//  Created by <NAME> on 11/21/14.
//  Copyright (c) 2014 Rocketmade. All rights reserved.
//

import Foundation
import UIKit

class ViewInspector {
    private var removedViews: [UIView] = []

    init(rootView: UIView) {
        self.recurseThroughSubviews(rootView);
    }

    func recurseThroughSubviews(rootView: UIView) {
        self.addDeleteBlock(rootView)
        rootView.layer.borderWidth = 2.0
        rootView.layer.borderColor = UIColor.redColor().CGColor

        for subview in rootView.subviews {
            self.recurseThroughSubviews(subview as UIView)
        }
    }

    func addDeleteBlock(view: UIView) {
        let tapGesture = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
        view.addGestureRecognizer(tapGesture)
    }

    @objc func handleTap(tapGesture: UITapGestureRecognizer) {
        let view = tapGesture.view!
        if (view.allSubviewsInvisble()) {
            self.removedViews.append(view)
            view.hidden = true
        }
    }

    @objc func undo() {
        if (removedViews.count > 0) {
            let last = removedViews.removeLast()
            last.hidden = false
        }
    }
    
}<commit_msg>Small improvements to view inspector<commit_after>//
//  ViewInspector.swift
//  TestViewHierarchy
//
//  Created by <NAME> on 11/21/14.
//  Copyright (c) 2014 Rocketmade. All rights reserved.
//

import Foundation
import UIKit

class ViewInspector {
    private var removedViews: [UIView] = []

    init(rootView: UIView) {
        self.recurseThroughSubviews(rootView);
    }

    func recurseThroughSubviews(rootView: UIView) {
        self.addDeleteBlock(rootView)
        rootView.layer.borderWidth = 2.0
        rootView.layer.borderColor = UIColor.redColor().CGColor

        for subview in rootView.subviews {
            self.recurseThroughSubviews(subview as UIView)
        }
    }

    func addDeleteBlock(view: UIView) {
        let tapGesture = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
        view.addGestureRecognizer(tapGesture)
    }

    @objc func handleTap(tapGesture: UITapGestureRecognizer) {
        let view = tapGesture.view!
        if (view.allSubviewsInvisble()) {
            self.removedViews.append(view)
            view.hidden = true
        }
    }

    @objc func undo() {
        if (removedViews.count > 0) {
            let last = removedViews.removeLast()
            last.hidden = false
        }
    }

    func undoAll() {
        while (removedViews.count > 0) {
            undo()
        }
    }
    
}
{'fraction_non_alphanumeric': 0.10110224249334854, 'fraction_numerical': 0.010262257696693273, 'mean_word_length': 2.281795511221945, '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': '7463281', 'n_tokens_mistral': 883, 'n_tokens_neox': 813, 'n_words': 162}