Commit Graph

7462 Commits

Author SHA1 Message Date
Kirill Bulatov
4f27155d5c Simplify paths searches 2020-02-03 13:56:03 +02:00
Kirill Bulatov
fcf5bbbbeb Fix inlay hints test snippet compilation 2020-02-03 13:35:14 +02:00
bors[bot]
d400fde66c
Merge #2959
2959: Rework how we send diagnostics to client r=matklad a=kiljacken

The previous way of sending from the thread pool suffered from stale diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop thread, but doing all the hard work in the thread pool. This should provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in each individual issue to be sure.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-02-03 11:27:31 +00:00
Emil Lauridsen
9f70f443a3 Update snapshot tests due to removed SuggestedFix 2020-02-03 12:24:57 +01:00
Emil Lauridsen
cde20bf8f0 Remove stray todo 2020-02-03 12:18:06 +01:00
bors[bot]
5b1b2cac39
Merge #2990
2990: Use name only when searching for an import candidate r=me a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-03 11:10:55 +00:00
Laurențiu Nicola
e0c7ce8417 Allow add_explicit_type to replace a placeholder type 2020-02-03 13:09:38 +02:00
Emil Lauridsen
790788d5f4 Rework how we send diagnostics to client.
The previous way of sending from the thread pool suffered from stale
diagnostics due to being canceled before we could clear the old ones.

The key change is moving to sending diagnostics from the main loop
thread, but doing all the hard work in the thread pool. This should
provide the best of both worlds, with little to no of the downsides.

This should hopefully fix a lot of issues, but we'll need testing in
each individual issue to be sure.
2020-02-03 11:34:24 +01:00
bors[bot]
52456c4490
Merge #2993
2993: vscode: fix bundling by switching to es2015 target modules system r=matklad a=Veetaha

Quick fix

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-03 08:54:04 +00:00
Veetaha
8f25408a12 vscode: fix bundling by switching to es2015 target modules system 2020-02-03 10:50:19 +02:00
bors[bot]
dbb235ed07
Merge #2991
2991: vscode: updated rollup typescript so it typechecks the bundle r=Veetaha a=Veetaha

