Commit Graph

33 Commits

Author SHA1 Message Date
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Rintaro Ishizaki
7e27d99075 [Parse] Remove 'Flags' from 'PersistentParserState'
This is not used anymore.
2023-11-02 23:13:59 -07:00
Alex Hoppen
fe2ae72ad2 [IDE] Rename CodeCompletion to IDEInspection in cases where the code path no longer exclusively applies to code completion
The code completio infrastructure is also being used for cursor info now, so it should no longer be called code completion.

rdar://103251187
2022-12-13 11:41:05 +01:00
Slava Pestov
5808d9beb9 Parse: Remove parse-time name lookup 2020-11-16 22:39:44 -05:00
Hamish Knight
6b87dce845 Remove DelayedDeclLists from PersistentParserState
Rather than parsing all delayed bodies for
`-dump-parse` once we finish parsing, tell the
parser not to delay any bodies. This then allows
us to remove `DelayedDeclLists` from
PersistentParserState.
2020-01-08 10:54:11 -08:00
Rintaro Ishizaki
62c44126b6 [SourceKit] Reuse compiler instance between multiple completion
- Introduce ide::CompletionInstance to manage CompilerInstance
- `CompletionInstance` vends the cached CompilerInstance when:
-- The compiler arguments (i.e. CompilerInvocation) has has not changed
-- The primary file is the same
-- The completion happens inside function bodies in both previous and
   current completion
-- The interface hash of the primary file has not changed
- Otherwise, it vends a fresh CompilerInstance and cache it for the next
  completion

rdar://problem/20787086
2019-12-18 21:52:20 -08:00
Rintaro Ishizaki
ff97c06e8d [CodeCompletion] Use offsets in the buffer for second pass state
So that we can use the different the buffer for the second pass from the
first pass.
2019-12-18 21:52:20 -08:00
David Ungar
3d3507b7b6 Remove unparsed ranges and use diffs to schedule dependents earlier. 2019-12-03 17:23:02 -08:00
David Ungar
742c3985bd Source-range-based dependencies
Frontend outputs source-as-compiled, and source-ranges file with function body ranges and ranges that were unparsed in secondaries.
Driver computes diffs for each source file. If diffs are in function bodies, only recompiles that one file. Else if diffs are in what another file did not parse, then the other file need not be rebuilt.
2019-11-12 20:41:02 -08:00
Rintaro Ishizaki
cd8ebe49bb [Parse/CodeCompletion] Cleanup code completion facilities in Parse
- Rename code completion related names in 'PersistentParserState' so
  it's clear when you are using.
- Refactor 'performCodeCompletionSecondPass()': Inline and consolidate
  'parse*Delayed()' because they used to share many code.

rdar://problem/56926367
2019-11-13 03:21:03 +09:00
Rintaro Ishizaki
4e50237f54 [Parse/CodeCompletion] Cleanup code completion facilities in Parse
- delayParseFromBeginningToHere is useless. Use delayDecl() instead
- Inline PersistentParserState::delayTopLevel()
- Cleanup completion handling in parseDecl()
2019-11-13 02:52:22 +09:00
Doug Gregor
d8b745db77 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-31 16:23:08 -07:00
eeckstein
903eeb220b Revert "Add a request to lazily parse function bodies." 2019-08-31 12:29:01 +02:00
Doug Gregor
2ab05a6835 Add a request to lazily parse function bodies.
Rework the lazy function body parsing mechanism to use the
request-evaluator, so that asking for the body of a function will
initiate parsing. Clean up a number of callers to
AbstractFunctionDecl::getBody() that don't actually need the body, so
we don't perform unnecessary parsing.

This change does not delay parsing of function bodies in the general
case; rather, it sets up the infrastructure to always delay parsing of
function bodies.
2019-08-30 16:48:23 -07:00
Doug Gregor
11969847c4 Simplify lazy parsing of nominal and extension members.
Lazy parsing for the members of nominal types and extensions depends
only on information already present in
`IterableDeclContext`. Eliminate the use of PersistentParserState as
an intermediary and have the member-parsing request construct a new
`Parser` instance itself to handle parsing. Make this possible even
for ill-formed nominal types/extensions to simplify the code path.

Eliminate `LazyMemberParser` and all of its uses, because it was only
present for lazy member parsing, which no longer needs it.
2019-08-30 08:29:43 -07:00
Doug Gregor
d8f7c9e72c [Parser] Introduce a request for parsing type and extension members.
Ensure that lazy parsing of the members of nominal type definitions
and extensions is handled through a request. Most of the effort here
is in establishing a new request zone for parser requests.
2019-08-28 21:39:56 -07:00
Slava Pestov
94149db4ec Parse: Record which delayed type and extension bodies possibly contain operators and classes
To properly delay parsing type and extension bodies we need to know
which ones might contain nested operator and class definitions, since
they must be known upfront when building the global operator lookup
and AnyObject dispatch lookup tables, respectively.

