@@ -35,6 +35,49 @@ struct RenameOptions {
bool RenameVirtual = true;
};
+/// A name of a symbol that should be renamed.
+///
+/// Symbol's name can be composed of multiple strings. For example, Objective-C
+/// methods can contain multiple argument labels:
+///
+/// \code
+/
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/82061
>From 2ae885429ae7658f014eacebd89e204512f3a1c2 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Mon, 29 Jul 2024 17:33:43 -0700
Subject: [PATCH] [clangd] Use `RenameSymbolName` to represent Objective-C
selectors
ahoppen wrote:
Thanks for the review, @DavidGoldman. I addressed your comments.
https://github.com/llvm/llvm-project/pull/82061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/82061
>From 1285081e8fc7d7ecd162ed8ec7201437dbd708da Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Mon, 29 Jul 2024 17:33:43 -0700
Subject: [PATCH] [clangd] Use `RenameSymbolName` to represent Objective-C
selectors
ahoppen wrote:
@DavidGoldman Would you mind reviewing my changes?
https://github.com/llvm/llvm-project/pull/82061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
ahoppen wrote:
@sam-mccall If you could review my latest changes, that would be great.
https://github.com/llvm/llvm-project/pull/82061
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
ahoppen wrote:
For some context: When I’m talking about * finding the ranges to rename based
on an index that’s not clangd’s built-in index* I meant a request like
https://github.com/apple/llvm-project/pull/7973. This allows us to use Apple’s
IndexStore to find the locations of symbols to rena
@@ -13,6 +13,7 @@ add_clang_library(clangToolingRefactoring
Rename/USRFinder.cpp
Rename/USRFindingAction.cpp
Rename/USRLocFinder.cpp
+ SymbolName.cpp
ahoppen wrote:
Goode suggestions 👍🏽
https://github.com/llvm/llvm-project/pull/82061
_
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/82061
>From fca2389759d73380312e284c05ddc1662209de2e Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Fri, 16 Feb 2024 14:50:25 -0800
Subject: [PATCH] [clangd] Use `SymbolName` to represent Objective-C selectors
MIME-V
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/82061
>From a8f769d2376e01c789ebf10df95e18b8c23cb79f Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Fri, 16 Feb 2024 14:50:25 -0800
Subject: [PATCH] [clangd] Use `SymbolName` to represent Objective-C selectors
MIME-V
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/82061
>From 8b4d8134f581dd44595f347e2ca2465a069411a4 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Fri, 16 Feb 2024 14:50:25 -0800
Subject: [PATCH] [clangd] Use `SymbolName` to represent Objective-C selectors
MIME-V
https://github.com/ahoppen approved this pull request.
Thanks for fixing!
https://github.com/llvm/llvm-project/pull/82396
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/82061
>From be2388c8552ea7a4466046c4d2c9b041a5bf78f2 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Fri, 16 Feb 2024 14:50:25 -0800
Subject: [PATCH] [clangd] Use `SymbolName` to represent Objective-C selectors
MIME-V
https://github.com/ahoppen created
https://github.com/llvm/llvm-project/pull/82061
This is a cleaner design than using identifier and an optional `Selector`. It
also allows rename of Objective-C method names if no declaration is at hand and
thus no `Selector` instance can be formed. For exampl
@@ -538,11 +564,222 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -538,11 +564,222 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -538,11 +564,222 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
https://github.com/ahoppen edited
https://github.com/llvm/llvm-project/pull/76466
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/ahoppen commented:
The outstanding comments from last review are:
- Use `SymbolName` instead of `StringRef`
- https://github.com/llvm/llvm-project/pull/76466#discussion_r1476409221
- https://github.com/llvm/llvm-project/pull/76466#discussion_r1476427027
- Don’t re-lex the s
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -508,24 +513,46 @@ static bool mayBeValidIdentifier(llvm::StringRef Ident) {
!isAsciiIdentifierStart(Ident.front(), AllowDollar))
return false;
for (char C : Ident) {
+if (AllowColon && C == ':')
ahoppen wrote:
Oh, I just assumed that the fi
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -53,13 +55,34 @@ struct RenameInputs {
struct RenameResult {
// The range of the symbol that the user can attempt to rename.
Range Target;
+ // Placeholder text for the rename operation if non-empty.
+ std::string Placeholder;
// Rename occurrences for the current m
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -508,24 +513,46 @@ static bool mayBeValidIdentifier(llvm::StringRef Ident) {
!isAsciiIdentifierStart(Ident.front(), AllowDollar))
return false;
for (char C : Ident) {
+if (AllowColon && C == ':')
ahoppen wrote:
Should we also allow spaces he
@@ -569,8 +840,13 @@ renameWithinFile(ParsedAST &AST, const NamedDecl
&RenameDecl,
// }
if (!isInsideMainFile(RenameLoc, SM))
continue;
+Locs.push_back(RenameLoc);
+ }
+ if (const auto *MD = dyn_cast(&RenameDecl))
+return renameObjCMethodWithinFile(AS
@@ -508,24 +513,46 @@ static bool mayBeValidIdentifier(llvm::StringRef Ident) {
!isAsciiIdentifierStart(Ident.front(), AllowDollar))
return false;
for (char C : Ident) {
+if (AllowColon && C == ':')
+ continue;
if (llvm::isASCII(C) && !isAsciiIdentifie
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -508,24 +513,46 @@ static bool mayBeValidIdentifier(llvm::StringRef Ident) {
!isAsciiIdentifierStart(Ident.front(), AllowDollar))
return false;
for (char C : Ident) {
+if (AllowColon && C == ':')
+ continue;
if (llvm::isASCII(C) && !isAsciiIdentifie
@@ -681,12 +957,22 @@ renameOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFilePath,
ExpBuffer.getError().message());
continue;
}
+std::string RenameIdentifier = RenameDecl.getNameAsString();
ahoppen wrote:
Technically `
ahoppen wrote:
I think we could also include my tests from
https://github.com/llvm/llvm-project/pull/78872/files#diff-26ff7c74af8a1d882abbad43625d3cd4bf8d024ef5c7064993f5ede3eec8752eR834
More tests never hurt.
https://github.com/llvm/llvm-project/pull/76466
_
@@ -681,12 +957,22 @@ renameOutsideFile(const NamedDecl &RenameDecl,
llvm::StringRef MainFilePath,
ExpBuffer.getError().message());
continue;
}
+std::string RenameIdentifier = RenameDecl.getNameAsString();
+std::optional Selector = std::nullopt;
+
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
@@ -538,11 +565,254 @@ std::optional checkName(const NamedDecl
&RenameDecl,
Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
}
}
- if (Result)
+ if (Result) {
InvalidNameMetric.record(1, toString(Result->K));
+return makeError(*Re
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/78872
>From 26d9d1a5a342df34cde921f7d9921e7b94dadd87 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Tue, 19 Dec 2023 15:54:40 -0800
Subject: [PATCH 1/5] [Refactoring] Add capabilities to `SymbolName` to
represent Ob
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/78872
>From 26d9d1a5a342df34cde921f7d9921e7b94dadd87 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Tue, 19 Dec 2023 15:54:40 -0800
Subject: [PATCH 1/5] [Refactoring] Add capabilities to `SymbolName` to
represent Ob
https://github.com/ahoppen updated
https://github.com/llvm/llvm-project/pull/78872
>From 26d9d1a5a342df34cde921f7d9921e7b94dadd87 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Tue, 19 Dec 2023 15:54:40 -0800
Subject: [PATCH 1/5] [Refactoring] Add capabilities to `SymbolName` to
represent Ob
https://github.com/ahoppen created
https://github.com/llvm/llvm-project/pull/78872
This adds support to rename Objective-C method declarations and calls to clangd.
>From 26d9d1a5a342df34cde921f7d9921e7b94dadd87 Mon Sep 17 00:00:00 2001
From: Alex Hoppen
Date: Tue, 19 Dec 2023 15:54:40 -0800
Su
40 matches
Mail list logo