Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
35abf139
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
35abf139
编写于
5月 31, 2017
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small refactoring + docs
上级
a2a999f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
31 deletion
+45
-31
src/librustc_save_analysis/json_api_dumper.rs
src/librustc_save_analysis/json_api_dumper.rs
+1
-1
src/librustc_save_analysis/json_dumper.rs
src/librustc_save_analysis/json_dumper.rs
+1
-10
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/lib.rs
+15
-1
src/librustc_save_analysis/sig.rs
src/librustc_save_analysis/sig.rs
+28
-19
未找到文件。
src/librustc_save_analysis/json_api_dumper.rs
浏览文件 @
35abf139
...
...
@@ -15,7 +15,7 @@
use
external_data
::
*
;
use
data
::{
VariableKind
,
Visibility
};
use
dump
::
Dump
;
use
json_dumper
::
id_from_def_id
;
use
id_from_def_id
;
use
rls_data
::{
Analysis
,
Import
,
ImportKind
,
Def
,
DefKind
,
CratePreludeData
};
...
...
src/librustc_save_analysis/json_dumper.rs
浏览文件 @
35abf139
...
...
@@ -10,7 +10,6 @@
use
std
::
io
::
Write
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
rustc_serialize
::
json
::
as_json
;
use
rls_data
::{
self
,
Id
,
Analysis
,
Import
,
ImportKind
,
Def
,
DefKind
,
Ref
,
RefKind
,
MacroRef
,
...
...
@@ -20,6 +19,7 @@
use
external_data
::
*
;
use
data
::
VariableKind
;
use
dump
::
Dump
;
use
id_from_def_id
;
pub
struct
JsonDumper
<
O
:
DumpOutput
>
{
result
:
Analysis
,
...
...
@@ -163,15 +163,6 @@ fn inheritance(&mut self, data: InheritanceData) {
// method, but not the supplied method). In both cases, we are currently
// ignoring it.
// DefId::index is a newtype and so the JSON serialisation is ugly. Therefore
// we use our own Id which is the same, but without the newtype.
pub
fn
id_from_def_id
(
id
:
DefId
)
->
Id
{
Id
{
krate
:
id
.krate
.as_u32
(),
index
:
id
.index
.as_u32
(),
}
}
impl
Into
<
Import
>
for
ExternCrateData
{
fn
into
(
self
)
->
Import
{
Import
{
...
...
src/librustc_save_analysis/lib.rs
浏览文件 @
35abf139
...
...
@@ -1026,6 +1026,20 @@ fn escape(s: String) -> String {
// Helper function to determine if a span came from a
// macro expansion or syntax extension.
pub
fn
generated_code
(
span
:
Span
)
->
bool
{
fn
generated_code
(
span
:
Span
)
->
bool
{
span
.ctxt
!=
NO_EXPANSION
||
span
==
DUMMY_SP
}
// DefId::index is a newtype and so the JSON serialisation is ugly. Therefore
// we use our own Id which is the same, but without the newtype.
fn
id_from_def_id
(
id
:
DefId
)
->
rls_data
::
Id
{
rls_data
::
Id
{
krate
:
id
.krate
.as_u32
(),
index
:
id
.index
.as_u32
(),
}
}
fn
id_from_node_id
(
id
:
NodeId
,
scx
:
&
SaveContext
)
->
rls_data
::
Id
{
let
def_id
=
scx
.tcx.hir
.local_def_id
(
id
);
id_from_def_id
(
def_id
)
}
src/librustc_save_analysis/sig.rs
浏览文件 @
35abf139
...
...
@@ -8,16 +8,38 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// FIXME? None of these include visibility info.
// Large outstanding things - where clauses, defs/refs for generics
// paresable - each sig ends with `;` of ` {}`
// A signature is a string representation of an item's type signature, excluding
// any body. It also includes ids for any defs or refs in the signature. For
// example:
//
// ```
// fn foo(x: String) {
// println!("{}", x);
// }
// ```
// The signature string is something like "fn foo(x: String) {}" and the signature
// will have defs for `foo` and `x` and a ref for `String`.
//
// All signature text should parse in the correct context (i.e., in a module or
// impl, etc.). Clients may want to trim trailing `{}` or `;`. The text of a
// signature is not guaranteed to be stable (it may improve or change as the
// syntax changes, or whitespace or punctuation may change). It is also likely
// not to be pretty - no attempt is made to prettify the text. It is recommended
// that clients run the text through Rustfmt.
//
// This module generates Signatures for items by walking the AST and looking up
// references.
//
// Signatures do not include visibility info. I'm not sure if this is a feature
// or an ommission (FIXME).
//
// FIXME where clauses need implementing, defs/refs in generics are mostly missing.
use
SaveContext
;
use
{
SaveContext
,
id_from_def_id
,
id_from_node_id
}
;
use
rls_data
::{
Signature
,
SigElement
,
Id
};
use
rls_data
::{
Signature
,
SigElement
};
use
rustc
::
hir
::
def
::
Def
;
use
rustc
::
hir
::
def_id
::
DefId
;
use
syntax
::
ast
::{
self
,
NodeId
};
use
syntax
::
print
::
pprust
;
...
...
@@ -26,19 +48,6 @@ pub fn item_signature(item: &ast::Item, scx: &SaveContext) -> Option<Signature>
item
.make
(
0
,
None
,
scx
)
.ok
()
}
// TODO dup from json_dumper
fn
id_from_def_id
(
id
:
DefId
)
->
Id
{
Id
{
krate
:
id
.krate
.as_u32
(),
index
:
id
.index
.as_u32
(),
}
}
fn
id_from_node_id
(
id
:
NodeId
,
scx
:
&
SaveContext
)
->
Id
{
let
def_id
=
scx
.tcx.hir
.local_def_id
(
id
);
id_from_def_id
(
def_id
)
}
type
Result
=
::
std
::
result
::
Result
<
Signature
,
&
'static
str
>
;
trait
Sig
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录