Commit Graph

146 Commits

Author SHA1 Message Date
John McCall
c8c41b385c Implement SE-0077: precedence group declarations.
What I've implemented here deviates from the current proposal text
in the following ways:

- I had to introduce a FunctionArrowPrecedence to capture the parsing
  of -> in expression contexts.

- I found it convenient to continue to model the assignment property
  explicitly.

- The comparison and casting operators have historically been
  non-associative; I have chosen to preserve that, since I don't
  think this proposal intended to change it.

- This uses the precedence group names and higherThan/lowerThan
  as agreed in discussion.
2016-07-26 14:04:57 -07:00
Xi Ge
195c737b54 [libIDE] Add syntax kind of argument to fix a crash. rdar://27377118
Argument used to have the same syntax kind with that of parameter. This patch
starts to differentiate them.
2016-07-19 15:10:46 -07:00
Jordan Rose
5ff3ee3933 [IDE] Don't assume a platform name's SourceRange matches its length.
We're about to make 'macOS' and 'OSX' aliases.

Groundwork for SE-0106.
2016-07-07 10:28:52 -07:00
Xi Ge
3e03b78b77 [SyntaxColoring] Tolerating empty spaces between doc-comment openning… (#3373)
* [SyntaxColoring] Tolerating empty spaces between doc-comment opennings and field keywords. rdar://26310081

* [test] Update test for SourceKit.
2016-07-06 22:41:58 -07:00
Xi Ge
500fdd22d1 [Syntax] Avoid highlighting keyword-like labels in call arguments as … (#3369)
* [Syntax] Avoid highlighting keyword-like labels in call arguments as keywords. rdar://24460689

* [test] Update test for SourceKit.
2016-07-06 22:40:44 -07:00
David Farler
05235956fc SourceKit: Include up to closing paren in object literals
rdar://problem/26451674
2016-05-24 18:29:01 -07:00
David Farler
6c726620c0 SourceKit: Clean up syntax map switch
When creating the token map for highlighting, there is some glitchy
behavior that needed to be cleaned up:

- New image literal syntax wasn't getting highlighted as an object
  literal keyword.
- Other #-prefixed keywords had no data
- #line would appear as a build config ("brown") at the start of a line
- #available showed up as a build config. However, this should be a keyword
  because it is a runtime check, not a build configuration.

Add some test cases for these.

Fixes:
rdar://problem/26451674
2016-05-24 17:34:22 -07:00
Ted Kremenek
b8bbed8c13 [WIP] Implement SE-0039 (Modernizing Playground Literals) (#2215)
* Implement the majority of parsing support for SE-0039.

* Parse old object literals names using new syntax and provide FixIt.

For example, parse "#Image(imageLiteral:...)" and provide a FixIt to
change it to "#imageLiteral(resourceName:...)".  Now we see something like:

test.swift:4:9: error: '#Image' has been renamed to '#imageLiteral
var y = #Image(imageLiteral: "image.jpg")
        ^~~~~~ ~~~~~~~~~~~~
        #imageLiteral resourceName

Handling the old syntax, and providing a FixIt for that, will be handled in a separate
commit.

Needs tests.  Will be provided in later commit once full parsing support is done.

* Add back pieces of syntax map for object literals.

* Add parsing support for old object literal syntax.

... and provide fixits to new syntax.

Full tests to come in later commit.

* Improve parsing of invalid object literals with old syntax.

* Do not include bracket in code completion results.

* Remove defunct code in SyntaxModel.

* Add tests for migration fixits.

* Add literals to code completion overload tests.

@akyrtzi told me this should be fine.

* Clean up response tests not to include full paths.

* Further adjust offsets.

* Mark initializer for _ColorLiteralConvertible in UIKit as @nonobjc.

* Put attribute in the correct place.
2016-04-25 07:19:26 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Xi Ge
f0e96f1e70 [SyntaxColoring] Allow empty lines when highlighting doc comment keywords. rdar://25144566 2016-03-15 13:28:34 -07:00
Ben Langmuir
8030d44826 [SyntaxMap] Fold unary minus into numeric literals
Unlike other prefix operators, unary minus is folded into the
NumberLiteralExpr in the parser. This commit recreates this effect in
the lexer-based syntax map so that token ranges will include the leading
minus.

rdar://problem/20205885
2016-03-15 10:40:52 -07:00
Xi Ge
b74bd730a6 [SyntaxColoring] Not coloring 'keywords' appearing in API argument names as actual keywords; they are legal names. rdar://25129880 2016-03-14 17:39:40 -07:00
Xi Ge
8b7eff2e7f [SyntaxColoring] Sanitize extra closing parenthesis by the end of URLs. 2016-03-14 11:18:48 -07:00
Xi Ge
f64ff89bd4 [SyntaxColoring] Remember to search for URLs inside doc comment lines/blocks. 2016-03-14 11:18:48 -07:00
Xi Ge
9c2f28475e [SyntaxColoring] Highlight doc comment keywords in playground-specific doc comment format. rdar://24870642 2016-03-01 15:44:41 -08:00
Chris Lattner
8dedfb31e3 Add support for #file/#line, etc according to SE-0028. __FILE__ and friends
are still accepted without deprecation warning as of this patch.
2016-02-04 14:22:22 -08:00
Doug Gregor
dccf3155f1 SE-0022: Implement parsing, AST, and semantic analysis for #selector. 2016-01-26 21:12:04 -08:00
Xi Ge
00bff249ff [SyntaxModel] Highlight /*: ... */, when appearing in playground, as doc comment block. rdar://24234991 2016-01-21 11:05:34 -08:00
Doug Gregor
ecfde0e71c Start parsing names with argument labels.
Basic implementatation of SE-0021, naming functions with argument
labels. Handle parsing of compound function names in various
unqualified-identifier productions, updating the AST representation of
various expressions from Identifiers to DeclNames. The result doesn't
capture all of the source locations we want; more on that later.

As part of this, remove the parsing code for the "selector-style"
method names, since we now have a replacement. The feature was never
publicized and doesn't make sense in Swift, so zap it outright.
2016-01-20 17:09:01 -08:00
Xi Ge
c73bb636cd [SyntaxColoring] Teach syntax model to recognize playground-specific doc comment lines. rdar://23902920 2016-01-04 12:38:34 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Ge Sen
7ac02d54ba Erase redundant whitespaces. 2015-12-10 13:35:06 +08:00
Doug Coleman
86d99cea9b Fix eight Linux warnings.
Fix spurious docs warning that @in and @in_guaranteed should be ``fn``.

Add ``#ifdef SWIFT_OBJC_INTEROP`` to silence a -Wunused-function
on linux since that function is only used from within that #ifdef
elsewhere.

Fix three -Wunused-function warnings on linux.

Fix two -Wunreachable-code warnings on linux dealing with
SWIFT_HAVE_WORKING_STD_REGEX.
2015-12-07 15:29:41 -08:00
Xi Ge
37370aaa55 [SyntaxColoring] Check if the end quote is escaped when checking if a string ends. rdar://23188457 2015-11-04 10:55:15 -08:00
Dmitri Hrybenko
2e51d23875 Un-ifdef object literals
Swift SVN r32880
2015-10-25 07:50:53 +00:00
Dmitri Hrybenko
0b4a54f64c CMake: detect and refuse broken std::regex
Swift SVN r32256
2015-09-26 05:06:43 +00:00
Argyrios Kyrtzidis
012f6cb083 [IDE] Make sure to process the body of a defer statement properly.
Fixes IDE features (except code-completion) not working inside 'defer'.
rdar://22849414.

Swift SVN r32254
2015-09-26 00:50:39 +00:00
Xi Ge
7f6a8b1315 Remove the constructor of CharSourceRange that takes SourceRange;
And add a utility function at lexer that converts SourceRange to CharSourceRange.

Swift SVN r32023
2015-09-17 01:15:34 +00:00
Xi Ge
682e4320d8 [SyntaxModel] Adjust the end loc when converting from SourceRange to CharSourceRange. rdar://22676599
Swift SVN r32013
2015-09-16 21:58:53 +00:00
Xi Ge
3088128501 Refactor DenseMapInfo<ASTNode> to ASTNode.h
Swift SVN r31438
2015-08-24 22:25:24 +00:00
Xi Ge
a21010e8f7 [SyntaxColor] Teach syntax model walker not to walk into active regions inside #if config stmt twice. rdar://22224993
Swift SVN r31433
2015-08-24 18:28:08 +00:00
Xi Ge
f9a621e6f5 [SyntaxHighlight] Highlight #line as keyword. rdar://22163375
Swift SVN r31040
2015-08-06 01:34:25 +00:00
Jordan Rose
953424072e Guard "object literals" feature with SWIFT_ENABLE_OBJECT_LITERALS.
This is not a feature we're releasing at the moment, so provide a way
to turn it off.

rdar://problem/21935551

Swift SVN r30966
2015-08-04 00:16:52 +00:00
Xi Ge
da69adbb09 [SyntaxHighlighting] Fix a issue when detecting multiple urls exist in one line of commit.
Swift SVN r30682
2015-07-27 01:12:30 +00:00
Xi Ge
f51335ac65 [SyntaxHighlighting] Highlight platform keywords inside available attributes. rdar://21905215
Swift SVN r30681
2015-07-27 01:12:28 +00:00
Xi Ge
61ccc5f48e Move radar number out of source file.
Swift SVN r30546
2015-07-23 20:23:04 +00:00
Xi Ge
72df884348 [SyntaxColoring] Correct the node kind of attributes and comment on the special case.
Swift SVN r30544
2015-07-23 19:49:17 +00:00
Xi Ge
95dc5b5607 [SyntaxColoring] Address Jordan's comments.
Highlight all decl modifiers for enum element decls, not just "indirect", as keywords.

Swift SVN r30524
2015-07-23 02:24:43 +00:00
Xi Ge
d980700f17 [SyntaxColoring] Add syntax coloring to indirect keyword of enum element decl. rdar://21927124
Swift SVN r30521
2015-07-23 01:37:22 +00:00
Chris Lattner
0001dc27bb remove support for the experiemental "character literals" feature.
Swift SVN r30509
2015-07-22 22:35:19 +00:00
Xi Ge
2f3a77ab40 Address Ben's comments on r30290
Swift SVN r30325
2015-07-17 20:27:17 +00:00
Xi Ge
42ecad7903 [SyntaxModel] Improve the efficiency of url regex search.
We improve the efficiency through two ways: 1. read the protocol keywords, such as
http, radar, or im, to select the right regex pattern to search for instead of
trying every known patterns; and 2. reduce the regex search space by truncating
text before protocol keywords. rdar://21009781

Swift SVN r30290
2015-07-17 00:03:22 +00:00
Xi Ge
57489ceb0f [SyntaxHighlighting] Give ASTWalker the option to walk into generic params of function decls.
Therefore, generic params can also benefit from syntax highlighting and semantic annotation
in SourceKit. rdar://20529255

Swift SVN r30220
2015-07-15 18:28:09 +00:00
Xi Ge
29cebb8ac5 [SyntaxModel] Ensure syntax-coloring does not crash when the last token is a DeclAttribute.
This may happen to rethrows, rdar://21324493

Swift SVN r29472
2015-06-17 23:35:58 +00:00
David Farler
794d9ed84d Check both ends of doc comments before trimming
Doc comments assume a prefix of /** and a suffix of */
but if a user accidentally types /**/, SourceKit can crash and
bring down Xcode with certain timings. Check both ends of doc
comments before dropping characters.

rdar://problem/21105409

Swift SVN r29035
2015-05-26 18:25:19 +00:00
David Farler
b0f87a059b Highlight documentation comments and some syntax
- Start highlighting doc comments as Xcode "Documentation Comments".
- Start highlighting custom top-level fields as Xcode "Documentation
Comment Keywords".

This requires SourceKit r28827 to build and Xcode
rdar://problem/21034381 for proper highlighting.

Swift SVN r28828
2015-05-20 09:08:13 +00:00
Maxwell Swadling
73700aab02 Added ObjectLiterals to the SyntaxMap
rdar://problem/20821831

Swift SVN r28787
2015-05-19 21:14:10 +00:00
Argyrios Kyrtzidis
7c69b077c7 [IDE] Add enum elements in the document structure.
rdar://18845613

Swift SVN r28618
2015-05-15 06:56:22 +00:00
Chris Lattner
d5ecef1d67 remove a pointless return type, silencing a warning.
Swift SVN r28539
2015-05-13 23:32:21 +00:00