/*
   Copyright 2017 Ryuichi Laboratories and the Yanagiba project contributors

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

import Foundation

import Source
import Bocho

extension SourceRange {
  var normalizedLocation: String {
    return "\(normalizedFilePath):\(startLineColumn)-\(endLineColumn)"
  }

  var normalizedFilePath: String {
    return start.identifier.truncatedPath
  }

  var startLineColumn: String {
    return "\(start.line):\(start.column)"
  }

  var endLineColumn: String {
    return "\(end.line):\(end.column)"
  }
}

/*
   Copyright 2017 Ryuichi Laboratories and the Yanagiba project contributors

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

import Foundation

import Source

extension SourceRange {
  var normalizedLocation: String {
    return "\(normalizedFilePath):\(startLineColumn)-\(endLineColumn)"
  }

  var normalizedFilePath: String {
    let pwd = FileManager.default.currentDirectoryPath
    var filePath = start.identifier
    if filePath.hasPrefix(pwd) {
      let prefixIndex = filePath.index(filePath.startIndex, offsetBy: pwd.count+1)
      filePath = String(filePath[prefixIndex...])
    }
    return filePath
  }

  var startLineColumn: String {
    return "\(start.line):\(start.column)"
  }

  var endLineColumn: String {
    return "\(end.line):\(end.column)"
  }
}

--- 
+++ 
@@ -17,6 +17,7 @@
 import Foundation
 
 import Source
+import Bocho
 
 extension SourceRange {
   var normalizedLocation: String {
@@ -24,13 +25,7 @@
   }
 
   var normalizedFilePath: String {
-    let pwd = FileManager.default.currentDirectoryPath
-    var filePath = start.identifier
-    if filePath.hasPrefix(pwd) {
-      let prefixIndex = filePath.index(filePath.startIndex, offsetBy: pwd.count+1)
-      filePath = String(filePath[prefixIndex...])
-    }
-    return filePath
+    return start.identifier.truncatedPath
   }
 
   var startLineColumn: String {
Use Bocho method to get normalized file path
