mirror of
https://github.com/hsjobeki/noogle.git
synced 2024-12-24 14:32:15 +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
|
||||
/// partially applied functions -> special case, don't know how it is "correct". Would need access to the upvalues?
|
||||
///
|
||||
/// Simple lambdas (not partially applied)
|
||||
/// Match primop: (Doesnt have source position)
|
||||
/// Eq countApplied,
|
||||
@ -40,23 +40,21 @@ pub fn find_aliases(item: &Docs, list: &Vec<&Docs>) -> AliasList {
|
||||
return match (o_meta.isPrimop, s_meta.isPrimop) {
|
||||
// Both PrimOp
|
||||
(true, true) => {
|
||||
let is_empty = match &s_meta.content {
|
||||
Some(c) => c.is_empty(),
|
||||
None => true,
|
||||
};
|
||||
if s_meta.countApplied != Some(0)
|
||||
&& s_meta.countApplied == o_meta.countApplied
|
||||
{
|
||||
if item.path.last() == other.path.last() {
|
||||
return Some(other.path.clone());
|
||||
} else {
|
||||
return None;
|
||||
match s_meta.countApplied {
|
||||
Some(0) => {
|
||||
if s_meta.name.is_some() && s_meta.name == o_meta.name {
|
||||
return Some(other.path.clone());
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
if s_meta.countApplied == o_meta.countApplied
|
||||
&& item.path.last() == other.path.last()
|
||||
{
|
||||
return Some(other.path.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if o_meta.content == s_meta.content && !is_empty {
|
||||
return Some(other.path.clone());
|
||||
}
|
||||
None
|
||||
}
|
||||
// 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) {
|
||||
return Some(other.path.clone());
|
||||
}
|
||||
|
||||
// Last resort try to find all functions with:
|
||||
// - same source position
|
||||
// - same isPrimop
|
||||
|
@ -45,11 +45,17 @@
|
||||
},
|
||||
{
|
||||
"docs": {
|
||||
"attr": { "content": "", "position": null },
|
||||
"attr": {
|
||||
"position": null
|
||||
},
|
||||
"lambda": {
|
||||
"args": ["e1", "e2"],
|
||||
"arity": 2,
|
||||
"content": "\n Return the sum of the numbers *e1* and *e2*.\n ",
|
||||
"countApplied": 0,
|
||||
"experimental": false,
|
||||
"isPrimop": true,
|
||||
"name": "add",
|
||||
"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