Repository: intellij-rust/intellij-rust
Issue: Moving a file with a relative path in a macro removes quotes

## Environment

* **Intellij-Rust plugin version:** 25 Dec 2018
* **Rust toolchain version:** Latest (1.31.1)
* **IDE name and version:** Pycharm 2018.3
* **Operating system:** MacOS

## Problem description

Moving a file with a relative path in a string seems to strip the quotes

## Steps to reproduce

Create a `src/main.rs` file with this:

`static TEMPLATE: &[u8] = include_bytes!("template.html");`

Now, move `src/main.rs` to `src/bin/main.rs`. You will see that the line above becomes:

`static TEMPLATE: &[u8] = include_bytes!(../template.html);`

Notice the quotes are now missing.

Changed files:
src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt, src/main/kotlin/org/rust/ide/injected/RsStringLiteralManipulator.kt

diff --git a/src/main/kotlin/org/rust/ide/injected/RsStringLiteralManipulator.kt b/src/main/kotlin/org/rust/ide/injected/RsStringLiteralManipulator.kt
index e1d108763..931fafba7 100644
--- a/src/main/kotlin/org/rust/ide/injected/RsStringLiteralManipulator.kt
+++ b/src/main/kotlin/org/rust/ide/injected/RsStringLiteralManipulator.kt
@@ -9,6 +9,7 @@ import com.intellij.openapi.util.TextRange
 import com.intellij.psi.AbstractElementManipulator
 import org.rust.lang.core.psi.RsLitExpr
 import org.rust.lang.core.psi.RsLiteralKind
+import org.rust.lang.core.psi.RsPsiFactory
 import org.rust.lang.core.psi.kind
 
 class RsStringLiteralManipulator : AbstractElementManipulator<RsLitExpr>() {
@@ -17,8 +18,12 @@ class RsStringLiteralManipulator : AbstractElementManipulator<RsLitExpr>() {
             // FIXME not supported for now
             return element
         }
-        element.updateText(newContent)
-        return element
+
+        val oldText = element.text
+        val newText = "${oldText.substring(0, range.startOffset)}$newContent${oldText.substring(range.endOffset)}"
+
+        val newLitExpr = RsPsiFactory(element.project).createExpression(newText)
+        return element.replace(newLitExpr) as RsLitExpr
     }
 
     override fun getRangeInElement(element: RsLitExpr): TextRange {
diff --git a/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt b/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt
index c32759bff..ff312430b 100644
--- a/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt
+++ b/src/test/kotlin/org/rust/ide/refactoring/RenameTest.kt
@@ -239,6 +239,38 @@ class RenameTest : RsTestBase() {
         }
     """)
 
+    fun `test handle file references in include macro`() = checkByDirectory("""
+        //- main.rs
+            include!("foo.rs");
+        //- foo.rs
+            fn foo() {}
+    """, """
+        //- main.rs
+            include!("bar.rs");
+        //- bar.rs
+            fn foo() {}
+    """) {
+        val file = myFixture.configureFromTempProjectFile("foo.rs")
+        myFixture.renameElement(file, "bar.rs")
+    }
+
+    fun `test handle file references in path attribute`() = checkByDirectory("""
+        //- main.rs
+            #[path = "foo.rs"]
+            mod baz;
+        //- foo.rs
+            fn foo() {}
+    """, """
+        //- main.rs
+            #[path = "bar.rs"]
+            mod baz;
+        //- bar.rs
+            fn foo() {}
+    """) {
+        val file = myFixture.configureFromTempProjectFile("foo.rs")
+        myFixture.renameElement(file, "bar.rs")
+    }
+
     private fun doTest(
         newName: String,
         @Language("Rust") before: String,