Joachim Mårtensson
f7dd4c0ace
Add std::hash() implementation to scope_t
2015-05-09 21:21:01 +02:00
Allan Odgaard
40879d5683
Replace sizeofA macro with range-based for loop or std::begin/end
2015-03-05 16:38:09 +07:00
Allan Odgaard
de6724aad5
Minor scope_t implementation improvements
...
We let std::string do comparisons and we shortcut the equivalence test for scope_t when the node pointers are identical.
2014-09-16 13:57:52 +02:00
Allan Odgaard
b6c77d1960
Change behavior and implementation of to_s overload for scopes
...
For a scope context with identical left/right scopes we now return the scope without “decoration” and when the left/right scopes differ, we return them separated by the unit separator character.
The change is motivated by the need to use the result of to_s as a cache key where speed is important.
2014-09-16 12:54:48 +02:00
Allan Odgaard
39b94e6ac3
Harmonize whitespace and add trailing newline
2014-04-14 14:26:52 +07:00
Allan Odgaard
c2397484b8
Use C++11 for loop
...
Majority of the edits done using the following ruby script:
def update_loops(src)
dst, cnt = '', 0
block_indent, variable = nil, nil
src.each_line do |line|
if block_indent
if line =~ /^#{block_indent}([{}\t])|^\t*$/
block_indent = nil if $1 == '}'
line = line.gsub(%r{ ([^a-z>]) \(\*#{variable}\) | \*#{variable}\b | \b#{variable}(->) }x) do
$1.to_s + variable + ($2 == "->" ? "." : "")
end
else
block_indent = nil
end
elsif line =~ /^(\t*)c?iterate\((\w+), (?!diacritics::make_range)(.*\))$/
block_indent, variable = $1, $2
line = "#$1for(auto const& #$2 : #$3\n"
cnt += 1
end
dst << line
end
return dst, cnt
end
paths.each do |path|
src = IO.read(path)
cnt = 1
while cnt != 0
src, cnt = update_loops(src)
STDERR << "#{path}: #{cnt}\n"
end
File.open(path, "w") { |io| io << src }
end
2014-03-03 10:34:13 +07:00
Joachim Mårtensson
ca98e2f86d
Use std::atomic family
2013-09-05 20:59:10 +02:00
Allan Odgaard
e4e80a946c
Use std::make_shared
2013-09-03 12:27:20 +02:00
Allan Odgaard
29ba700c71
More encapsulation
2013-08-31 21:24:39 +02:00
Allan Odgaard
91fb146f26
Remove custom debug/trace log system
2013-08-31 21:24:39 +02:00
Allan Odgaard
95376adb79
Convert scope match API to accept C strings
2013-08-31 21:24:39 +02:00
Allan Odgaard
f67c91dcb9
Introduce C string API
...
This may seem like a step back, but is the easiest way to deal with “static strings” (that should not be copied).
2013-08-31 21:24:39 +02:00
Allan Odgaard
caf347e66d
Remove unused to_s functions
2013-08-31 21:24:39 +02:00
Allan Odgaard
f0a932e9e4
Remove unused comparison operators
2013-08-31 21:24:38 +02:00
Allan Odgaard
96e0a6e0ff
Improve encapsulation
2013-08-31 21:24:38 +02:00
Allan Odgaard
9bf9c51494
Use linked list for scope_t data
2013-08-31 21:24:38 +02:00
Allan Odgaard
0a8a238159
Add more scope selector tests
2013-08-31 20:49:47 +02:00
Allan Odgaard
d241a971f2
Update scope selector matching code
...
This is in anticipation of changing scope_t data layout.
2013-08-31 20:48:25 +02:00
Allan Odgaard
c01e181b49
Use name convention to identify non-content scopes
2013-08-31 16:09:49 +02:00
Allan Odgaard
cc56c61c78
Remove scope::types::atom_t
...
This is first step toward decreasing memory usage by scope_t.
2013-08-31 16:09:49 +02:00
Allan Odgaard
0f5bbdfad0
Remove unused scope parsing API
2013-08-31 16:09:49 +02:00
Allan Odgaard
c0e8186bc1
When constructing scope, split string on space instead of parsing
2013-08-31 16:09:48 +02:00
Allan Odgaard
05b0b480f1
Handle assigning empty scope to non-empty scope
2013-08-31 16:09:48 +02:00
Allan Odgaard
b52b13329e
Call scope_t::empty instead of using an operator bool cast
2013-08-30 12:30:34 +02:00
Allan Odgaard
240dc4baec
Simplify scope::shared_prefix and scope_t::has_prefix
...
This is mainly for upcoming implementation changes.
2013-08-30 12:30:34 +02:00
Allan Odgaard
b624d7cc98
Treat empty string as empty scope
...
Previously would be a scope with one empty “atom”.
2013-08-30 12:30:34 +02:00
Allan Odgaard
62e3db265c
Add scope_t::empty and scope_t::size
2013-08-30 12:30:33 +02:00
Allan Odgaard
79dc48acc3
Add range check to scope atom parser
2013-08-30 12:30:33 +02:00
Allan Odgaard
1442e3061f
Remove old scope_t API
2013-08-28 00:23:08 +02:00
Allan Odgaard
d42417ee1a
Use public API for scope_t utility functions
2013-08-28 00:23:08 +02:00
Allan Odgaard
1cc0065623
Return false from ‘scope_t::operator bool’ when there is no scope
2013-08-28 00:23:08 +02:00
Allan Odgaard
5da71f9556
Add new API for mutating scope_t
2013-08-28 00:23:07 +02:00
Allan Odgaard
057096af5b
Rename API to make searching easier
...
Using generic names like ‘append’ is not good when analyzing code for potential refactoring.
2013-08-27 15:30:09 +02:00
Allan Odgaard
8f1485d158
String given to scope_t::append now returned from scope_t::back
...
Previously we would parse the string appended to an existing scope, meaning invalid scopes would not be returned as the same string.
Fixes #1099
2013-08-26 15:54:05 +02:00
Allan Odgaard
0a465955d1
Allow peeking at the last element of a scope
...
This is useful when constructing scopes during parsing.
2013-08-25 17:58:08 +02:00
Allan Odgaard
cb098b4d80
Update testing system for scope framework
2013-07-26 13:53:58 +02:00
Joachim Mårtensson
eaf2d97141
Using ‘$’ in scope selector will anchor to end of content scope
...
The content scope is the portion of the scope created while parsing the document content, unlike scope attributes, document, project, SCM, and dynamic scopes (appended to the content scope).
2013-03-25 10:22:27 +01:00
Allan Odgaard
d16f3bcc1e
Use per-line indent patterns when estimating indent
...
This solves the problem where we need to estimate the current line’s indent, but the lines above it is a multi-line block comment. Previously we would fetch indent patterns based on the current scope, then find the first line above caret, for which the patterns can be used to estimate the indent. The problem is that the commented lines without comment markers would be treated as code, and used for the indent.
With the new approach, we can set different patterns for ‘comment.block’ (the C bundle already does this), which basically ignore all the lines, which will cause TextMate to use the code above the comment to estimate indent.
This commit closes textmate/c.tmbundle#3 and also closes textmate/php.tmbundle#24 .
2013-03-13 12:38:12 +01:00
Allan Odgaard
b139ac5097
Change push_back → emplace_back (C++11)
...
This is mainly motivated by readability, so I only did a few select replacements.
2013-02-08 11:20:35 +01:00
Allan Odgaard
bcbd055137
Use exp2(x) instead of pow(2, x)
2013-02-08 11:20:35 +01:00
Allan Odgaard
e75e7ec8e5
Change text::format → std::to_string (C++11)
2013-02-08 11:20:34 +01:00
Allan Odgaard
cbe91ff831
Assume compiler support for explicit keyword
...
Since we require a fairly recent clang for other features, there is no reason to test for this one.
2012-08-29 14:27:35 +02:00
Jacob Bandes-Storch
0fcb4c2d2c
Use libc++: don’t rely on implicit conversions
2012-08-28 20:10:55 +02:00
Jacob Bandes-Storch
e3aa997b06
Use libc++: replace std::tr1 with std
2012-08-28 13:30:20 +02:00
Allan Odgaard
4ca897816d
Remove TS_WARN since we do have tests
...
Sort of a fixup! to 2c6a847 (which added child selectors).
2012-08-19 15:53:43 +02:00
Joachim Mårtensson
b21fbd897e
Fix ^, previously it failed immediatly if last rule in scope selector, wasn't tested against last scope part. Fixed by giving ^ additional chances
2012-08-10 18:44:16 +02:00
Joachim Mårtensson
49320f4efb
Fix bug with > in scope selector. There was an implicit > after path
2012-08-10 18:44:16 +02:00
Joachim Mårtensson
2c6a8471f9
Add support for ^ $ and > in scope selectors
2012-08-10 18:44:16 +02:00
Allan Odgaard
9894969e67
Initial commit
2012-08-09 16:25:56 +02:00