mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Extract method
This commit is contained in:
+1
-1
@@ -259,7 +259,7 @@ class EditVariableDialog extends DialogWrapper {
|
||||
Variable variable = myVariables.get(row);
|
||||
if (col == 0) {
|
||||
String varName = (String) aValue;
|
||||
if (TemplateImplUtil.parseVariables("$" + varName + "$").containsKey(varName)) {
|
||||
if (TemplateImplUtil.isValidVariableName(varName)) {
|
||||
Variable newVar = new Variable(varName, variable.getExpressionString(), variable.getDefaultValueString(),
|
||||
variable.isAlwaysStopAt());
|
||||
myVariables.set(row, newVar);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,15 +29,15 @@ public class TemplateImplUtil {
|
||||
TemplateTextLexer lexer = new TemplateTextLexer();
|
||||
lexer.start(text);
|
||||
|
||||
while(true){
|
||||
while (true) {
|
||||
IElementType tokenType = lexer.getTokenType();
|
||||
if (tokenType == null) break;
|
||||
int start = lexer.getTokenStart();
|
||||
int end = lexer.getTokenEnd();
|
||||
String token = text.subSequence(start, end).toString();
|
||||
if (tokenType == TemplateTokenType.VARIABLE){
|
||||
if (tokenType == TemplateTokenType.VARIABLE) {
|
||||
String name = token.substring(1, token.length() - 1);
|
||||
if (!variables.containsKey(name)){
|
||||
if (!variables.containsKey(name)) {
|
||||
variables.put(name, new Variable(name, "", "", true));
|
||||
}
|
||||
}
|
||||
@@ -45,4 +45,8 @@ public class TemplateImplUtil {
|
||||
}
|
||||
return variables;
|
||||
}
|
||||
|
||||
public static boolean isValidVariableName(String varName) {
|
||||
return parseVariables("$" + varName + "$").containsKey(varName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user