See [this happy update](https://github.com/rollup/plugins/blob/master/packages/typescript/CHANGELOG.md#v300) from `@rollup/typescript-plugin` changelog)

I also added a utility script to view the latest dependencies versions (`dry-run` variant) and update them in batch. Beware, that it bumps versions even if the major version of them has changed (for updating only within one major version there is a cli option, but I didn't want add a whole bunch of scripts)
Some of the dependencies major versions are out of date:
```
~/my/projects/rust-analyzer/editors/code (feature/refactoring-vscode-ext) $ npm run bump-deps:dry-run

> rust-analyzer@0.1.0 bump-deps:dry-run /home/veetaha/my/projects/rust-analyzer/editors/code
> npm-check-updates

Checking /home/veetaha/my/projects/rust-analyzer/editors/code/package.json
[====================] 16/16 100%

 jsonc-parser                    ^2.1.0  →   ^2.2.0 
 @rollup/plugin-commonjs        ^11.0.1  →  ^11.0.2 
 @rollup/plugin-node-resolve     ^6.1.0  →   ^7.1.0 
 @types/node                  ^12.12.25  →  ^13.7.0 
 rollup                         ^1.30.1  →  ^1.31.0 
 tslint                         ^5.20.1  →   ^6.0.0 
 vsce                           ^1.71.0  →  ^1.72.0 
```

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-02 22:21:23 +00:00
Veetaha
0ade5cb2b3 vscode: dropped npm-check-updates script 2020-02-03 00:05:49 +02:00
Veetaha
e9800b0023 vscode: updated rollup typescript so it typechecks the bundle 2020-02-03 00:05:49 +02:00
bors[bot]
ae16884b95
Merge #2989
2989: vscode extension: migrate from any to unknown where possible r=Veetaha a=Veetaha

`unknown` type is the stricter version of `any` and it should always be prefered (like `const` over `let`).
It lets you assign any value to it, but doesn't let you carry out arbitrary operations on them without an explicit type check (like `typeof unknownValue === 'string'`).

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-02 21:27:58 +00:00
Kirill Bulatov
01d59f4a32 Use name only when searching for an import candidate 2020-02-02 23:27:20 +02:00
Veetaha
2fd7af2a62 vscode: use void where possible 2020-02-02 23:24:09 +02:00
Veetaha
5411d65a7f vscode: fix, fallback to any for cmd type 2020-02-02 22:36:12 +02:00
Veetaha
12d0970f7e vscode extension: migrate from any to unknown where possible 2020-02-02 22:19:59 +02:00
bors[bot]
5e61c9b11d
Merge #2987
2987: vscode refactoring: use more laconic export snytax, split huge string literal r=matklad a=Veetaha



Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-02 19:40:28 +00:00
Veetaha
4bf5f59560 vscode: fix type 2020-02-02 21:38:49 +02:00
Veetaha
8184752470 vscode refactoring: use more laconic export snytax, split huge string to several lines 2020-02-02 21:37:22 +02:00
bors[bot]
e72771ebc6
Merge #2986
2986: vscode extension cleanup: migrate to prefer-const tslint rule r=matklad a=Veetaha



Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-02 19:20:42 +00:00
Veetaha
420462421d vscode extension cleanup: migrate to prefer-const tslint rule 2020-02-02 21:12:59 +02:00
bors[bot]
d06e02dd13
Merge #2985
2985: Avoid premature pessimization r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-02 17:57:40 +00:00
Aleksey Kladov
24ad1cce2c Avoid premature pessimization
The extra allocation for message should not matter here at all, but
using a static string is just as ergonomic, if not more, and there's
no reason to write deliberately slow code
2020-02-02 18:56:37 +01:00
bors[bot]
856e4ba126
Merge #2979
2979: vscode: now we are actually using tslib r=matklad a=Veetaha

We had an incorrect setup where `tslib` was in `devDependencies`.
FYI:
tslib is a runtime dependency, it contains functions that are used by transpiled JavaScript in order not to inline them in each file.
For example:
```ts
// foo.ts (source code)
import * as foo from "foo";
// ---------------------------
// foo.js (compiled output)
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const foo = __importStar(require("foo"));
```
As you see, `tsc` generated that `__importStar` helper function in compiled output. And it generates it per each file if you don't enable `"importHelpers": true`. Now with `importHelpers` enabled we get the following picture:
```ts
// foo.ts (source code)
import * as foo from "foo";
// ---------------------------
// foo.js (compiled output)
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const foo = tslib_1.__importStar(require("foo"));
```
It saves some bundle size, but I am not entirely sure wheter we want that. Discussions are welcome!

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-02 14:05:23 +00:00
bors[bot]
9006cec492
Merge #2983
2983: Fix repo link in package.json r=matklad a=Veetaha

Fix repo link

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-02-02 13:57:17 +00:00
bors[bot]
e24829909a
Merge #2982
2982: Merge imports when auto importing r=flodiebold a=SomeoneToIgnore



Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-02 13:06:14 +00:00
zombiefungus
f4f71e361e include requested changes 2020-02-02 08:04:24 -05:00
zombiefungus
7d52715945 add new ImportAlias enum to differentiate no alias from an _ alias 2020-02-02 08:04:24 -05:00
Kirill Bulatov
2ee94e3e24
Remove obsolete rustdoc 2020-02-02 14:59:07 +02:00
Kirill Bulatov
c669b2f489 Code review fixes 2020-02-02 14:27:52 +02:00
Kirill Bulatov
6dae5cbb11 Require ModPath for importing 2020-02-02 14:06:51 +02:00
bors[bot]
dce7dc44be
Merge #2978
2978: Auto import functions r=flodiebold a=SomeoneToIgnore

A follow up for https://github.com/rust-analyzer/rust-analyzer/pull/2887#issuecomment-577832601

I've used the logic for conversion from the https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_hir_def/src/item_scope.rs#L169 method.

I'm not fond of how the conversion is implemented and for my needs, I can simply replace the `hir_def::item_scope::ItemInNs::Types(item.into())` with `hir_def::item_scope::ItemInNs::Values(item.into())` and it will work, so I can use this approach instead, if you find it a better one.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2020-02-02 10:38:03 +00:00
Veetaha
3d6d0819cc fix repo link in package.json 2020-02-02 12:16:41 +02:00
Kirill Bulatov
a9669a5505 Merge imports when auto importing 2020-02-02 10:28:16 +02:00
Veetaha
f08297983f vscode: moved tslib to runtime dependencies and added \"importHelpers\": true 2020-02-01 23:11:39 +02:00
Kirill Bulatov
d3188769e4 Auto import functions 2020-02-01 22:13:02 +02:00
bors[bot]
96bd4f5704
Merge #2975
2975: Update regex r=kjeremy a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-02-01 17:20:39 +00:00
kjeremy
0772f76ad0 Update regex 2020-02-01 12:19:02 -05:00
bors[bot]
3f499489f7
Merge #2964
2964: Improve responsiveness of the cargo check status label r=matklad a=lnicola

This is still not ideal because the label displays the crate that was just checked, not the one that's currently being checked. But it should give the impression of being faster.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-01 15:41:55 +00:00
bors[bot]
eba599d986
Merge #2972
2972: Prevent child cargo process from messing with our stdin r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-02-01 15:28:48 +00:00
Aleksey Kladov
5559d6b8a8 Prevent child cargo process from messing with our stdin
By default, `spawn` inherits stderr/stdout/stderr of the parent
process, and so, if child, for example does fcntl(O_NONBLOCK), weird
stuff happens to us.

Closes https://github.com/rust-analyzer/lsp-server/pull/10
2020-02-01 16:25:44 +01:00
bors[bot]
a878f39b5e
Merge #2963 #2967
2963: Emacs fixes r=matklad a=flodiebold

 - use provided environment for runnables (finally set `RUST_BACKTRACE`)
 - implement `selectAndApplySourceChange` so auto-import works 🙂 

cc @brotzeit 

2967: Disable optimizations for some build-time crates r=matklad a=lnicola

This speeds up a release build on my laptop from 4m 13s to 3m 33s. It's a bit disappointing, but we don't get perfect parallelism during the build. The non-RA dependencies finish building around 72s as opposed to 112s.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
Co-authored-by: Florian Diebold <florian.diebold@freiheit.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-01 14:41:39 +00:00
bors[bot]
8e0ad99832
Merge #2970
2970: [VSCode] Fix syntax highlighting r=matklad a=bjorn3

Fixes #2969
Fixes #2971

Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-02-01 14:34:04 +00:00
bjorn3
c84897bfb7 Tsfmt 2020-02-01 13:41:11 +01:00
bjorn3
5c39311f96 Fix seedrandom in packaged extension
Fixes #2971
2020-02-01 13:39:04 +01:00
bjorn3
f4431d2acc [VSCode] Fix syntax highlighting
Fixes #2969
2020-02-01 13:12:39 +01:00
bors[bot]
fc0a8c14dc
Merge #2965
2965: Improve auto import message r=kiljacken a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-02-01 11:10:50 +00:00
Florian Diebold
2586cf9279 Implement support for selectAndApplySourceChange (auto import) in Emacs 2020-01-31 22:24:05 +01:00