-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Swift: Handle interpolating and non-interpolating strings.
- Loading branch information
Showing
9 changed files
with
189 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/io/err0/client/languages/ext/SwiftExtendedInformation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.err0.client.languages.ext; | ||
|
||
import io.err0.client.core.Token; | ||
import io.err0.client.core.TokenExtendedInformation; | ||
import io.err0.client.core.TokenType; | ||
|
||
public class SwiftExtendedInformation implements TokenExtendedInformation { | ||
|
||
public SwiftExtendedInformation(Token token) { | ||
this.token = token; | ||
} | ||
|
||
final Token token; | ||
|
||
public boolean nonInterpolating = false; | ||
|
||
@Override | ||
public String getStringLiteral() { | ||
String s = null != token.sourceNoErrorCode ? token.sourceNoErrorCode : token.source; | ||
if (null == s) return null; | ||
return s.length() > 1 ? s.substring(this.getStringQuoteWidth(), s.length() - 1) : ""; | ||
} | ||
|
||
@Override | ||
public int getStringQuoteWidth() { | ||
return (nonInterpolating ? 1 : 0) + (token.type == TokenType.QUOT3_LITERAL ? 3 : 1); | ||
} | ||
|
||
@Override | ||
public Token getToken() { | ||
return token; | ||
} | ||
|
||
@Override | ||
public boolean escapeErrorCode() { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters