Giter VIP home page Giter VIP logo

Comments (8)

markohlebar avatar markohlebar commented on May 22, 2024

There are a couple of problems there... The API for Xcode 8 Source Code Extension is still pretty limited. I think it could be pretty hard to determine the context of the source file you're looking at in Xcode as in:

  • it's full path
  • the project it is related to

However, if you could just feed Sourcery with text and make something out of that, it might work. I'll try to remember what we were brainstorming for Import extension, I think there was some stuff that could help. @clementpadovani @velyan

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

I was thinking of just feeding the text to the tool, since we usually need only local context for snippets, if we wanted full AST then we could write regular plugin but that requires people to unsign Xcode so better to limit it to native extension. Looking forward to hearing your experiences with it, I didn't had a chance to write the native extensions yet :)

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

Do we have access to darwin notifications in extensions? If we do we could potentially use that to communicate between the app and extension, sourcery can run it's parsing on text as it does in tests

from sourcery.

ikesyo avatar ikesyo commented on May 22, 2024

FYI jpsim/SourceKitten#271

from sourcery.

conradev avatar conradev commented on May 22, 2024

Darwin notifications only have a single uint64_t state variable to communicate information. What does the sandbox profile for a source editor extension roughly look like?

from sourcery.

ilyapuchka avatar ilyapuchka commented on May 22, 2024

So I've just made a simple prototype to work thanks to to the link from @ikesyo There are still few limitations, like extension not being provided with any kind of project info except currently opened file's content, or not being able to access any files out if it's container. But to make it work just for currently opened file will be possible in short time.

But there are few more things to solve here. Like accessing templates. As extension can not access anything outside it's container (which is ~/Library/Containers/extension.bundle.id/Data) it will be impossible to discover any template unless they are copied into this folder. This could be a simple task to solve just with a special cli command that would do that. When templates are copied extension can provide a menu item for each of them.

Going forward we could make an app (extension requires an app anyway) to manage templates, maybe even with a simple editor functionality.

And to make the extension really powerful we would need to give it access to Sourcery cache (again copying it to the container) that would be constantly updated in the background using some demon process maybe. Though this looks pretty complex and maybe it would be better to wait for the next version of Xcode if there would be any improvements for extensions from Apple.

The other way is to simply write a path to the sources to scan into extension container directory and scan them on each extension run using XPC service for Sourcery itself, instead of SourceKitten which I implemented now. This will also require to provide Sourcery functionality via framework ala SourceKittenFramework.

@krzysztofzablocki what do you think?

from sourcery.

krzysztofzablocki avatar krzysztofzablocki commented on May 22, 2024

I'd reckon we should wait for next Xcode version and see what they provide there, rather than complicating the tool too much, especially now that we have inline generation

from sourcery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.