Commit Graph

189 Commits

Author SHA1 Message Date
Marcelo Fabri
94465a38c0 [SourceKit] Add GenericTypeParam to structure (SR-5474) (#13616) 2018-01-09 17:28:52 -08:00
Xi Ge
3160446a8c SourceKitd: fix a placeholder expanding issue. rdar://34230324
When expanding placeholders, we analyze the surrounding context of a
placeholder to decide whether to expand the placeholder to a trailing
closure. This analysis assumes CallExpr is the only AST node with argument;
however UnresolvedMemberExpr can have argument as well. This commit
teaches the analysis logic to handle both.
2017-11-16 16:31:50 -08:00
Slava Pestov
a70a1f0d36 IDE: Fix bug in SourceEntityWalker subscript handling
We weren't passing the lvalue access kind to the subscript.
This was causing a test to fail with the next patch.
2017-11-13 22:19:25 -08:00
Slava Pestov
0715eaeaed AST: Move SourceEntityWalker to IDE 2017-11-13 22:10:41 -08:00
Adam Nemet
9b9805420d Add optimization remarks
This allows reporting successful and unsuccessful optimizations similar to
clang/llvm.

This first patch adds support for the
options -Rpass=<pass-name-regex> -Rpass-missed=<pass-name-regex>.  These allow
reporting successful/unsuccessful optimization on the compiler output for passes
specified by the regex.  I've also added one missed and one passed remark type
to the inliner to test the infrastructure.

Clang also has the option of collecting these records in an external YAML data
file.  This will be added in a later patch.

A few notes:
* The goal is to use this facility for both user-lever "performance" warnings
and expert-level performance analysis.  There will probably be a flag in the
future differentiating the verbosity.

* The intent is match clang/llvm as much as it makes sense.  On the other hand I
did make some changes.  Unlike in llvm, the emitter is not a pass which
simplifies things.  Also the remark class hierarchy is greatly simplified since
we don't derive from DiagnosticInfo.  We also don't derive from Diagnostic to
support the streaming API for arbitrary named-value pairs.

* Currently function names are printed mangled which should be fixed.
2017-10-20 12:41:37 -07:00
Ben Langmuir
9c7d9235de [sourcekitd] Add a request to get statistics from the service
... and add a few basic statistics about the number of requests, ASTs
built, etc.  The Statistic type is loosely based on the one from LLVM,
but suitable for using without DEBUG macros and using SourceKit UIdents
to identify the statistic.  The easiest way to add a new statistic is to
add it to SwiftStatistics.def in the SwiftLangSupport.
2017-10-05 12:34:49 -07:00
Ben Langmuir
4e6831d485 [SourceKit] Disable automatic rebuilding of dependent-ASTs
After modifying a file, don't rebuild the ASTs for every file that
(might) depend on it.  This is very expensive if there are a lot of open
documents and we don't yet provide a way for clients to distinguish
documents that they want to update from any other documents that e.g.
are just open because they haven't been saved yet.

rdar://problem/34415818
2017-10-02 10:21:01 -07:00
Marcelo Fabri
2bf49b0151 [SourceKit] Add range for attributes in a structure (SR-5587) (#11750) 2017-09-20 15:54:42 -07:00
Nathan Hawes
d12d7c1b12 [SyntaxColoring] Address review feedback for rdar://problem/33463141 NFC 2017-09-14 21:36:22 -07:00
Nathan Hawes
5b82a25240 [SyntaxColoring] Fix losing syntax highlighting for a type or function declaration following an incomplete function decl missing a closing parenthesis
If an edit didn't intersect with an existing highlighted tokens but caused a
later highlighted token to change kind, syntax highlighting would be lost
between the edit and that token.

Resolves rdar://problem/33463141.
2017-09-14 21:36:13 -07:00
Nathan Hawes
c0ee62be93 [syntax-coloring|test] Update test cases for new behaviour and address review comments 2017-09-14 21:34:22 -07:00
Nathan Hawes
f64a19bbbe [syntax-coloring] Relax the requirement that the reported affected range extends to line boundaries
The editor is now assumed to handle affected ranges that don't fall on line boundaries.
2017-09-14 21:34:22 -07:00
Nathan Hawes
13874d3f12 [syntax-coloring] Remove early exit from delta logic when there are no new highlighted tokens but are removed ones, and take account of the range of the mismatching token in the previous syntax map
We still need to adjust the affected range to the line boundaries and return all
tokens on the line when there are no new tokens, as the client will clear all
tokens on that line in its copy of the syntax map leaving the other tokens
unhighlighted. We also need to extend the affected range to include the ranges
of the mismatched tokens from the previous syntaxmap, so their highlighting will
be cleared.

Also add more comments to better document the new syntax map structure and
behaviour.
2017-09-14 21:34:22 -07:00
Nathan Hawes
77d502cb39 [syntax-coloring] Fix incorrectly reporting a no-op when a token is removed 2017-09-14 21:34:21 -07:00
Nathan Hawes
6b9690ac5c [syntax-coloring] Rework the syntax map to use offset+length rather than start/end line+column and simplify the delta logic
This patch changes the syntax map data structure it uses to be offset based
rather than line/col based in order to avoid calling getLineAndColumn for the
start and end offset of every token. This removes the 30% of time spent in
getLineAndColumn for this request in large files (rdar://problem/28965123).

The logic for returning the affected range and the token ranges to highlight
following an edit also made several assumptions that no longer hold. This
patch changes it to compare the syntax maps from before and after the edit,
find the first mismtaching tokens from the start and end of the syntax maps
and return the tokens in that range (adjusted to line boundaries). This fixes
syntax highlighting issues with interpolated multi-line strings
(rdar://problem/32148117) and block comments.

With the above changes the per-keystroke time spent for syntax highlighting
(with sematic info disabled) dropped from ~80ms to just under 50ms for a
12KLOC file.
2017-09-14 21:34:21 -07:00
swift-ci
0bae2e5aa6 Merge pull request #11660 from nkcsgexi/code-expand-trailing 2017-08-28 14:24:35 -07:00
Xi Ge
5c9099b07e SourceKitd: Properly record enclosing statement to ensure expanding to trailing closures consistently. rdar://33477177 2017-08-28 13:43:13 -07:00
Jordan Rose
449cd98997 Excise "Accessibility" from the compiler (3/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

Rename AccessibilityAttr to AccessControlAttr and
SetterAccessibilityAttr to SetterAccessAttr, then track down the last
few uses of "accessibility" that don't have to do with
NSAccessibility. (I left the SourceKit XPC API alone because that's
supposed to be more stable.)
2017-08-28 13:27:59 -07:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Jordan Rose
5f30eac288 Excise "Accessibility" from the compiler (1/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the names of methods, fields, a few local
variables, and even a swift-ide-test flag. The full list is below.

accessibilityForDiagnostics -> accessLevelForDiagnostics
checkAccessibility -> checkAccess
checkGenericParamAccessibility -> checkGenericParamAccess
checkTypeAccessibility -> checkTypeAccess
checkWitnessAccessibility -> checkWitnessAccessibility
computeAccessibility -> computeAccessLevel
computeDefaultAccessibility -> computeDefaultAccessLevel
fixItAccessibility -> fixItAccess
getAccessibilityString -> getAccessLevelString
getAccessibilityStrictly -> getAccessLevelStrictly
getAccessibilityUID -> getAccessLevelUID
getActualAccessibility -> getActualAccessLevel
getDefaultAccessibility -> getDefaultAccessLevel
getMaxAccessibility -> getMaxAccessLevel
getOverridableAccessibility -> getOverridableAccessLevel
getRawStableAccessibility -> getRawStableAccessLevel
getSetterAccessibility -> getSetterFormalAccess
hasAccessibility -> hasAccess
hasDefaultAccessibility -> hasDefaultAccessLevel
inferAccessibility -> inferAccessLevel
inferDefaultAccessibility -> inferDefaultAccessLevel
inferSetterAccessibility -> inferSetterAccessLevel
overwriteAccessibility -> overwriteAccess
overwriteSetterAccessibility -> overwriteSetterAccess
printAccessibility -> printAccess
requiredAccessibilityForDiagnostics -> requiredAccessForDiagnostics
resolveAccessibility -> resolveAccessControl
setAccessibility -> setAccess
setSetterAccessibility -> setSetterAccess
setDefaultAndMaxAccessibility -> setDefaultAndMaxAccess
validateAccessibility -> validateAccessControl

Accessibility -> AccessLevel
AccessibilityFilter -> AccessFilter
IgnoreAccessibility -> IgnoreAccessControl
NL_IgnoreAccessibility -> NL_IgnoreAccessControl
PrintAccessibility -> PrintAccess
PrintInternalAccessibilityKeyword -> PrintInternalAccessKeyword
SetterAccessibility -> SetterAccessLevel

setterAccessibility -> setterAccess
storedPropertyAccessibility -> storedPropertyAccess

-print-accessibility -> -print-access
2017-08-28 11:11:57 -07:00
Argyrios Kyrtzidis
8e9c172f81 [sourcekitd] Fix crash in the document structure request when a class name starts with a number
rdar://33817431
2017-08-22 12:22:50 -07:00
Marcelo Fabri
40b054b642 [SourceKit] Add local variables to structure (SR-5057) (#11431) 2017-08-11 13:43:05 -07:00
Marcelo Fabri
d16cce3a94 [SourceKit] Add documentation range in structure (SR-2487) (#11264) 2017-08-02 13:39:49 -07:00
Marcelo Fabri
8a8f7c827e [SourceKit] Add accessibility in extension structure (SR-4823) (#11260) 2017-07-31 14:14:25 -07:00
Xi Ge
b8cf32f1e9 Revert "[syntax-coloring] Rework the syntax map to use offset + length and simplify the delta logic" (#10633)
Resolving rdar://32988175.
2017-06-27 12:28:41 -07:00
Harlan
e89e7f58b2 [Parse] [Syntax] Simplify TupleTypeRepr parsing and add attributes for Syntax (#8298)
* Simplify TupleTypeRepr parsing

This patch introduces a TupleTypeReprElement struct that holds the
locations for all relevant bits of tuple elements. It removes the
NameLoc and UnderscoreLoc arrays from TupleTypeReprElement in favor of
holding each of these on TupleTypeReprElement. These extra bits of info
are required for full-fidelity representation in the Syntax library.

* Remove TupleTypeReprBitfields and move EllipsisLoc out of TrailingObjects

* Update users of TupleTypeRepr

* Don't resize the elts if we're going to push_back

* getType -> getElementType

* Move ellipsis back into TrailingObjects.

* Move NumElements into TupleTypeReprBitfields
2017-06-27 10:54:47 -07:00
Argyrios Kyrtzidis
0cfc56ec04 [SourceKit] If diagnostics are 'stale' for a particular snapshot then ignore them and only return the syntactic parser diagnostics (#10388)
This makes sure that diagnostics returned for a particular state of source buffer are consistent and accurate.
rdar://32769873
2017-06-20 12:26:32 -07:00
Nathan Hawes
3791e12895 [syntax-coloring] Remove early exit from delta logic when there are no new highlighted tokens but are removed ones, and take account of the range of the mismatching token in the previous syntax map
We still need to adjust the affected range to the line boundaries and return all
tokens on the line when there are no new tokens, as the client will clear all
tokens on that line in its copy of the syntax map leaving the other tokens
unhighlighted. We also need to extend the affected range to include the ranges
of the mismatched tokens from the previous syntaxmap, so their highlighting will
be cleared.

Also add more comments to better document the new syntax map structure and
behaviour.
2017-06-19 11:45:08 -07:00
Nathan Hawes
1158137d95 [syntax-coloring] Fix incorrectly reporting a no-op when a token is removed 2017-06-15 13:16:04 -07:00
Nathan Hawes
09cb55ebf3 [syntax-coloring] Rework the syntax map to use offset+length rather than start/end line+column and simplify the delta logic
This patch changes the syntax map data structure it uses to be offset based
rather than line/col based in order to avoid calling getLineAndColumn for the
start and end offset of every token. This removes the 30% of time spent in
getLineAndColumn for this request in large files (rdar://problem/28965123).

The logic for returning the affected range and the token ranges to highlight
following an edit also made several assumptions that no longer hold. This
patch changes it to compare the syntax maps from before and after the edit,
find the first mismtaching tokens from the start and end of the syntax maps
and return the tokens in that range (adjusted to line boundaries). This fixes
syntax highlighting issues with interpolated multi-line strings
(rdar://problem/32148117) and block comments.

With the above changes the per-keystroke time spent for syntax highlighting
(with sematic info disabled) dropped from ~80ms to just under 50ms for a
12KLOC file.
2017-06-15 13:15:43 -07:00
Alex Hoppen
58c956a29a [Misc] Preparations for removal of getName on ValueDecl
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:13:24 -07:00
Nathan Hawes
e5426ecfa5 Revert "[SyntaxColor] Improve highligting of multiline strings"
This reverts commit 86d0fc37bc.
This was causing a performance regression.

Resolves rdar://problem/32434045
2017-05-26 16:46:03 -07:00
Nathan Hawes
56fb4a5d9f [SyntaxColor] Improve highligting of multiline strings
Multiline strings (and multiline tokens in general) were not well supported by the existing highlighting logic. Edits
on one line can make tokens appear/disappear on previous and later lines, which broke assumptions in the existing
logic, and left odd ranges of source unhighlighted or out of date. This patch accounts for these changes, and also
changes unterminated  multiline (and regular strings) to still be highlighted as strings, so the rest of the
file doesn't look like plain text.

Resolves rdar://problem/32148117.
2017-05-22 16:53:32 -07:00
Maxwell Swadling
93d485e4f7 Changed handleDiagnostic to take a format string and format args instead of the formatted string
This allows diagnostic consumers to modify the way formatting of diagnostics is performed.
rdar://problem/31305854
2017-04-14 11:28:04 -07:00
Xi Ge
1827fb1436 RangeInfo: Report RValue type if a decl reference is of read-only LValue type. (#8300) 2017-03-23 15:52:54 -07:00
Xi Ge
0d97dd4992 [SourceKit] Add a new request to translate markup text to its XML equivalence. rdar://30587403 (#8088)
Required fields:
- "key.request": "source.request.convert.markup.xml"
- "key.sourcetext": "markup text"

Expected response:
- "key.sourcetext": "xml text"
2017-03-14 15:13:43 -07:00
Slava Pestov
162b2d252e AST: Include gardening to minimize dependencies on Expr.h
A lot of files transitively include Expr.h, because it was
included from SILInstruction.h, SILLocation.h and SILDeclRef.h.

However in reality most of these files don't do anything
with Exprs, especially not anything in IRGen or the SILOptimizer.

Now we're down to 171 files in the frontend which depend on
Expr.h, which is still a lot but much better than before.
2017-03-12 22:26:56 -07:00
Xi Ge
b4cf37bf7d Sema: several improvements on missing switch cases diagnostics. (#8026)
1. Make sure the actions taken by fixits are reflected in diagnostics messages.
2. Issue missing cases diagnostics at the start of the switch statement instead of its end.
3. Use <#code#> instead of <#Code#> in the stub.
2017-03-10 19:32:37 -08:00
Hugh Bellamy
2cdee2f09d Fix MSVC static assertion failure in SourceKit 2017-02-21 10:33:25 +07:00
Hugh Bellamy
2bc2341300 Fix SourceKit unreachable warnings 2017-02-19 14:20:52 +07:00
Xi Ge
6b699d8855 SourceEntityWalker: keep track of type reference in extension declarations' openings. (#7192)
This is necessary when we want to differentiate between type reference
on extension declaration's start, e.g "extension A {}", and other
references of "A". NFC on existing functionality.
2017-02-01 17:09:01 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Xi Ge
14f968a5ed SourceEntityWalker: Add a parameter to visitDeclReference() describing the kind of the reference under visit. NFC 2016-12-20 14:30:02 -08:00
practicalswift
9d0b2abfc2 [gardening] Normalize end-of-namespace comments 2016-12-17 22:29:07 +01:00
Rintaro Ishizaki
264be984b5 [AST] Eliminate NamedTypeRepr
Now that, TupleTypeRepr holds all information needed.
2016-11-26 14:17:57 +09:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Xi Ge
9577d980b0 [SourceKit] Initialize pointer as nullptr to fix a crash. rdar://28959889 2016-10-27 13:01:50 -07:00
John McCall
afdda3d107 Implement SE-0117.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one.  On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones.  The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
2016-08-02 07:46:38 -07:00
Jordan Rose
508e825ff2 Split 'fileprivate' and 'private', but give them the same behavior.
'fileprivate' is considered a broader level of access than 'private',
but for now both of them are still available to the entire file. This
is intended as a migration aid.

One interesting fallout of the "access scope" model described in
758cf64 is that something declared 'private' at file scope is actually
treated as 'fileprivate' for diagnostic purposes. This is something
we can fix later, once the full model is in place. (It's not really
/wrong/ in that they have identical behavior, but diagnostics still
shouldn't refer to a type explicitly declared 'private' as
'fileprivate'.)

As a note, ValueDecl::getEffectiveAccess will always return 'FilePrivate'
rather than 'Private'; for purposes of optimization and code generation,
we should never try to distinguish these two cases.

This should have essentially no effect on code that's /not/ using
'fileprivate' other than altered diagnostics.

Progress on SE-0025 ('fileprivate' and 'private')
2016-07-25 13:13:35 -07:00
Xi Ge
09a19bb230 [SourceKit] Avoid expanding the last argument as trailing closure if there are other closures in the tuple. rdar://23428366 (#3408)
SourceKit invariantly expands the last argument in a function call as trailing closure,
if it is of function type. However, there are situations when inline closures
are preferred; for example, when the last argument is not the only closure in the function
call. This patch modifies SourceKit so that when the argument contains multiple closures,
the last argument is expanded as inline closure.
2016-07-07 18:25:55 -07:00