Skip to content

Instantly share code, notes, and snippets.

View ahoppen's full-sized avatar

Alex Hoppen ahoppen

View GitHub Profile
@ahoppen
ahoppen / gist:aa71c48bafd62472a446
Created February 27, 2015 10:38
Focus Xcode after test has been started
#!/bin/sh
# Add this script as an action to Xcode -> Behaviours -> Edit Behaviours... -> Testing starts
# to automatically jump back from the simulator to Xcode when unit test are started
sleep 3
osascript -e 'tell application "Xcode" to activate'
@ahoppen
ahoppen / Swift Incremental Syntax Parsing.md
Created May 3, 2018 15:40
Swift Incremental Syntax Parsing

Swift incremental syntax parsing

This proposal aims to add an incremental syntax parsing mode to the Swift compiler that takes a syntax tree of a pre-edit file, a post-edit file, and a diff between the pre-edit and the post-edit file as its input. It then generates the libSyntax tree of the modified file based on this information.

Motivation

In order to be able to use libSyntax for syntax colouring in IDEs, libSyntax needs to be able to rapidly regenerate the syntax tree based on minor edits. A complete reparse of the file is not acceptable. This proposal adds an incremental syntax parsing mode to the compiler that is able to rearrange on old syntax tree based on minor edits that have been performed on the source file.

The goal is that this incremental compilation is (nearly) in O(1) in terms of the size of the original source file so that the delay for regenerating syntax colouring after a single edit is independent of the file's size.