mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-12-25 06:53:17 +03:00
fix: alias breakage of lib.pipe
This commit is contained in:
parent
0b6941791f
commit
f64a53a52f
58612
pesto/json.json
58612
pesto/json.json
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@ use crate::pasta::{AliasList, Docs, ValuePath};
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
/// Match
|
/// Match
|
||||||
/// partially applied functions -> special case, don't know how it is "correct". Would need access to the upvalues?
|
///
|
||||||
/// Simple lambdas (not partially applied)
|
/// Simple lambdas (not partially applied)
|
||||||
/// Match primop: (Doesnt have source position)
|
/// Match primop: (Doesnt have source position)
|
||||||
/// Eq countApplied,
|
/// Eq countApplied,
|
||||||
@ -40,23 +40,21 @@ pub fn find_aliases(item: &Docs, list: &Vec<&Docs>) -> AliasList {
|
|||||||
return match (o_meta.isPrimop, s_meta.isPrimop) {
|
return match (o_meta.isPrimop, s_meta.isPrimop) {
|
||||||
// Both PrimOp
|
// Both PrimOp
|
||||||
(true, true) => {
|
(true, true) => {
|
||||||
let is_empty = match &s_meta.content {
|
match s_meta.countApplied {
|
||||||
Some(c) => c.is_empty(),
|
Some(0) => {
|
||||||
None => true,
|
if s_meta.name.is_some() && s_meta.name == o_meta.name {
|
||||||
};
|
return Some(other.path.clone());
|
||||||
if s_meta.countApplied != Some(0)
|
}
|
||||||
&& s_meta.countApplied == o_meta.countApplied
|
}
|
||||||
{
|
_ => {
|
||||||
if item.path.last() == other.path.last() {
|
if s_meta.countApplied == o_meta.countApplied
|
||||||
return Some(other.path.clone());
|
&& item.path.last() == other.path.last()
|
||||||
} else {
|
{
|
||||||
return None;
|
return Some(other.path.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if o_meta.content == s_meta.content && !is_empty {
|
|
||||||
return Some(other.path.clone());
|
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
// Both None PrimOp
|
// Both None PrimOp
|
||||||
@ -65,7 +63,6 @@ pub fn find_aliases(item: &Docs, list: &Vec<&Docs>) -> AliasList {
|
|||||||
if s_meta.countApplied == Some(0) || o_meta.countApplied == Some(0) {
|
if s_meta.countApplied == Some(0) || o_meta.countApplied == Some(0) {
|
||||||
return Some(other.path.clone());
|
return Some(other.path.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last resort try to find all functions with:
|
// Last resort try to find all functions with:
|
||||||
// - same source position
|
// - same source position
|
||||||
// - same isPrimop
|
// - same isPrimop
|
||||||
|
@ -45,11 +45,17 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"docs": {
|
"docs": {
|
||||||
"attr": { "content": "", "position": null },
|
"attr": {
|
||||||
|
"position": null
|
||||||
|
},
|
||||||
"lambda": {
|
"lambda": {
|
||||||
|
"args": ["e1", "e2"],
|
||||||
|
"arity": 2,
|
||||||
"content": "\n Return the sum of the numbers *e1* and *e2*.\n ",
|
"content": "\n Return the sum of the numbers *e1* and *e2*.\n ",
|
||||||
"countApplied": 0,
|
"countApplied": 0,
|
||||||
|
"experimental": false,
|
||||||
"isPrimop": true,
|
"isPrimop": true,
|
||||||
|
"name": "add",
|
||||||
"position": null
|
"position": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
36
pesto/test_data/aliases/pipe.expect
Normal file
36
pesto/test_data/aliases/pipe.expect
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"aliases": [
|
||||||
|
[
|
||||||
|
"lib",
|
||||||
|
"trivial",
|
||||||
|
"pipe"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"lib",
|
||||||
|
"pipe"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aliases": [
|
||||||
|
[
|
||||||
|
"lib",
|
||||||
|
"pipe"
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"path": [
|
||||||
|
"lib",
|
||||||
|
"trivial",
|
||||||
|
"pipe"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"aliases": [],
|
||||||
|
"path": [
|
||||||
|
"lib",
|
||||||
|
"lists",
|
||||||
|
"unique"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
56
pesto/test_data/aliases/pipe.json
Normal file
56
pesto/test_data/aliases/pipe.json
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"docs": {
|
||||||
|
"attr": {
|
||||||
|
"position": {
|
||||||
|
"column": 27,
|
||||||
|
"file": "test_data/assets/default.nix",
|
||||||
|
"line": 73
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lambda": {
|
||||||
|
"content": "\n Reduce a list by applying a binary operator, from left to right,\n e.g. `foldl' op nul [x0 x1 x2 ...] = op (op (op nul x0) x1) x2)\n ...`. For example, `foldl' (x: y: x + y) 0 [1 2 3]` evaluates to 6.\n The return value of each application of `op` is evaluated immediately,\n even for intermediate values.\n ",
|
||||||
|
"countApplied": 1,
|
||||||
|
"isPrimop": true,
|
||||||
|
"position": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path": ["lib", "pipe"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"docs": {
|
||||||
|
"attr": {
|
||||||
|
"position": {
|
||||||
|
"column": 3,
|
||||||
|
"file": "test_data/assets/trivial.nix",
|
||||||
|
"line": 94
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lambda": {
|
||||||
|
"content": "\n Reduce a list by applying a binary operator, from left to right,\n e.g. `foldl' op nul [x0 x1 x2 ...] = op (op (op nul x0) x1) x2)\n ...`. For example, `foldl' (x: y: x + y) 0 [1 2 3]` evaluates to 6.\n The return value of each application of `op` is evaluated immediately,\n even for intermediate values.\n ",
|
||||||
|
"countApplied": 1,
|
||||||
|
"isPrimop": true,
|
||||||
|
"position": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path": ["lib", "trivial", "pipe"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"docs": {
|
||||||
|
"attr": {
|
||||||
|
"position": {
|
||||||
|
"column": 3,
|
||||||
|
"file": "test_data/assets/lists.nix",
|
||||||
|
"line": 864
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lambda": {
|
||||||
|
"content": "\n Reduce a list by applying a binary operator, from left to right,\n e.g. `foldl' op nul [x0 x1 x2 ...] = op (op (op nul x0) x1) x2)\n ...`. For example, `foldl' (x: y: x + y) 0 [1 2 3]` evaluates to 6.\n The return value of each application of `op` is evaluated immediately,\n even for intermediate values.\n ",
|
||||||
|
"countApplied": 2,
|
||||||
|
"isPrimop": true,
|
||||||
|
"position": null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"path": ["lib", "lists", "unique"]
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user