mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Rust: add block ids to canonical paths, making them "extended"
This commit is contained in:
2
rust/extractor/src/generated/.generated.list
generated
2
rust/extractor/src/generated/.generated.list
generated
@@ -1,2 +1,2 @@
|
||||
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
|
||||
top.rs 781f69884739378b8b401f67c795fda457996dc2ee0785ce143dc6d9a2607f13 781f69884739378b8b401f67c795fda457996dc2ee0785ce143dc6d9a2607f13
|
||||
top.rs 60b0821a7535361e4f0dd280d654c4d8167fca919bda082b17f91ff9878788a5 60b0821a7535361e4f0dd280d654c4d8167fca919bda082b17f91ff9878788a5
|
||||
|
||||
4
rust/extractor/src/generated/top.rs
generated
4
rust/extractor/src/generated/top.rs
generated
@@ -5129,8 +5129,8 @@ pub struct Item {
|
||||
}
|
||||
|
||||
impl Item {
|
||||
pub fn emit_canonical_path(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
|
||||
out.add_tuple("item_canonical_paths", vec![id.into(), value.into()]);
|
||||
pub fn emit_extended_canonical_path(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
|
||||
out.add_tuple("item_extended_canonical_paths", vec![id.into(), value.into()]);
|
||||
}
|
||||
pub fn emit_crate_origin(id: trap::Label<Self>, value: String, out: &mut trap::Writer) {
|
||||
out.add_tuple("item_crate_origins", vec![id.into(), value.into()]);
|
||||
|
||||
@@ -5,6 +5,7 @@ use crate::trap::{DiagnosticSeverity, TrapFile, TrapId};
|
||||
use crate::trap::{Label, TrapClass};
|
||||
use codeql_extractor::trap::{self};
|
||||
use log::Level;
|
||||
use ra_ap_base_db::salsa::InternKey;
|
||||
use ra_ap_base_db::CrateOrigin;
|
||||
use ra_ap_hir::db::ExpandDatabase;
|
||||
use ra_ap_hir::{Adt, ItemContainer, Module, Semantics, Type};
|
||||
@@ -347,9 +348,9 @@ impl<'a> Translator<'a> {
|
||||
}
|
||||
|
||||
fn canonical_path_from_hir_module(&self, item: Module) -> Option<String> {
|
||||
if ModuleId::from(item).is_block_module() {
|
||||
if let Some(block_id) = ModuleId::from(item).containing_block() {
|
||||
// this means this is a block module, i.e. a virtual module for a block scope
|
||||
return None;
|
||||
return Some(format!("{{{}}}", block_id.as_intern_id()));
|
||||
}
|
||||
if item.is_crate_root() {
|
||||
return Some("crate".into());
|
||||
@@ -407,7 +408,7 @@ impl<'a> Translator<'a> {
|
||||
let path = self.canonical_path_from_hir(def)?;
|
||||
let origin = self.origin_from_hir(def);
|
||||
generated::Item::emit_crate_origin(label, origin, &mut self.trap.writer);
|
||||
generated::Item::emit_canonical_path(label, path, &mut self.trap.writer);
|
||||
generated::Item::emit_extended_canonical_path(label, path, &mut self.trap.writer);
|
||||
Some(())
|
||||
})();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user