To guess if the type contains operator definitions, we look for the
'func' keyword followed by an operator token.

To guess if the type contains class definitions, we look for the
'class' keyword.

For now, this information is recorded but not used. Subsequent commits
will make use of this information to delay parsing in more cases.
2019-08-12 17:15:51 -04:00
Shahzad Lone
065a25fce1 Reserve AllDelayed vector to upper bound.
File: [swift/lib/Parse/PersistentParserState.cpp]

Observing this code snipped closely in function, [void PersistentParserState::parseAllDelayedDeclLists()]:
```
for (auto &P: DelayedDeclListStates) {
    AllDelayed.push_back(P.first);
}
```

We observe that 'AllDelayed' gets maximum of DelayedDeclListStates.size() elements pushed into it.
So it is better to reserve 'vector AllDelayed' to that max size, to save reallocation cost.

I believe we can use size() on [DelayedDeclListStates], which is of type: ```llvm::DenseMap<IterableDeclContext *, std::unique_ptr<DelayedDeclListState>>``` because of the ```DenseMapIterator``` implementation of size().
[http://llvm.org/doxygen/DenseMap_8h_source.html#l00126]
2019-01-14 20:44:26 -05:00
Xi Ge
a7a06d7ce3 FrontendTool: parse all delayed member decls when we're dumping parse tree or verifying parse diagnostics. 2018-09-12 19:40:28 -07:00
Xi Ge
24b0eac9a4 Parser: parse members in extension decls incrementally. 2018-09-05 17:00:39 -07:00
Rintaro Ishizaki
4df9fc111b [Parse] Remove delayed parsing for accessor decls
Now that, parsing accessor body is done by 'parseAbstractFunctionBody()'
which automatically handles delayed parsing by `delayFunctionBodyParsing()`.
So we no longer use delayed parsing facilities specific for accessor body.
2018-08-29 18:01:21 +09:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01: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
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Xi Ge
4dcc3f1469 [CodeCompletion] No crash on a terribly wrong code completion position. rdar://21796881
Swift SVN r30706
2015-07-28 00:02:33 +00:00
Dmitri Hrybenko
5af5711ab7 Code completion: implement delayed parsing for accessor bodies, allowing code
completion inside computed properties.

Adding tests for willSet/didSet uncovered some crashes while doing code
completion (see FIXMEs), and I will investigate these next.

Partially addresses rdar://15849262


Swift SVN r14338
2014-02-25 16:51:07 +00:00
Dmitri Hrybenko
46a4bc1402 Code completion: preserve the AST for the parsed top-level code. This enables
us to find iteration variables while doing code completion in nested top-level
code.

Fixes part of rdar://15199468


Swift SVN r9343
2013-10-15 01:24:16 +00:00
Dmitri Hrybenko
07e83ea49c Code completion: basic completion in constructor bodies
Swift SVN r8338
2013-09-17 18:20:26 +00:00
Dmitri Hrybenko
3cc01cf7d6 Introduce AbstractFunctionDecl -- a base class for ConstructorDecl,
DestructorDecl, FuncDecl -- and move some of the common concepts and logic
into it

No functionality change.


Swift SVN r8090
2013-09-11 04:04:01 +00:00
Dmitri Hrybenko
536723eca4 Code completion: implement delayed parsing of all (?) declarations
This allows us to show generic parameters in:
struct S<T> {
  func f(a: #^A^#
}

And show the type Z in:
struct S {
  func f(a: #^A^#
  typealias Z = Int
}


Swift SVN r7216
2013-08-13 23:53:39 +00:00
Dmitri Hrybenko
6beee6a62e Code completion: implement delayed parsing and code completion for
TopLevelCodeDecls


Swift SVN r6638
2013-07-26 01:44:23 +00:00
Dmitri Hrybenko
56998205d6 Delayed function body parsing: replace two error handling code paths with asserts
This should just never happen.


Swift SVN r6607
2013-07-25 20:03:55 +00:00
Argyrios Kyrtzidis
66d1e516c8 Refactor how multiple parsing passes and delayed parsing works.
-Introduce PersistentParserState to represent state persistent among multiple parsing passes.
  The advantage is that PersistentParserState is independent of a particular Parser or Lexer object.
-Use PersistentParserState to keep information about delayed function body parsing and eliminate parser-specific
  state from the AST (ParserTokenRange).
-Introduce DelayedParsingCallbacks to abstract out of the parser the logic about which functions should be delayed
  or skipped.

Many thanks to Dmitri for his valuable feedback!

Swift SVN r6580
2013-07-25 01:40:16 +00:00