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

Swift file could not be parsed #18

Closed
emaloney opened this issue Jan 2, 2015 · 10 comments
Closed

Swift file could not be parsed #18

emaloney opened this issue Jan 2, 2015 · 10 comments

Comments

@emaloney
Copy link

emaloney commented Jan 2, 2015

Hello,

I am opening this ticket in response to a new error encountered while using the jazzy documentation generator:

"BasicDeepLinkSupportConfiguration.swift could not be parsed. Please open an issue at https://github.com/jpsim/sourcekitten/issues with the file contents."

So, as requested, that's what I'm doing. :)

The content of the file in question is:

//
//  BasicDeepLinkSupportConfiguration.swift
//  Gilt Cleanroom
//
//  Created by Evan Maloney on 1/2/15.
//  Copyright (c) 2015 Gilt Groupe. All rights reserved.
//

import Foundation

/**
A `DeepLinkRouterConfiguration` that provides basic support for handling
deep links. It enables default support for creating view controllers from
deep links, and displaying those view controllers onscreen in an appropriate
way. In addition, this adds support for handling deep links that are only
intended to activate the app.
*/
public class BasicDeepLinkSupportConfiguration: DeepLinkRouterConfigurationImpl
{
    /**
    The initializer.
    */
    override public init()
    {
        super.init()
        displayOptionsFactories = [DefaultDeepLinkDisplayOptionsFactory()]
        navigators = [DeepLinkActivateNavigator(), DeepLinkViewControllerNavigator()]
    }
}

I'm encountering this error using jazzy 0.0.19 and 0.0.20.

Please let me know if there's more information I can provide that will be helpful.

Thanks!
Evan

@jpsim
Copy link
Owner

jpsim commented Jan 2, 2015

Thanks for filing this, @emaloney. Does your project build successfully when running xcodebuild in the command line? If xcodebuild needs additional arguments to build your target, you should pass those arguments to sourcekitten. For example, sourcekitten -workspace Gilt.xcworkspace -scheme Gilt.

@jpsim
Copy link
Owner

jpsim commented Jan 2, 2015

It seems to work for me when I run the following:

sourcekitten --single-file `pwd`/BasicDeepLinkSupportConfiguration.swift -j4 `pwd`/BasicDeepLinkSupportConfiguration.swift

Can you try that from your end?

@emaloney
Copy link
Author

emaloney commented Jan 2, 2015

Yes, if I just do a plain old xcodebuild from the command line—with no arguments—the build succeeds.

I am also invoking jazzy with no arguments.

FWIW, I'm using an .xcodeproj with just one build scheme and two targets: the app itself, and the unit test target.

@jpsim
Copy link
Owner

jpsim commented Jan 2, 2015

Since I can't reproduce with just the file, I'll need access to the full project to help troubleshoot, unfortunately.

We could also screenshare if you can't send me the full source.

Alternatively, you could troubleshoot on your end by running sourcekitten in a debug session in Xcode. But that's actually bit complex to explain how to do properly since sourcekitten will spawn a new process for each file.

@emaloney
Copy link
Author

emaloney commented Jan 2, 2015

I don't have sourcekitten installed as stand-alone code; in my case it is being invoked via jazzy.

I will install it and try --single-file parsing. Will let you know.

@emaloney
Copy link
Author

emaloney commented Jan 2, 2015

Below is what I get when I run sourcekitten against that file using --single-file; doesn't look like I'm getting an error.

However, if I run sourcekitten against the codebase as a whole, I do get the same error message that caused me to open this issue in the first place.

{
  "key.substructure" : [
    {
      "key.kind" : "source.lang.swift.decl.class",
      "key.offset" : 530,
      "key.attributes" : [
        {
          "key.attribute" : "source.decl.attribute.private"
        },
        {
          "key.attribute" : "source.decl.attribute.__raw_doc_comment"
        }
      ],
      "key.nameoffset" : 536,
      "key.namelength" : 33,
      "key.inheritedtypes" : [
        {
          "key.name" : "DeepLinkRouterConfigurationImpl"
        }
      ],
      "key.bodylength" : 258,
      "key.runtime_name" : "_TtC8__main__33BasicDeepLinkSupportConfiguration",
      "key.substructure" : [
        {
          "key.kind" : "source.lang.swift.decl.function.method.instance",
          "key.offset" : 661,
          "key.attributes" : [
            {
              "key.attribute" : "source.decl.attribute.private"
            },
            {
              "key.attribute" : "source.decl.attribute.override"
            },
            {
              "key.attribute" : "source.decl.attribute.__raw_doc_comment"
            }
          ],
          "key.nameoffset" : 661,
          "key.namelength" : 6,
          "key.bodyoffset" : 673,
          "key.bodylength" : 187,
          "key.length" : 200,
          "key.substructure" : [

          ],
          "key.name" : "init()"
        }
      ],
      "key.name" : "BasicDeepLinkSupportConfiguration",
      "key.length" : 333,
      "key.bodyoffset" : 604
    }
  ],
  "key.offset" : 0,
  "key.diagnostic_stage" : "source.diagnostic.stage.swift.parse",
  "key.length" : 864
}

@emaloney
Copy link
Author

emaloney commented Jan 2, 2015

I will see if I can whittle down the issue to a subset of our source tree in hopes of pinpointing the problem.

If I can get it to a small enough set of code to share, I will send it along. Otherwise, I appreciate your offer of screensharing and may have to take you up on it.

I'll be away for the remainder of the weekend, but will look into this again early next week.

Thanks for your help, and for your contributions to jazzy. It's great having a modern option for generating amazing-looking documentation!

@emaloney
Copy link
Author

emaloney commented Jan 5, 2015

Hi JP,

I've just e-mailed you with some more information to reproduce the issue. I've narrowed the problem down to a specific line.

E.

@jpsim
Copy link
Owner

jpsim commented Jan 5, 2015

Thanks for the email and the help troubleshooting, @emaloney!

I managed to identify the issue and pushed a fix in 7f55237. This is now merged into jazzy in the master branch, which will be included in the next release.

@jpsim jpsim closed this as completed Jan 5, 2015
@jpsim
Copy link
Owner

jpsim commented Jan 5, 2015

What's neat is that this bug never would have happened if Array subscript returned an optional, since it would have enforced proper "bounds checking".

SteffenL pushed a commit to SteffenL/SourceKitten that referenced this issue Feb 13, 2019
Add features to misc_jazzy_features fixture for testing documentation…
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

No branches or pull requests

2 participants