Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: inner types without file should not crash Environment#report #4998

Merged
merged 4 commits into from
Nov 16, 2022

Conversation

MartinWitt
Copy link
Collaborator

@MartinWitt MartinWitt commented Nov 4, 2022

fixes #4997

@MartinWitt MartinWitt changed the title fix: inner types without file should not crash Environment#report wip: fix: inner types without file should not crash Environment#report Nov 4, 2022
Copy link
Collaborator

@I-Al-Istannen I-Al-Istannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some preliminary thoughts

// TODO: will explode if type == null
buffer.append(" at " + type.getQualifiedName() + ".");
if (type != null) {
buffer.append(" at " + type.getQualifiedName() + ".");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buffer.append(" at " + type.getQualifiedName() + ".");
buffer.append(" at ").append(type.getQualifiedName()).append(".");

If you already have a buffer I'd use its append method instead of string concatenation inside the argument.

CtExecutable<?> exe = (element instanceof CtExecutable) ? (CtExecutable<?>) element : element.getParent(CtExecutable.class);
if (exe != null) {
buffer.append(exe.getSimpleName());
}
buffer.append("(" + sp.getFile().getName() + ":" + sp.getLine() + ")");
if (sp.getFile() != null) {
buffer.append("(" + sp.getFile().getName() + ":" + sp.getLine() + ")");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
buffer.append("(" + sp.getFile().getName() + ":" + sp.getLine() + ")");
buffer.append("(").append(sp.getFile().getName()=.append(":").append(sp.getLine()).append(")");

@MartinWitt MartinWitt changed the title wip: fix: inner types without file should not crash Environment#report review: fix: inner types without file should not crash Environment#report Nov 5, 2022
Copy link
Collaborator

@I-Al-Istannen I-Al-Istannen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a small formatting issue

src/test/java/spoon/test/logging/LogTest.java Outdated Show resolved Hide resolved
@I-Al-Istannen I-Al-Istannen changed the title review: fix: inner types without file should not crash Environment#report fix: inner types without file should not crash Environment#report Nov 16, 2022
@I-Al-Istannen I-Al-Istannen merged commit fdcf4d6 into master Nov 16, 2022
@I-Al-Istannen I-Al-Istannen deleted the fix/issue4997 branch November 16, 2022 19:39
@monperrus monperrus mentioned this pull request Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Environment.report(...) throws NullPointerException
2 participants