| /** |
| * |
| * Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany) |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation |
| * |
| */ |
| package org.eclipse.osbp.xtext.basic.valueconverter; |
| |
| import org.antlr.runtime.Token; |
| import org.antlr.runtime.TokenSource; |
| import org.eclipse.xtext.conversion.impl.STRINGValueConverter; |
| |
| public class TRANSLATABLESTRINGValueConverter extends STRINGValueConverter { |
| |
| protected void assertTokens(String value, TokenSource tokenSource, String escapedString) { |
| if (tokenSource == null) |
| return; |
| Token token = tokenSource.nextToken(); |
| if (!escapedString.equals(token.getText())) { |
| throw createTokenContentMismatchException(value, escapedString, token); |
| } |
| if (!getRuleName().toUpperCase().equals("TRANSLATABLESTRING") && !getRuleName(token).equals("STRING")) { |
| throw createTokenTypeMismatchException(value, escapedString, token); |
| } |
| String reparsedValue = toValue(token.getText(), null); |
| if (value != reparsedValue && !value.equals(reparsedValue)) { |
| throw createTokenContentMismatchException(value, escapedString, token); |
| } |
| } |
| |
| |
| } |