Commit d91675f
committed
#66: Resolve imports relative to file's location
Part II: resolve relative import references (first part was
about type references).
Legend:
Many projects are storing proto files in a locations that are not marked as source/resource root.
As a result, imports are highlighted with error "file does not exist", and all imported types are not resolvable.
Plugin can try to resolve imports relative to source file's location using following rules:
1. If `package` is not set, try to look in the same folder where source file is.
2. If package is set, try to look from parent folder.
3. Parent folder should be computed as source file's folders, with removed corresponding parts of the package.
For example:
`/home/user/project/foo/bar/hello.proto`:
```proto
package foo.bar;
import "baz/import.proto";
```
Import should be resolved to `/home/user/project/baz/import.proto`.1 parent 0ee75f2 commit d91675f
File tree
3 files changed
+29
-2
lines changed- src
- main/java/io/protostuff/jetbrains/plugin/reference/file
- test
- java/io/protostuff/jetbrains/plugin/reference
- resources/reference/relative/import
3 files changed
+29
-2
lines changedLines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
105 | 110 | | |
106 | 111 | | |
107 | 112 | | |
| |||
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
135 | | - | |
| 140 | + | |
136 | 141 | | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
140 | | - | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
57 | 70 | | |
58 | 71 | | |
59 | 72 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments