##// END OF EJS Templates
vcs: Minimal change to expose the shadow repository...
vcs: Minimal change to expose the shadow repository Based on my original research, this was the "minimal" starting point. It shows that three concepts are needed for the "repo_name": * From the security standpoint we think of the shadow repository having the same ACL as the target repository of the pull request. This is because the pull request itself is considered to be a part of the target repository. Out of this thought, the variable "acl_repo_name" is used whenever we want to check permissions or when we need the database configuration of the repository. An alternative name would have been "db_repo_name", but the usage for ACL checking is the most important one. * From the web interaction perspective, we need the URL which was originally used to get to the repository. This is because based on this base URL commands can be identified. Especially for Git this is important, so that the commands are correctly recognized. Since the URL is in the focus, this is called "url_repo_name". * Finally we have to deal with the repository on the file system. This is what the VCS layer deal with normally, so this name is called "vcs_repo_name". The original repository interaction is a special case where all three names are the same. When interacting with a pull request, these three names are typically all different. This change is minimal in a sense that it just makes the interaction with a shadow repository barely work, without checking any special constraints yet. This was the starting point for further work on this topic.

File last commit:

r346:1a48416d default
r887:175782be default
Show More
swift.js
202 lines | 6.3 KiB | application/javascript | JavascriptLexer
project: added all source files and assets
r1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Swift mode created by Michael Kaminsky https://github.com/mkaminsky11
(function(mod) {
if (typeof exports == "object" && typeof module == "object")
mod(require("../../lib/codemirror"))
else if (typeof define == "function" && define.amd)
define(["../../lib/codemirror"], mod)
else
mod(CodeMirror)
})(function(CodeMirror) {
"use strict"
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 function wordSet(words) {
var set = {}
for (var i = 0; i < words.length; i++) set[words[i]] = true
return set
project: added all source files and assets
r1 }
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 var keywords = wordSet(["var","let","class","deinit","enum","extension","func","import","init","protocol",
"static","struct","subscript","typealias","as","dynamicType","is","new","super",
"self","Self","Type","__COLUMN__","__FILE__","__FUNCTION__","__LINE__","break","case",
"continue","default","do","else","fallthrough","if","in","for","return","switch",
"where","while","associativity","didSet","get","infix","inout","left","mutating",
"none","nonmutating","operator","override","postfix","precedence","prefix","right",
"set","unowned","weak","willSet"])
var definingKeywords = wordSet(["var","let","class","enum","extension","func","import","protocol","struct",
"typealias","dynamicType","for"])
var atoms = wordSet(["Infinity","NaN","undefined","null","true","false","on","off","yes","no","nil","null",
"this","super"])
var types = wordSet(["String","bool","int","string","double","Double","Int","Float","float","public",
"private","extension"])
var operators = "+-/*%=|&<>#"
var punc = ";,.(){}[]"
var number = /^-?(?:(?:[\d_]+\.[_\d]*|\.[_\d]+|0o[0-7_\.]+|0b[01_\.]+)(?:e-?[\d_]+)?|0x[\d_a-f\.]+(?:p-?[\d_]+)?)/i
var identifier = /^[_A-Za-z$][_A-Za-z$0-9]*/
var property = /^[@\.][_A-Za-z$][_A-Za-z$0-9]*/
var regexp = /^\/(?!\s)(?:\/\/)?(?:\\.|[^\/])+\//
function tokenBase(stream, state, prev) {
if (stream.sol()) state.indented = stream.indentation()
if (stream.eatSpace()) return null
var ch = stream.peek()
if (ch == "/") {
if (stream.match("//")) {
stream.skipToEnd()
return "comment"
}
if (stream.match("/*")) {
state.tokenize.push(tokenComment)
return tokenComment(stream, state)
}
if (stream.match(regexp)) return "string-2"
}
if (operators.indexOf(ch) > -1) {
stream.next()
return "operator"
}
if (punc.indexOf(ch) > -1) {
stream.next()
stream.match("..")
return "punctuation"
}
if (ch == '"' || ch == "'") {
stream.next()
var tokenize = tokenString(ch)
state.tokenize.push(tokenize)
return tokenize(stream, state)
}
if (stream.match(number)) return "number"
if (stream.match(property)) return "property"
if (stream.match(identifier)) {
var ident = stream.current()
if (keywords.hasOwnProperty(ident)) {
if (definingKeywords.hasOwnProperty(ident))
state.prev = "define"
return "keyword"
}
if (types.hasOwnProperty(ident)) return "variable-2"
if (atoms.hasOwnProperty(ident)) return "atom"
if (prev == "define") return "def"
return "variable"
}
project: added all source files and assets
r1
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 stream.next()
return null
}
function tokenUntilClosingParen() {
var depth = 0
return function(stream, state, prev) {
var inner = tokenBase(stream, state, prev)
if (inner == "punctuation") {
if (stream.current() == "(") ++depth
else if (stream.current() == ")") {
if (depth == 0) {
stream.backUp(1)
state.tokenize.pop()
return state.tokenize[state.tokenize.length - 1](stream, state)
}
else --depth
}
}
return inner
}
}
function tokenString(quote) {
return function(stream, state) {
var ch, escaped = false
while (ch = stream.next()) {
if (escaped) {
if (ch == "(") {
state.tokenize.push(tokenUntilClosingParen())
return "string"
}
escaped = false
} else if (ch == quote) {
break
} else {
escaped = ch == "\\"
}
}
state.tokenize.pop()
return "string"
}
}
function tokenComment(stream, state) {
stream.match(/^(?:[^*]|\*(?!\/))*/)
if (stream.match("*/")) state.tokenize.pop()
return "comment"
}
function Context(prev, align, indented) {
this.prev = prev
this.align = align
this.indented = indented
}
function pushContext(state, stream) {
var align = stream.match(/^\s*($|\/[\/\*])/, false) ? null : stream.column() + 1
state.context = new Context(state.context, align, state.indented)
}
function popContext(state) {
if (state.context) {
state.indented = state.context.indented
state.context = state.context.prev
}
}
CodeMirror.defineMode("swift", function(config) {
project: added all source files and assets
r1 return {
startState: function() {
return {
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 prev: null,
context: null,
indented: 0,
tokenize: []
project: added all source files and assets
r1 }
},
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 token: function(stream, state) {
var prev = state.prev
state.prev = null
var tokenize = state.tokenize[state.tokenize.length - 1] || tokenBase
var style = tokenize(stream, state, prev)
if (!style || style == "comment") state.prev = prev
else if (!state.prev) state.prev = style
project: added all source files and assets
r1
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 if (style == "punctuation") {
var bracket = /[\(\[\{]|([\]\)\}])/.exec(stream.current())
if (bracket) (bracket[1] ? popContext : pushContext)(state, stream)
}
project: added all source files and assets
r1
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 return style
},
project: added all source files and assets
r1
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 indent: function(state, textAfter) {
var cx = state.context
if (!cx) return 0
var closing = /^[\]\}\)]/.test(textAfter)
if (cx.align != null) return cx.align - (closing ? 1 : 0)
return cx.indented + (closing ? 0 : config.indentUnit)
},
electricInput: /^\s*[\)\}\]]$/,
lineComment: "//",
blockCommentStart: "/*",
blockCommentEnd: "*/"
project: added all source files and assets
r1 }
})
CodeMirror.defineMIME("text/x-swift","swift")
})