agents/projects/code-health/java-inline-fqn-cleanup/SKILL.md
Clean up inline fully qualified names (FQNs) in Java code by replacing them with proper import statements at the top of the file, and then formatting/optimizing the import order.
Using fully qualified class names inline (e.g. android.view.View view = ...)
instead of importing them makes code harder to read and breaks standard style
conventions. This skill helps automate the discovery, safety analysis, and
clean-up of these inline qualifiers in Chromium's first-party Java files.
android.view.View view = ...View view = ... (with import android.view.View; added at top)org.chromium.build.BuildConfig.IS_CHROME_BRANDEDBuildConfig.IS_CHROME_BRANDED (with
import org.chromium.build.BuildConfig; added at top)@OptIn(markerClass = org.chromium.net.QuicOptions.Experimental.class)@OptIn(markerClass = QuicOptions.Experimental.class) (with
import org.chromium.net.QuicOptions; added at top)void foo(org.chromium.base.Callback<T> callback)void foo(Callback<T> callback) (with
import org.chromium.base.Callback; added at top)java.lang.String text = ...String text = ... (DO NOT add an import statement since
java.lang.* is implicitly imported by Java. Adding it will cause a
RedundantImport linter error.).R. (e.g., android.R.attr
or org.chromium.chrome.R.id).R classes are almost always imported (e.g.,
import org.chromium.chrome.R;). Importing a secondary R class (like
android.R) creates an unresolvable naming collision that breaks the build.
These MUST remain fully qualified.../hub/references/shared_workflows.md to ensure a clean and updated
environment.Discovery: Run the candidate discovery script from the skill's scripts/
folder:
python3 scripts/find_candidates.py
Present Candidate Batch: You MUST output the candidate batch details to the user and request confirmation to proceed. Announce the batch with exactly this format (replace with details):
../hub/references/shared_workflows.md using the branch name
cleanup-inline-imports-[component-name] (e.g.
cleanup-inline-imports-tab-ui).CRITICAL RULE: You MUST use your standard file editing tools (like
replace_file_content or multi_replace_file_content) to apply the cleanups
directly to the Java files. DO NOT create, write, or execute any custom
python or bash scripts to perform the text replacements.
For each file in the batch, apply the following cleanup rules:
Banned FQNs list, you
must completely ignore those specific FQNs. They are either raw package paths
or invalid classes, and attempting to import them will break the build.third_party/ or auto-generated directories.TabProperties), feature flags
(ChromeFeatureList), or enums (TabLaunchType), prefer importing the
class itself rather than importing its members statically.
import static org.chromium.chrome.browser.tasks.tab_management.TabProperties.IS_SELECTED;import org.chromium.chrome.browser.tasks.tab_management.TabProperties;
and use TabProperties.IS_SELECTED in the code.TabProperties.TITLE) keeps
clear context of where the constant is defined and avoids namespace
conflicts when multiple imported properties classes share the same field
names (e.g. TabProperties.TITLE vs FolderProperties.TITLE).{@link android.webkit.WebSettings} ->
{@link WebSettings}). However, never modify URLs (like https://... or
other web links) inside comments.org.chromium.chrome.browser.profiles.ProfileKey.Theme),
prefer importing the top-level outer class
(import org.chromium.chrome.browser.profiles.ProfileKey;) and referring to
it as ProfileKey.Theme in the code, rather than importing the nested class
directly.
import statement at the top of the file.git cl format to format the modified source
code and organize imports. Address any errors that are reported.../hub/references/shared_automated_review.md, using the specific
prompt overrides in references/automated_review.md. Do NOT skip this step.
Do NOT proceed to the Submission phase until the review returns PASS.Bug Tracking:
create_buganizer_issue tool with the
following properties:
[Component/Directory] directory.1456931 (Chromium > CodeHealth)["8218789"]INTERNAL_CLEANUPP2[email protected])Commit: Follow the Commit section in
../hub/references/shared_workflows.md using the following commit message
template:
[code-health] Clean up inline FQNs in [Component/Directory]
Remove inline fully qualified class names and replace them with
standard imports.
This change was generated using the skill java-inline-fqn-cleanup.
Bug: 528570333, <BugID>
Submission Pipeline: Follow the Upload to Gerrit section in
../hub/references/shared_workflows.md to handle the upload.
Workspace Reset: Switch back to main: git checkout main.
Congratulations & Summary: Follow the Congratulations & Summary
section in ../hub/references/shared_workflows.md. For this skill, the
[Specific Cleanup Details] are: