mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
use MessageFormat API to format IdentifierHelper messages (bug 225143)
This commit is contained in:
parent
805f997868
commit
427d783899
2 changed files with 14 additions and 13 deletions
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* IBM Corporation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
package org.eclipse.cdt.internal.ui.refactoring.utils;
|
||||||
|
|
||||||
|
@ -15,6 +16,8 @@ import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.KeywordSetKey;
|
import org.eclipse.cdt.core.parser.KeywordSetKey;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
|
||||||
|
@ -28,8 +31,6 @@ import org.eclipse.cdt.internal.core.parser.token.KeywordSets;
|
||||||
*/
|
*/
|
||||||
public class IdentifierHelper {
|
public class IdentifierHelper {
|
||||||
|
|
||||||
private static final String QUOTE = Messages.IdentifierHelper_quote;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param identifier to check
|
* @param identifier to check
|
||||||
* @return an instance of IdentifierResult that holds the outcome of the validation
|
* @return an instance of IdentifierResult that holds the outcome of the validation
|
||||||
|
@ -41,20 +42,20 @@ public class IdentifierHelper {
|
||||||
}
|
}
|
||||||
if(isCorrect(identifier)){
|
if(isCorrect(identifier)){
|
||||||
if(isKeyword(identifier)){
|
if(isKeyword(identifier)){
|
||||||
return new IdentifierResult(IdentifierResult.KEYWORD, QUOTE + identifier + Messages.IdentifierHelper_isKeyword);
|
return new IdentifierResult(IdentifierResult.KEYWORD, MessageFormat.format(Messages.IdentifierHelper_isKeyword, new Object[] {identifier}));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return new IdentifierResult(IdentifierResult.VALID, QUOTE + identifier + Messages.IdentifierHelper_isValid );
|
return new IdentifierResult(IdentifierResult.VALID, MessageFormat.format(Messages.IdentifierHelper_isValid, new Object[] {identifier}));
|
||||||
}
|
}
|
||||||
} else if(isLeadingADigit(identifier)){
|
} else if(isLeadingADigit(identifier)){
|
||||||
return new IdentifierResult(IdentifierResult.DIGIT_FIRST, QUOTE + identifier + Messages.IdentifierHelper_leadingDigit);
|
return new IdentifierResult(IdentifierResult.DIGIT_FIRST, MessageFormat.format(Messages.IdentifierHelper_leadingDigit, new Object[] {identifier}));
|
||||||
} else if(identifier.length() == 0){
|
} else if(identifier.length() == 0){
|
||||||
return new IdentifierResult(IdentifierResult.EMPTY, Messages.IdentifierHelper_emptyIdentifier );
|
return new IdentifierResult(IdentifierResult.EMPTY, Messages.IdentifierHelper_emptyIdentifier );
|
||||||
} else if(hasIllegalCharacters(identifier)){
|
} else if(hasIllegalCharacters(identifier)){
|
||||||
return new IdentifierResult(IdentifierResult.ILLEGAL_CHARACTER, Messages.IdentifierHelper_illegalCharacter + identifier + QUOTE);
|
return new IdentifierResult(IdentifierResult.ILLEGAL_CHARACTER, MessageFormat.format(Messages.IdentifierHelper_illegalCharacter, new Object[] {identifier}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return new IdentifierResult(IdentifierResult.UNKNOWN, QUOTE + identifier + Messages.IdentifierHelper_unidentifiedMistake);
|
return new IdentifierResult(IdentifierResult.UNKNOWN, MessageFormat.format(Messages.IdentifierHelper_unidentifiedMistake, new Object[] {identifier}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isKeyword(String identifier) {
|
private static boolean isKeyword(String identifier) {
|
||||||
|
|
|
@ -8,14 +8,14 @@
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# Institute for Software - initial API and implementation
|
# Institute for Software - initial API and implementation
|
||||||
|
# IBM Corporation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
IdentifierHelper_isKeyword=' is a keyword.
|
IdentifierHelper_isKeyword=''{0}'' is a keyword.
|
||||||
IdentifierHelper_isValid=' is valid.
|
IdentifierHelper_isValid=''{0}'' is valid.
|
||||||
IdentifierHelper_quote='
|
IdentifierHelper_leadingDigit=''{0}'' has a leading digit.
|
||||||
IdentifierHelper_leadingDigit=' has a leading digit.
|
|
||||||
IdentifierHelper_emptyIdentifier=Identifier must not be empty.
|
IdentifierHelper_emptyIdentifier=Identifier must not be empty.
|
||||||
IdentifierHelper_illegalCharacter="Illegal character found in '
|
IdentifierHelper_illegalCharacter=Illegal character found in ''{0}''.
|
||||||
IdentifierHelper_unidentifiedMistake=' contains an unidentified mistake.
|
IdentifierHelper_unidentifiedMistake=''{0}'' contains an unidentified mistake.
|
||||||
VisibilityEnum_public=public
|
VisibilityEnum_public=public
|
||||||
VisibilityEnum_protected=protected
|
VisibilityEnum_protected=protected
|
||||||
VisibilityEnum_private=private
|
VisibilityEnum_private=private
|
||||||
|
|
Loading…
Add table
Reference in a new issue