本文整理汇总了Java中com.intellij.codeInsight.template.Template.getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java Template.getDefaultValue方法的具体用法?Java Template.getDefaultValue怎么用?Java Template.getDefaultValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.codeInsight.template.Template
的用法示例。
在下文中一共展示了Template.getDefaultValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resetFrom
import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
public void resetFrom(TemplateImpl another) {
removeAllParsed();
toParseSegments = another.toParseSegments;
myKey = another.getKey();
myString = another.myString;
myTemplateText = another.myTemplateText;
myGroupName = another.myGroupName;
myId = another.myId;
myDescription = another.myDescription;
myShortcutChar = another.myShortcutChar;
isToReformat = another.isToReformat;
isToShortenLongNames = another.isToShortenLongNames;
myIsInline = another.myIsInline;
myTemplateContext = another.myTemplateContext.createCopy();
isDeactivated = another.isDeactivated;
for (Property property : Property.values()) {
boolean value = another.getValue(property);
if (value != Template.getDefaultValue(property)) {
setValue(property, value);
}
}
for (Variable variable : another.myVariables) {
addVariable(variable.getName(), variable.getExpressionString(), variable.getDefaultValueString(), variable.isAlwaysStopAt());
}
}
示例2: copy
import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@Override
public TemplateImpl copy() {
TemplateImpl template = new TemplateImpl(myKey, myString, myGroupName);
template.myId = myId;
template.myDescription = myDescription;
template.myShortcutChar = myShortcutChar;
template.isToReformat = isToReformat;
template.isToShortenLongNames = isToShortenLongNames;
template.myIsInline = myIsInline;
template.myTemplateContext = myTemplateContext.createCopy();
template.isDeactivated = isDeactivated;
for (Property property : Property.values()) {
boolean value = getValue(property);
if (value != Template.getDefaultValue(property)) {
template.setValue(property, value);
}
}
for (Variable variable : myVariables) {
template.addVariable(variable.getName(), variable.getExpressionString(), variable.getDefaultValueString(), variable.isAlwaysStopAt());
}
return template;
}
示例3: serializeTemplate
import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@NotNull
static Element serializeTemplate(@NotNull TemplateImpl template, @Nullable TemplateContext defaultContext) {
Element element = new Element(TEMPLATE);
final String id = template.getId();
if (id != null) {
element.setAttribute(ID, id);
}
element.setAttribute(NAME, template.getKey());
element.setAttribute(VALUE, template.getString());
if (template.getShortcutChar() == TAB_CHAR) {
element.setAttribute(SHORTCUT, TAB);
} else if (template.getShortcutChar() == ENTER_CHAR) {
element.setAttribute(SHORTCUT, ENTER);
} else if (template.getShortcutChar() == SPACE_CHAR) {
element.setAttribute(SHORTCUT, SPACE);
}
if (template.getDescription() != null) {
element.setAttribute(DESCRIPTION, template.getDescription());
}
element.setAttribute(TO_REFORMAT, Boolean.toString(template.isToReformat()));
element.setAttribute(TO_SHORTEN_FQ_NAMES, Boolean.toString(template.isToShortenLongNames()));
if (template.getValue(Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE)
!= Template.getDefaultValue(Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE))
{
element.setAttribute(USE_STATIC_IMPORT, Boolean.toString(template.getValue(Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE)));
}
if (template.isDeactivated()) {
element.setAttribute(DEACTIVATED, Boolean.toString(true));
}
for (int i = 0; i < template.getVariableCount(); i++) {
Element variableElement = new Element(VARIABLE);
variableElement.setAttribute(NAME, template.getVariableNameAt(i));
variableElement.setAttribute(EXPRESSION, template.getExpressionStringAt(i));
variableElement.setAttribute(DEFAULT_VALUE, template.getDefaultValueStringAt(i));
variableElement.setAttribute(ALWAYS_STOP_AT, Boolean.toString(template.isAlwaysStopAt(i)));
element.addContent(variableElement);
}
try {
Element contextElement = new Element(CONTEXT);
template.getTemplateContext().writeTemplateContext(contextElement, defaultContext);
element.addContent(contextElement);
} catch (WriteExternalException ignore) {
}
return element;
}
示例4: saveTemplate
import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
private void saveTemplate(TemplateImpl template, Element templateSetElement) {
Element element = new Element(TEMPLATE);
final String id = template.getId();
if (id != null) {
element.setAttribute(ID, id);
}
element.setAttribute(NAME, template.getKey());
element.setAttribute(VALUE, template.getString());
if (template.getShortcutChar() == TAB_CHAR) {
element.setAttribute(SHORTCUT, TAB);
} else if (template.getShortcutChar() == ENTER_CHAR) {
element.setAttribute(SHORTCUT, ENTER);
} else if (template.getShortcutChar() == SPACE_CHAR) {
element.setAttribute(SHORTCUT, SPACE);
}
if (template.getDescription() != null) {
element.setAttribute(DESCRIPTION, template.getDescription());
}
element.setAttribute(TO_REFORMAT, Boolean.toString(template.isToReformat()));
element.setAttribute(TO_SHORTEN_FQ_NAMES, Boolean.toString(template.isToShortenLongNames()));
if (template.getValue(Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE)
!= Template.getDefaultValue(Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE))
{
element.setAttribute(USE_STATIC_IMPORT, Boolean.toString(template.getValue(Template.Property.USE_STATIC_IMPORT_IF_POSSIBLE)));
}
if (template.isDeactivated()) {
element.setAttribute(DEACTIVATED, Boolean.toString(true));
}
for (int i = 0; i < template.getVariableCount(); i++) {
Element variableElement = new Element(VARIABLE);
variableElement.setAttribute(NAME, template.getVariableNameAt(i));
variableElement.setAttribute(EXPRESSION, template.getExpressionStringAt(i));
variableElement.setAttribute(DEFAULT_VALUE, template.getDefaultValueStringAt(i));
variableElement.setAttribute(ALWAYS_STOP_AT, Boolean.toString(template.isAlwaysStopAt(i)));
element.addContent(variableElement);
}
try {
Element contextElement = new Element(CONTEXT);
TemplateImpl def = getDefaultTemplate(template);
template.getTemplateContext().writeTemplateContext(contextElement, def == null ? null : def.getTemplateContext());
element.addContent(contextElement);
} catch (WriteExternalException ignore) {
}
templateSetElement.addContent(element);
}