Skip to content

Fix #3349: Fix dottydoc filenames for Windows #4171

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

Merged
merged 1 commit into from
Mar 24, 2018

Conversation

smarter
Copy link
Member

@smarter smarter commented Mar 23, 2018

Many characters are forbidden in Windows filenames, mangled names are
used for classfiles so they should be safe.

Also make factories#path more efficient.

@smarter smarter requested a review from allanrenucci March 23, 2018 22:21
@smarter smarter force-pushed the fix/dottydoc-windows branch from 5f4b5f0 to ce30255 Compare March 23, 2018 22:51
def path(sym: Symbol)(implicit ctx: Context): List[String] = {
@tailrec def go(sym: Symbol, acc: List[String]): List[String] =
if (sym.isRoot)
acc
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be acc.reverse, unless you meant to change the semantics unlike described (the caller doesn't call reverse either).
This appears return a reverted list compared to earlier — since you essentially replaced xs :+ x by x :: xs.

Copy link
Member Author

Choose a reason for hiding this comment

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

no, the semantics are the same as before, a.b.c becomes List("a", "b", "c").

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, you're right, brain short-circuit.

//TODO: should not `collectMember` from `rhs` - instead: get from symbol, will get inherited members as well
ObjectImpl(o.symbol, annotations(o.symbol), name.dropRight(1), collectMembers(rhs), flags(o), path(o.symbol).init :+ name, superTypes(o))
ObjectImpl(o.symbol, annotations(o.symbol), o.name.stripModuleClassSuffix.show, collectMembers(rhs), flags(o), path(o.symbol.owner) :+ o.name.mangledString, superTypes(o))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is o.name == o.symbol.name (I tried to find out but failed)? Then path(o.symbol) would be simpler and faster. Otherwise, maybe just pass o.name.mangledString :: Nil as initial accumulator to avoid the O(N) append.

I'd also factor out map (_.mangledString) for robustness.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Many characters are forbidden in Windows filenames, mangled names are
used for classfiles so they should be safe.

Also make factories#path more efficient.
@smarter smarter force-pushed the fix/dottydoc-windows branch from ce30255 to 54ccac6 Compare March 24, 2018 13:32
Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

Otherwise. LGTM

//TODO: should not `collectMember` from `rhs` - instead: get from symbol, will get inherited members as well
ObjectImpl(o.symbol, annotations(o.symbol), name.dropRight(1), collectMembers(rhs), flags(o), path(o.symbol).init :+ name, superTypes(o))
ObjectImpl(o.symbol, annotations(o.symbol), o.name.stripModuleClassSuffix.show, collectMembers(rhs), flags(o), path(o.symbol), superTypes(o))
Copy link
Contributor

@allanrenucci allanrenucci Mar 24, 2018

Choose a reason for hiding this comment

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

I would do o.name.stripModuleClassSuffix.toString. show is for pretty printing, it might add colors

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think show adds color on names, but if we change this then there's a ton of places where this is used in dottydoc that need to be changed. I'll leave that to whoever wants to maintain dottydoc :).

@smarter smarter merged commit f021702 into scala:master Mar 24, 2018
@allanrenucci allanrenucci deleted the fix/dottydoc-windows branch March 24, 2018 13:55
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.

3 participants