Skip to content

Add replace and deleteCharAt methods to StringBuilder and StringBuffer #1205

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
Oct 30, 2014

Conversation

l15k4
Copy link

@l15k4 l15k4 commented Oct 29, 2014

Hi, would you please merge these? Both work the same as the java.lang implementations. Thank you

@scala-jenkins
Copy link

Can one of the admins verify this patch?

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

test this please

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

@l15k4 Could you confirm that you didn't look at OpenJDK's code for this?

@l15k4
Copy link
Author

l15k4 commented Oct 29, 2014

@sjrd I looked at Oracle's JDK :-)

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

Ach. Well, that's as much a problem. We can't accept code that's been derived from any JDK because their licenses are not compatible with ours (excluding Apache Harmony). :-(

@l15k4
Copy link
Author

l15k4 commented Oct 29, 2014

What I meant was that I adhered to the "protocol/spec" these methods have :

  1. param values restrictions
  2. behavior (exclusive end,inclusive start)

Not that I have copied the code... We work with String, they work with Char Arrays

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

OK, I suppose that's fine.

I'll repeat here my comment from #1106:
Could you please sign the CLA (see #1139). I also see that your commits are under the name @viagraphs. You should configure your GitHub account so it knows that the appropriate e-mail address is attached to your account. Otherwise we can't track the CLA status.
Thanks.

@@ -67,6 +67,28 @@ class StringBuffer(private var content: String) extends CharSequence
this
}

def deleteCharAt(index: Int): StringBuffer = {
if (index < 0 || index >= content.length)
throw new IndexOutOfBoundsException("String index out of range: " + index)
Copy link
Member

Choose a reason for hiding this comment

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

_String_IndexOfBoundsException?

Copy link
Member

Choose a reason for hiding this comment

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

Only this left to address.
And then, can you squash the commits, please? Fixup commits should always be squashed.

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

That's all.

@l15k4
Copy link
Author

l15k4 commented Oct 29, 2014

Done and Done :-)

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

Done and Done :-)

Thanks!

@l15k4 l15k4 force-pushed the replace-deleteCharAt-StringBuilder branch from d21b666 to 20973bc Compare October 29, 2014 22:10
@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

LGTM

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

test this please

@scala-jenkins
Copy link

Test PASSed.
Refer to this link for build results: https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/802/

@l15k4
Copy link
Author

l15k4 commented Oct 29, 2014

Btw I have a suggestion regarding Character API, there is isLetter method not implemented because in JDK it depends on heavy java.lang.CharacterData class that it doesn't make sense to rewrite... But I think it might be done like :

val isLetterPattern = Pattern.compile("\\p{L}")
def isLetter(c: scala.Char): scala.Boolean = isLetterPattern.matcher(String.valueOf(c)).matches()

This method is heavily used, for instance parser combinators lib is pretty much broken without this method implemented... So I think that it is better to have something than nothing :-) Wdyt ? Should I make another PR or should I work it around at the third party libs ?

@sjrd
Copy link
Member

sjrd commented Oct 29, 2014

Our regexes do not support \p because they rely on JS regexes. So it's not that easy, unfortunately. See also #964 and #1201.

@scala-jenkins
Copy link

Test PASSed.
Refer to this link for build results: https://scala-webapps.epfl.ch/jenkins/job/scalajs-pr/803/

gzm0 added a commit that referenced this pull request Oct 30, 2014
Add replace and deleteCharAt methods to StringBuilder and StringBuffer
@gzm0 gzm0 merged commit d24afe0 into scala-js:master Oct 30, 2014
@l15k4
Copy link
Author

l15k4 commented Oct 30, 2014

Just a quick question regarding living on the scalajs cutting edge, is there a way to publishLocal all projects, not just the aggregated ones? Like compiler, sbtPlugin, tools etc. I just always have to manually publishLocal each one and since I'm doing that not that regularly I always forget which need to be published

@scala-jenkins
Copy link

Can one of the admins verify this patch?

@sjrd
Copy link
Member

sjrd commented Oct 30, 2014

There's no direct way because some projects need to be published against your version of Scala (the aggregates) and some always with 2.10.4 (tools and sbtPlugin).

So it's:

> ++2.11.2
> publishLocal
> ++2.10.4
> tools/publishLocal
> sbtPlugin/publishLocal

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.

4 participants