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


Java Macro类代码示例

本文整理汇总了Java中com.intellij.codeInsight.template.Macro的典型用法代码示例。如果您正苦于以下问题:Java Macro类的具体用法?Java Macro怎么用?Java Macro使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Macro类属于com.intellij.codeInsight.template包,在下文中一共展示了Macro类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createMacro

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public static Macro createMacro(@NonNls String name) {
  if(myMacroTable == null) {
    init();
  }

  return myMacroTable.get(name);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MacroFactory.java

示例2: getMacros

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public static Macro[] getMacros() {
  if(myMacroTable == null) {
    init();
  }

  final Collection<Macro> values = myMacroTable.values();
  return values.toArray(new Macro[values.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:MacroFactory.java

示例3: init

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
private static void init() {
  myMacroTable = new HashMap<String, Macro>();

  for(Macro macro: Extensions.getExtensions(Macro.EP_NAME)) {
    myMacroTable.put(macro.getName(), macro);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MacroFactory.java

示例4: parseMacro

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static Expression parseMacro(Lexer lexer, String expression) {
  IElementType tokenType = lexer.getTokenType();
  String token = getString(lexer, expression);
  if (tokenType == MacroTokenType.STRING_LITERAL) {
    advance(lexer);
    return new ConstantNode(parseStringLiteral(token));
  }

  if (tokenType != MacroTokenType.IDENTIFIER) {
    LOG.info("Bad macro syntax: Not identifier: " + token);
    advance(lexer);
    return new ConstantNode("");
  }

  Macro macro = MacroFactory.createMacro(token);
  if (macro == null) {
    return parseVariable(lexer, expression);
  }

  advance(lexer);
  MacroCallNode macroCallNode = new MacroCallNode(macro);
  if (lexer.getTokenType() == null) {
    return macroCallNode;
  }

  if (lexer.getTokenType() != MacroTokenType.LPAREN) {
    return macroCallNode;
  }

  advance(lexer);
  parseParameters(macroCallNode, lexer, expression);
  if (lexer.getTokenType() != MacroTokenType.RPAREN) {
    LOG.info("Bad macro syntax: ) expected: " + expression);
  }
  advance(lexer);
  return macroCallNode;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:MacroParser.java

示例5: parseMacro

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static Expression parseMacro(Lexer lexer, String expression) {
  IElementType tokenType = lexer.getTokenType();
  String token = getString(lexer, expression);
  if (tokenType == MacroTokenType.STRING_LITERAL) {
    advance(lexer);

    return new ConstantNode(token.substring(1, token.length() - 1).replaceAll("\\\\n", "\n").
      replaceAll("\\\\r", "\r").replaceAll("\\\\t", "\t").replaceAll("\\\\f", "\f").replaceAll("\\\\(.)", "$1"));
  }

  if (tokenType != MacroTokenType.IDENTIFIER) {
    System.out.println("Bad macro syntax: Not identifier: " + token);
    advance(lexer);
    return new ConstantNode("");
  }

  Macro macro = MacroFactory.createMacro(token);
  if (macro == null) {
    return parseVariable(lexer, expression);
  }

  advance(lexer);
  MacroCallNode macroCallNode = new MacroCallNode(macro);
  if (lexer.getTokenType() == null) {
    return macroCallNode;
  }

  if (lexer.getTokenType() != MacroTokenType.LPAREN) {
    return macroCallNode;
  }

  advance(lexer);
  parseParameters(macroCallNode, lexer, expression);
  if (lexer.getTokenType() != MacroTokenType.RPAREN) {
    System.out.println("Bad macro syntax: ) expected: " + expression);
  }
  advance(lexer);
  return macroCallNode;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:41,代码来源:MacroParser.java

示例6: init

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
private static MultiMap<String, Macro> init() {
  MultiMap<String, Macro> result = MultiMap.create();
  for(Macro macro: Extensions.getExtensions(Macro.EP_NAME)) {
    result.putValue(macro.getName(), macro);
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:MacroFactory.java

示例7: parseMacro

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
@SuppressWarnings({"HardCodedStringLiteral"})
private static Expression parseMacro(Lexer lexer, String expression) {
  IElementType tokenType = lexer.getTokenType();
  String token = getString(lexer, expression);
  if (tokenType == MacroTokenType.STRING_LITERAL) {
    advance(lexer);
    return new ConstantNode(parseStringLiteral(token));
  }

  if (tokenType != MacroTokenType.IDENTIFIER) {
    LOG.info("Bad macro syntax: Not identifier: " + token);
    advance(lexer);
    return new ConstantNode("");
  }

  List<Macro> macros = MacroFactory.getMacros(token);
  if (macros.isEmpty()) {
    return parseVariable(lexer, expression);
  }

  advance(lexer);
  MacroCallNode macroCallNode = new MacroCallNode(macros.get(0));
  if (lexer.getTokenType() == null) {
    return macroCallNode;
  }

  if (lexer.getTokenType() != MacroTokenType.LPAREN) {
    return macroCallNode;
  }

  advance(lexer);
  parseParameters(macroCallNode, lexer, expression);
  if (lexer.getTokenType() != MacroTokenType.RPAREN) {
    LOG.info("Bad macro syntax: ) expected: " + expression);
  }
  advance(lexer);
  return macroCallNode;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:39,代码来源:MacroParser.java

示例8: register

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
/**
 * @deprecated use com.intellij.liveTemplateMacro extension point instead
 */
public static void register(Macro macro) {
  if (myMacroTable == null) init();
  myMacroTable.put(macro.getName(), macro);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:MacroFactory.java

示例9: getMacro

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public Macro getMacro() {
  return myMacro;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:MacroCallNode.java

示例10: MacroCallNode

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public MacroCallNode(@NotNull Macro macro) {
  myMacro = macro;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:MacroCallNode.java

示例11: createVariablesTable

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
private JComponent createVariablesTable() {
  final String[] names = {
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined")
  };

  // Create a model of the data.
  TableModel dataModel = new VariablesModel(names);

  // Create the table
  myTable = new JBTable(dataModel);
  myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
  myTable.getColumn(names[0]).setPreferredWidth(120);
  myTable.getColumn(names[1]).setPreferredWidth(200);
  myTable.getColumn(names[2]).setPreferredWidth(200);
  myTable.getColumn(names[3]).setPreferredWidth(100);
  if (myVariables.size() > 0) {
    myTable.getSelectionModel().setSelectionInterval(0, 0);
  }

  ComboBox comboField = new ComboBox();
  Macro[] macros = MacroFactory.getMacros();
  Arrays.sort(macros, new Comparator<Macro> () {
    @Override
    public int compare(@NotNull Macro m1, @NotNull Macro m2) {
      return m1.getPresentableName().compareTo(m2.getPresentableName());
    }
  });
  eachMacro:
  for (Macro macro : macros) {
    for (TemplateContextType contextType : myContextTypes) {
      if (macro.isAcceptableInContext(contextType)) {
        comboField.addItem(macro.getPresentableName());
        continue eachMacro;
      }
    }
  }
  comboField.setEditable(true);
  DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
  cellEditor.setClickCountToStart(1);
  myTable.getColumn(names[1]).setCellEditor(cellEditor);
  myTable.setRowHeight(comboField.getPreferredSize().height);

  JTextField textField = new JTextField();

  /*textField.addMouseListener(
    new PopupHandler(){
      public void invokePopup(Component comp,int x,int y){
        showCellPopup((JTextField)comp,x,y);
      }
    }
  );*/

  cellEditor = new DefaultCellEditor(textField);
  cellEditor.setClickCountToStart(1);
  myTable.setDefaultEditor(String.class, cellEditor);

  final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
  return decorator.createPanel();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:64,代码来源:EditVariableDialog.java

示例12: createVariablesTable

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
private JComponent createVariablesTable() {
  final String[] names = {
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.name"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.expression"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.default.value"),
    CodeInsightBundle.message("templates.dialog.edit.variables.table.column.skip.if.defined")
  };

  // Create a model of the data.
  TableModel dataModel = new VariablesModel(names);

  // Create the table
  myTable = new JBTable(dataModel);
  myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  myTable.setPreferredScrollableViewportSize(new Dimension(500, myTable.getRowHeight() * 8));
  myTable.getColumn(names[0]).setPreferredWidth(120);
  myTable.getColumn(names[1]).setPreferredWidth(200);
  myTable.getColumn(names[2]).setPreferredWidth(200);
  myTable.getColumn(names[3]).setPreferredWidth(100);
  if (myVariables.size() > 0) {
    myTable.getSelectionModel().setSelectionInterval(0, 0);
  }

  JComboBox comboField = new JComboBox();
  Macro[] macros = MacroFactory.getMacros();
  Arrays.sort(macros, new Comparator<Macro> () {
    @Override
    public int compare(Macro m1, Macro m2) {
      return m1.getPresentableName().compareTo(m2.getPresentableName());
    }
  });
  eachMacro:
  for (Macro macro : macros) {
    for (TemplateContextType contextType : myContextTypes) {
      if (macro.isAcceptableInContext(contextType)) {
        comboField.addItem(macro.getPresentableName());
        continue eachMacro;
      }
    }
  }
  comboField.setEditable(true);
  DefaultCellEditor cellEditor = new DefaultCellEditor(comboField);
  cellEditor.setClickCountToStart(1);
  myTable.getColumn(names[1]).setCellEditor(cellEditor);
  myTable.setRowHeight(comboField.getPreferredSize().height);

  JTextField textField = new JTextField();

  /*textField.addMouseListener(
    new PopupHandler(){
      public void invokePopup(Component comp,int x,int y){
        showCellPopup((JTextField)comp,x,y);
      }
    }
  );*/

  cellEditor = new DefaultCellEditor(textField);
  cellEditor.setClickCountToStart(1);
  myTable.setDefaultEditor(String.class, cellEditor);

  final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).disableAddAction().disableRemoveAction();
  return decorator.createPanel();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:64,代码来源:EditVariableDialog.java

示例13: createMacro

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public static Macro createMacro(@NonNls String name) {
  return ContainerUtil.getFirstItem(myMacroTable.get(name));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:4,代码来源:MacroFactory.java

示例14: getMacros

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public static List<Macro> getMacros(@NonNls String name) {
  return (List<Macro>)myMacroTable.get(name);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:4,代码来源:MacroFactory.java

示例15: MacroCallNode

import com.intellij.codeInsight.template.Macro; //导入依赖的package包/类
public MacroCallNode(@Nonnull Macro macro) {
  myMacro = macro;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:4,代码来源:MacroCallNode.java


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