Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Xcode: emitted warnings won't highlight character/column #3

Closed
jhauberg opened this issue Jan 24, 2018 · 2 comments
Closed

Xcode: emitted warnings won't highlight character/column #3

jhauberg opened this issue Jan 24, 2018 · 2 comments
Labels
investigate Needs investigation to proceed

Comments

@jhauberg
Copy link
Owner

jhauberg commented Jan 24, 2018

I've been unable to get Xcode to properly highlight the proper parts of text indicated by an emitted warning.

For example, this is a warning that is treated and displayed as a warning in Xcode. However, it has both line and column index, but it seems the character index is being ignored completely.

So, raw output from comply:

/absolute/path/to/src/model/deck.c:9:22: warning: Unused symbol 'ceil' should not be listed as needed. [symbol-listed-not-needed]

This is what you get if you 'copy' the displayed warning from the build log:

/absolute/path/to/src/model/deck.c:9: Unused symbol 'ceil' should not be listed as needed. [symbol-listed-not-needed]

Notice how the warning: and column index has been stripped.

I've also tried emulating warnings/errors as reported by the compiler, which could look like:

/absolute/path/to/src/model/deck.c:29:5: error: use of undeclared identifier 'what'
    what
    ^

In Xcode, above looks like:

screen shot 2018-01-24 at 10 53 22

Notice the little red line under 'w'.

Now, if you take above generated error and put it into a run script:

echo "/absolute/path/to/src/model/deck.c:29:5: error: use of undeclared identifier 'what'"
echo "    what"
echo "    ^"
exit 1

Suddenly, only the line is being highlighted:

screen shot 2018-01-24 at 11 02 40

So I guess perhaps this is a security measure that won't let scripts do all that jazz?

EDIT:
So i've just tried making a fresh Xcode command-line project, and surprisingly, it actually works as expected:

screen shot 2018-01-24 at 11 10 56



Still haven't figured out how to add fix-it bubbles or underline parts (e.g. using `~~~` and `^`).

Again, emulating output as seen from compiler does not seem to work, e.g.:

```
/long/path/to/file.swift:57:17: warning: initialization of variable 'x' was never used; consider replacing with assignment to '_' or removing it
            var x = 0
            ~~~~^
            _
```

Emulated for fresh project:

```
echo "/full/path/main.c:13:1: warning: Replace int with var"
echo "int main(int argc, const char * argv[]) {"
echo "^~~"
echo "var"
```

This just shows a regular old warning, ignoring underlining and fix-it option:

![screen shot 2018-01-24 at 11 50 49](https://user-images.githubusercontent.com/1360637/35328511-e4e82526-00fc-11e8-902e-6c73e25c13db.png)

Again, i'm uncertain that scripts are even allowed to do this. But who knows?

Related, changing build system from standard to preview also cause character index to be ignored:

![screen shot 2018-01-24 at 11 55 32](https://user-images.githubusercontent.com/1360637/35328742-a389f964-00fd-11e8-9ccc-837a346b339e.png)
![screen shot 2018-01-24 at 11 55 22](https://user-images.githubusercontent.com/1360637/35328752-addf5602-00fd-11e8-99d9-5ad3988df461.png)
@jhauberg jhauberg added bug Something isn't working investigate Needs investigation to proceed and removed bug Something isn't working labels Jan 24, 2018
@jhauberg
Copy link
Owner Author

jhauberg commented Jan 24, 2018

@jhauberg
Copy link
Owner Author

It's unlikely that we can do more about this. Fix-Its and underlining is likely always going to be reserved for the built-in processes (compiler, analyzer) in Xcode.

The ClangReporter could be extended to support this stuff, and it may be worthwhile for other IDEs/editors (SublimeText?), but for now i'm closing this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
investigate Needs investigation to proceed
Projects
None yet
Development

No branches or pull requests

1 participant