Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def visit_Keyword(self, node: Keyword) -> None: # noqa: N802
source=self.file_path.as_posix(),
validation_str_without_prefix=node.name.lower().replace(" ", "").replace("_", ""),
validation_str_with_prefix=keyword_name_with_prefix.lower().replace(" ", "").replace("_", ""),
line_number=node.lineno,
)
)
except AttributeError:
Expand Down
2 changes: 2 additions & 0 deletions packages/roboview/roboview/schemas/domain/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class KeywordProperties(BaseModel):
called_keywords: list[str] | None = Field(
description="List of keywords that are called by the actual Keyword", default=[]
)
line_number: int | None = Field(description="Line number where the keyword is defined", default=None)


class KeywordUsage(BaseModel):
Expand All @@ -34,6 +35,7 @@ class KeywordUsage(BaseModel):
source: str = Field(description="Path of the file, where the keyword is defined as POSIX")
file_usages: int = Field(description="Usage of the keyword, in the selected file")
total_usages: int = Field(description="Total usage of the keyword across the whole project")
line_number: int | None = Field(description="Line number where the keyword is defined", default=None)


class SimilarKeyword(BaseModel):
Expand Down
6 changes: 6 additions & 0 deletions packages/roboview/roboview/services/keyword_usage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def get_keywords_with_global_usage_for_file(self, file_path: Path, keyword_type:
kw, file_path.as_posix()
),
total_usages=self._get_global_keyword_usage_for_target_keyword(kw),
line_number=keyword.line_number,
)
)
except Exception:
Expand Down Expand Up @@ -164,6 +165,7 @@ def get_keywords_without_documentation(self) -> list[KeywordUsage]:
total_usages=self._get_global_keyword_usage_for_target_keyword(
entry.keyword_name_with_prefix
),
line_number=entry.line_number,
)
)
except Exception:
Expand Down Expand Up @@ -198,6 +200,7 @@ def get_keywords_without_usages(self) -> list[KeywordUsage]:
source=entry.source,
file_usages=total_usages,
total_usages=total_usages,
line_number=entry.line_number,
)
)
except Exception:
Expand Down Expand Up @@ -241,6 +244,7 @@ def get_potential_duplicate_keywords(self, keyword_sim_service: KeywordSimilarit
total_usages=self._get_global_keyword_usage_for_target_keyword(
entry.keyword_name_with_prefix
),
line_number=entry.line_number,
)
)
except Exception:
Expand Down Expand Up @@ -334,6 +338,7 @@ def _get_external_or_builtin_keywords_with_usages(self) -> list[KeywordUsage]:
total_usages=self._get_global_keyword_usage_for_target_keyword(
entry.keyword_name_with_prefix
),
line_number=entry.line_number,
)
)
except Exception:
Expand Down Expand Up @@ -375,6 +380,7 @@ def _get_user_defined_keywords_with_usages(self) -> list[KeywordUsage]:
total_usages=self._get_global_keyword_usage_for_target_keyword(
entry.keyword_name_with_prefix
),
line_number=entry.line_number,
)
)
except Exception:
Expand Down
34 changes: 27 additions & 7 deletions vscode-integration/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions vscode-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@
"test": "vscode-test"
},
"dependencies": {
"axios": "^1.7.9",
"dotenv": "^17.3.1"
"axios": "^1.7.9"
},
"devDependencies": {
"@types/axios": "^0.9.36",
"@types/dotenv": "^6.1.1",
"@types/mocha": "^10.0.10",
"@types/node": "25.x",
"@types/vscode": "^1.93.0",
Expand All @@ -96,6 +97,7 @@
"@vscode/test-cli": "^0.0.11",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^3.7.1",
"dotenv": "^17.4.2",
"esbuild": "^0.27.3",
"eslint": "^10.0.2",
"eslint-config-prettier": "^10.1.8",
Expand Down
12 changes: 9 additions & 3 deletions vscode-integration/src/roboViewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
Uri,
ViewColumn,
Range,
TextEditorRevealType,
Position,
} from "vscode";
import axios from "axios";
import { getUri } from "./utils/getUri";
Expand Down Expand Up @@ -170,12 +172,16 @@ export class RoboViewPanel {

if (filePath) {
const fileUri = Uri.file(filePath);
window.showTextDocument(fileUri, {
const position = new Position(line - 1, 0);
const range = new Range(position, position);

const editor = await window.showTextDocument(fileUri, {
preview: false,
viewColumn: ViewColumn.Active,
selection:
line > 1 ? new Range(line - 1, 0, line - 1, 0) : undefined,
selection: range,
});

editor.revealRange(range, TextEditorRevealType.InCenter);
}
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ export function MainContentKeywordUsage({
pageStartIndex + PAGE_SIZE,
);

const handleSourceClick = (event: React.MouseEvent, filePath: string) => {
if (event.ctrlKey || event.metaKey) {
event.stopPropagation();
vscode.postMessage({ command: "openFile", filePath });
}
};
const handleSourceClick = (event: React.MouseEvent, filePath: string, lineNumber: number) => {
if (event.ctrlKey || event.metaKey) {
event.stopPropagation();
vscode.postMessage({ command: "openFile", filePath, line: lineNumber });
}
};

if (showNoFileSelected) {
return <NoFileSelected />;
Expand Down Expand Up @@ -318,7 +318,7 @@ export function MainContentKeywordUsage({
<TableCell
className="px-4 py-3 text-sm text-muted-foreground"
onClick={(event) =>
handleSourceClick(event, keyword.source)
handleSourceClick(event, keyword.source, keyword.line_number)
}
title={keyword.source}
>
Expand Down
1 change: 1 addition & 0 deletions vscode-integration/webview-ui/src/types/keywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface Keyword {
source: string;
file_usages: number;
total_usages: number;
line_number: number;
}

export interface KeywordCounts {
Expand Down
Loading