(folderAbsolutePath string, wslDollarSign bool, serviceNode *ast.MappingValueNode)
| 109 | } |
| 110 | |
| 111 | func createVolumeFileLinks(folderAbsolutePath string, wslDollarSign bool, serviceNode *ast.MappingValueNode) []protocol.DocumentLink { |
| 112 | if resolveAnchor(serviceNode.Key).GetToken().Value == "volumes" { |
| 113 | if sequence, ok := resolveAnchor(serviceNode.Value).(*ast.SequenceNode); ok { |
| 114 | links := []protocol.DocumentLink{} |
| 115 | for _, node := range sequence.Values { |
| 116 | if s, ok := resolveAnchor(node).(*ast.StringNode); ok { |
| 117 | t := s.GetToken() |
| 118 | config, err := format.ParseVolume(t.Value) |
| 119 | if err == nil && config.Type == composeTypes.VolumeTypeBind { |
| 120 | uri, path := createLocalFileLink(folderAbsolutePath, config.Source, wslDollarSign) |
| 121 | info, err := os.Stat(path) |
| 122 | if err == nil && !info.IsDir() { |
| 123 | links = append(links, protocol.DocumentLink{ |
| 124 | Range: createRange(t, len(config.Source)), |
| 125 | Target: types.CreateStringPointer(uri), |
| 126 | Tooltip: types.CreateStringPointer(path), |
| 127 | }) |
| 128 | } |
| 129 | } |
| 130 | } else if m, ok := resolveAnchor(node).(*ast.MappingNode); ok { |
| 131 | bindType := false |
| 132 | for _, value := range m.Values { |
| 133 | if resolveAnchor(value.Key).GetToken().Value == "type" && resolveAnchor(value.Value).GetToken().Value == "bind" { |
| 134 | bindType = true |
| 135 | break |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | if bindType { |
| 140 | for _, value := range m.Values { |
| 141 | if resolveAnchor(value.Key).GetToken().Value == "source" { |
| 142 | sourceToken := resolveAnchor(value.Value).GetToken() |
| 143 | uri, path := createLocalFileLink(folderAbsolutePath, sourceToken.Value, wslDollarSign) |
| 144 | info, err := os.Stat(path) |
| 145 | if err == nil && !info.IsDir() { |
| 146 | links = append(links, protocol.DocumentLink{ |
| 147 | Range: createRange(sourceToken, len(sourceToken.Value)), |
| 148 | Target: types.CreateStringPointer(uri), |
| 149 | Tooltip: types.CreateStringPointer(path), |
| 150 | }) |
| 151 | } |
| 152 | break |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | return links |
| 159 | } |
| 160 | } |
| 161 | return nil |
| 162 | } |
| 163 | |
| 164 | func createLocalFileLink(folderAbsolutePath, fsPath string, wslDollarSign bool) (uri, path string) { |
| 165 | if filepath.IsAbs(fsPath) { |
no test coverage detected