当前位置: 首页>>代码示例>>Java>>正文


Java Template.getDefaultValue方法代码示例

本文整理汇总了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());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TemplateImpl.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:TemplateImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:TemplateSettings.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:48,代码来源:TemplateSettings.java


注:本文中的com.intellij.codeInsight.template.Template.getDefaultValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。