Re: [swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-03-24 Thread Jean-Pierre Simard via swift-dev
I ended up writing some convenience APIs to perform these conversions along
with many other useful SourceKit<->Cocoa conversions like line+column,
UTF-8, UTF-16 and String.Index in SourceKitten. It's MIT-licensed so feel
free to grab the String extensions from the project yourself:
https://github.com/jpsim/SourceKitten/blob/master/Source/SourceKittenFramework/String+SourceKitten.swift

That being said, you might have an easier time working with SourceKitten
than with with SourceKit directly, since it does a whole lot more, like
dynamically resolving+loading which SourceKit to use, caching expensive
operations, easier multi-threaded access, generating documentation, etc.

On Fri, 24 Mar 2017 at 10:59 Tyler Stromberg via swift-dev <
swift-dev@swift.org> wrote:

> I'm currently working on integrating SourceKit with a macOS application.
> AppKit APIs (e.g. NSAttributedString, NSLayoutManager, etc) deal in terms
> of NSRange (UTF-16 code units?). SourceKit, however, deals in terms of
> integer offsets and lengths (UTF-8 code units?). Is there a more efficient
> or easier way to convert back and forth between the two other than doing
> the index(_:offsetBy:) -> samePosition(in:) dance?
> ___
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev
>
___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


Re: [swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-03-24 Thread Ben Langmuir via swift-dev

> On Mar 24, 2017, at 10:59 AM, Tyler Stromberg via swift-dev 
>  wrote:
> 
> I'm currently working on integrating SourceKit with a macOS application. 
> AppKit APIs (e.g. NSAttributedString, NSLayoutManager, etc) deal in terms of 
> NSRange (UTF-16 code units?). SourceKit, however, deals in terms of integer 
> offsets and lengths (UTF-8 code units?).

UTF8 byte offsets

> Is there a more efficient or easier way to convert back and forth between the 
> two other than doing the index(_:offsetBy:) -> samePosition(in:) dance?

If you’re doing a bunch of queries in the same file, you could build a table of 
line start offsets in both UTF8 and UTF16 you may get faster results by going 
UTF8 offset -> UTF8 line + delta -> UTF16 line + delta -> UTF16 offset. Since 
then the expensive part is O(line length) instead of O(file size).

I don’t know of a good canned solution.

> ___
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


[swift-dev] [SourceKit] NSRange, Swift.String, and NSString

2017-03-24 Thread Tyler Stromberg via swift-dev

I'm currently working on integrating SourceKit with a macOS application. AppKit 
APIs (e.g. NSAttributedString, NSLayoutManager, etc) deal in terms of NSRange 
(UTF-16 code units?). SourceKit, however, deals in terms of integer offsets and 
lengths (UTF-8 code units?). Is there a more efficient or easier way to convert 
back and forth between the two other than doing the index(_:offsetBy:) -> 
samePosition(in:) dance?
___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


Re: [swift-dev] [Swift CI] Build Failure: 0. OSS - Swift Incremental RA - OS X (master) #9017

2017-03-24 Thread Xi Ge via swift-dev
This seems to be fixed in the next build. I’ve integrated the radar.

Xi

> On Mar 23, 2017, at 8:46 PM, Slava Pestov  wrote:
> 
> I thought this was my changes but then it cleared up on the next build.
> 
> Xi, I filed rdar://31234811  with some information. Since 
> you’re the build czar can you keep an eye on this bot and see if this test 
> fails again?
> 
> Slava
> 
>> On Mar 23, 2017, at 8:32 PM, no-re...@swift.org  
>> wrote:
>> 
>> [FAILURE] oss-swift-incremental-RA-osx [#9017]
>> 
>> Build URL:   https://ci.swift.org/job/oss-swift-incremental-RA-osx/9017/ 
>> 
>> Project: oss-swift-incremental-RA-osx
>> Date of build:   Thu, 23 Mar 2017 20:10:41 -0700
>> Build duration:  21 min
>> Identified problems:
>> 
>> Regression test failed: This build failed because a regression test in the 
>> test suite FAILed. Below is a list of all errors:
>> Indication 1 
>> 
>> Tests:
>> 
>> Name: Swift(macosx-x86_64)
>> Failed: 1 test(s), Passed: 9095 test(s), Total: 9096 test(s)
>> Failed: 
>> Swift(macosx-x86_64).stdlib/Slice.Slice_Of_MinimalCollection_WithPrefix.swift
>>  
>> 
>> Name: Swift-Unit
>> Failed: 0 test(s), Passed: 476 test(s), Total: 476 test(s)
>> 
>> Changes
>> 
>> Commit 38f27c04964f0ed4ce7da7701e499fce16c5c929 by Slava Pestov:
>> Sema: Always add synthesized accessors in the same spot
>> 
>> edit: test/SILGen/guaranteed_self.swift
>> edit: test/SILGen/specialize_attr.swift
>> edit: test/SILGen/materializeForSet.swift
>> edit: lib/Sema/CodeSynthesis.cpp
>> edit: test/DebugInfo/generic_enum_closure.swift
>> edit: test/SILGen/addressors.swift
>> edit: test/SILGen/ivar_destroyer.swift
>> edit: test/IRGen/class_resilience.swift
>> edit: test/SILGen/dynamic.swift
>> 
>> Commit c94e6b8a5e36039be1d7f25e5e853eca48f0b697 by Slava Pestov:
>> SIL: Add new SILVTableVisitor
>> 
>> add: include/swift/SIL/SILVTableVisitor.h
>> 
>> Commit b42675c2352017b698c6e4ed01368b9988a5d3f4 by Slava Pestov:
>> IRGen: Use SILVTableVisitor instead of bespoke member traversal
>> 
>> edit: lib/IRGen/GenMeta.cpp
>> edit: lib/IRGen/ClassMetadataLayout.h
>> edit: lib/IRGen/GenMeta.h
>> 
>> Commit 1a9fe1fb7405ed4846f66a1a612875bd45507372 by Slava Pestov:
>> SILGen: Use SILVTableVisitor instead of bespoke member traversal
>> 
>> edit: test/SILGen/errors.swift
>> edit: test/SILGen/ivar_destroyer.swift
>> edit: test/SILGen/dynamic.swift
>> edit: test/SILGen/functions.swift
>> edit: test/SILGen/final.swift
>> edit: lib/SIL/SILDeclRef.cpp
>> edit: test/DebugInfo/initializer.swift
>> edit: test/SILGen/sil_locations_top_level.swift
>> edit: test/SILGen/objc_attr_NSManaged.swift
>> edit: lib/SILGen/SILGenType.cpp
>> edit: test/SILGen/lifetime.swift
>> edit: test/SILGen/SILDeclRef.swift
>> edit: test/SILGen/complete_object_init.swift
> 

___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev


Re: [swift-dev] [Swift CI] Build Still Failing: 0. OSS - Swift Incremental RA - OS X (swift 4.0) #27

2017-03-24 Thread Alex L via swift-dev
My bad, I forgot a cherry-pick. Should be fixed now.

On 24 March 2017 at 10:29,  wrote:

> New issue found!
> [FAILURE] oss-swift-4.0-incremental-RA-osx [#27]
> Build URL: https://ci.swift.org/job/oss-swift-4.0-incremental-RA-osx/27/
> Project: oss-swift-4.0-incremental-RA-osx
> Date of build: Fri, 24 Mar 2017 03:19:24 -0700
> Build duration: 10 min Identified problems:
>
>- Compile Error: This build failed because of a compile error. Below
>is a list of all errors in the build log:
>   - Indication 1
>   
> 
>
>
> Changes
>
>- Commit *08142cb734b8d2cefec8b1629f6bb170b3f94610* by *Tom Stellard:*
>
>Bump version to 4.0.1
>- *edit*: CMakeLists.txt
>
>- Commit *b683107a4016be84aec3a1c06c1c3a66ae4ab4c8* by *Alex Lorenz:*
>
>[ObjC][ARC] Avoid -Warc-performSelector-leaks for performSelector
>- *edit*: test/SemaObjC/arc-peformselector.m
>   - *edit*: lib/AST/DeclObjC.cpp
>   - *edit*: lib/Sema/SemaExprObjC.cpp
>
>- Commit *faa24a9d90e0958af9bd1d1e859e24f24a032cfb* by *Alex Lorenz:*
>
>Support attributes for Objective-C categories
>- *edit*: include/clang/Sema/Sema.h
>   - *edit*: test/SemaObjC/warn-deprecated-implementations.m
>   - *edit*: lib/Sema/SemaDeclObjC.cpp
>   - *edit*: test/SemaObjC/default-synthesize-3.m
>   - *add*: test/SemaObjC/category-attribute.m
>   - *edit*: include/clang/Basic/DiagnosticParseKinds.td
>   - *edit*: lib/Parse/ParseObjc.cpp
>   - *edit*: test/SemaObjC/attr-deprecated.m
>
>- Commit *ee01916422394b8b1a7f705bdaef7cb7d7ec01da* by *Alex Lorenz:*
>
>[CodeGen] Emit a CoreFoundation link guard when @available is used
>- *add*: test/CodeGenObjC/availability-cf-link-guard.m
>   - *edit*: lib/CodeGen/CGObjC.cpp
>   - *edit*: lib/CodeGen/CodeGenModule.cpp
>   - *edit*: lib/CodeGen/CodeGenModule.h
>
>
>
>
___
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev