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


Java PsiBuilder.getUserData方法代码示例

本文整理汇总了Java中com.intellij.lang.PsiBuilder.getUserData方法的典型用法代码示例。如果您正苦于以下问题:Java PsiBuilder.getUserData方法的具体用法?Java PsiBuilder.getUserData怎么用?Java PsiBuilder.getUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.lang.PsiBuilder的用法示例。


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

示例1: parseApplicationHandlerDefinitionSignature

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
public static boolean parseApplicationHandlerDefinitionSignature(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseApplicationHandlerDefinitionSignature")) return false;
  boolean r;
  //application handled definition in script only makes sense inside <using terms of> statement
  if (b.getUserData(IS_PARSING_USING_TERMS_FROM_STATEMENT) != Boolean.TRUE || b.getUserData(PARSING_TELL_COMPOUND_STATEMENT) == Boolean.TRUE) return false;

  StringHolder parsedCommandName = new StringHolder();
  String toldApplicationName = getTargetApplicationName(b);
  PsiBuilder.Marker m2 = enter_section_(b, l, _COLLAPSE_, "<parse Application Handler Definition");
  r = parseDictionaryCommandNameInner(b, l + 1, parsedCommandName, toldApplicationName, true, null);
  exit_section_(b, l, m2, DICTIONARY_COMMAND_NAME, r, false, null);

  if (!r) return false;
  // TODO: 06/12/15 may be try to avoid creating PSI here!..
  List<AppleScriptCommand> allCommandsWithName = getAllCommandsWithName(b, parsedCommandName.value, toldApplicationName, false, null);

  for (AppleScriptCommand command : allCommandsWithName) {
    r = parseParametersForCommand(b, l + 1, command);//custom parsing here
    if (r) {
      break;
    }
  }
  boolean incompleteHandlerCall = !r && allCommandsWithName.size() > 0 && (b.getTokenType() == NLS || b.eof());
  return r || incompleteHandlerCall;

}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:27,代码来源:AppleScriptGeneratedParserUtil.java

示例2: parseExpression

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
   * If inside tell (only in a tell?) compound statement - first check it's terms
   */
  public static boolean parseExpression(PsiBuilder b, int l, String dictionaryTermToken, Parser expression) {
    if (!recursion_guard_(b, l, "parseExpression")) return false;
    if (!nextTokenIsFast(b, dictionaryTermToken)) return false;
    boolean r;

    //check application terms first
    if (b.getUserData(PARSING_TELL_COMPOUND_STATEMENT) == Boolean.TRUE) {
      String toldAppName = peekTargetApplicationName(b);
      if (!StringUtil.isEmpty(toldAppName)) {
        StringHolder parsedName = new StringHolder();
        PsiBuilder.Marker mComName = enter_section_(b, l, _AND_, "<parse Expression>");
        r = parseCommandNameForApplication(b, l + 1, parsedName, toldAppName, true);
        exit_section_(b, l, mComName, null, r, false, null);
        if (r) return false;
        if (ParsableScriptSuiteRegistryHelper.isPropertyWithPrefixExist(toldAppName, dictionaryTermToken)) {
          return false;
//          PsiBuilder.Marker m = enter_section_(b, l, _AND_, null, "<dictionary constant>");
//          r = parseDictionaryConstant(b, l + 1);
//          exit_section_(b, l, m, r, false, null);
//          if (r) return false;
        }
      }
    }
    return expression.parse(b, l + 1);
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:29,代码来源:AppleScriptGeneratedParserUtil.java

示例3: parseTellCompoundStatement

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * If rule matches, removes added application name from the name stack which was used for parsing application terms
 *
 * @param b {@link PsiBuilder}
 * @param l level deep
 * @return true if rule matches
 */
public static boolean parseTellCompoundStatement(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseTellCompoundStatement")) return false;
  if (!nextTokenIs(b, TELL)) return false;
  boolean r;
  boolean pushStateBefore = b.getUserData(APPLICATION_NAME_PUSHED) == Boolean.TRUE;
  boolean compoundStateBefore = b.getUserData(PARSING_TELL_COMPOUND_STATEMENT) == Boolean.TRUE;
  b.putUserData(APPLICATION_NAME_PUSHED, false);
  b.putUserData(PARSING_TELL_COMPOUND_STATEMENT, true);

  r = AppleScriptParser.tellCompoundStatement(b, l + 1);

  b.putUserData(PARSING_TELL_COMPOUND_STATEMENT, compoundStateBefore);
  popApplicationNameIfWasPushed(b);
  b.putUserData(APPLICATION_NAME_PUSHED, pushStateBefore);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:24,代码来源:AppleScriptGeneratedParserUtil.java

示例4: parseUsingTermsFromStatement

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * If rule matches, removes added application name from the name stack which was used for parsing application terms
 *
 * @param b {@link PsiBuilder}
 * @param l level deep
 * @return true if rule matches
 */
public static boolean parseUsingTermsFromStatement(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseUsingTermsFromStatement")) return false;
  boolean r;
  boolean oldParseUsingTermsState = b.getUserData(IS_PARSING_USING_TERMS_FROM_STATEMENT) == Boolean.TRUE;
  boolean oldPushedState = b.getUserData(APPLICATION_NAME_PUSHED) == Boolean.TRUE;
  b.putUserData(IS_PARSING_USING_TERMS_FROM_STATEMENT, true);
  b.putUserData(APPLICATION_NAME_PUSHED, false);

  r = AppleScriptParser.usingTermsFromStatement(b, l + 1);

  popApplicationNameIfWasPushed(b);
  b.putUserData(IS_PARSING_USING_TERMS_FROM_STATEMENT, oldParseUsingTermsState);
  b.putUserData(APPLICATION_NAME_PUSHED, oldPushedState);

  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:24,代码来源:AppleScriptGeneratedParserUtil.java

示例5: parseDictionaryCommandName

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
public static boolean parseDictionaryCommandName(PsiBuilder b, int l) {
  boolean r;
  if (nextTokenIs(b, NLS)) {
    return false;
  }
  StringHolder parsedCommandName = new StringHolder();
  String toldApplicationName = getTargetApplicationName(b);
  boolean areThereUseStatements = b.getUserData(WAS_USE_STATEMENT_USED) == Boolean.TRUE;
  Set<String> applicationsToImport = null;
  if (areThereUseStatements) {
    applicationsToImport = b.getUserData(USED_APPLICATION_NAMES);
  }
  PsiBuilder.Marker m = enter_section_(b, l, _COLLAPSE_, "<parse ApplicationDictionary Command Name>");
  r = parseDictionaryCommandNameInner(b, l + 1, parsedCommandName, toldApplicationName, areThereUseStatements, applicationsToImport);
  exit_section_(b, l, m, DICTIONARY_COMMAND_NAME, r, false, null);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:18,代码来源:AppleScriptGeneratedParserUtil.java

示例6: parseDictionaryClassName

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * @param b                     {@link PsiBuilder}
 * @param l                     level deep
 * @param isPluralForm          if parsing plural form of a class name
 * @param checkForUseStatements parser rule for the check if there are use statements in the script
 * @return true in case rule matches, false otherwise
 */
public static boolean parseDictionaryClassName(PsiBuilder b, int l, final boolean isPluralForm, @NotNull Parser checkForUseStatements) {
  if (!recursion_guard_(b, l, "parseDictionaryClassName")) return false;
  boolean r;
  final String s = b.getTokenText();
  if (s == null || s.length() == 0 || !AppleScriptNames.isIdentifierStart(s.charAt(0))) return false;
  final String toldApplicationName = getTargetApplicationName(b);
  final boolean areThereUseStatements = checkForUseStatements.parse(b, l + 1);
  Set<String> applicationsToImportFrom = null;
  if (areThereUseStatements) {
    applicationsToImportFrom = b.getUserData(USED_APPLICATION_NAMES);
  }
  final StringHolder currentTokenText = new StringHolder();
  currentTokenText.value = s;
  r = parseDictionaryClassName(b, l + 1, currentTokenText, isPluralForm, toldApplicationName, areThereUseStatements, applicationsToImportFrom);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:24,代码来源:AppleScriptGeneratedParserUtil.java

示例7: parseCommandHandlerCallExpression

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * <<< COMMAND_HANDLER_CALL >>>
 */
// commandName commandParameters?
public static boolean parseCommandHandlerCallExpression(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseCommandHandlerCallExpression")) return false;
  boolean r;

  if (nextTokenIs(b, NLS)) return false;
  final String s = b.getTokenText();

  if (s == null || s.length() == 0 || !AppleScriptNames.isIdentifierStart(s.charAt(0))) return false;
  StringHolder parsedCommandName = new StringHolder();
  //get current application name to which messages will be sent in the current block
  String toldApplicationName = getTargetApplicationName(b);
  //if there are <use statements> present in the script
  boolean areThereUseStatements = b.getUserData(WAS_USE_STATEMENT_USED) == Boolean.TRUE;
  Set<String> applicationsToImport = null;
  if (areThereUseStatements) {
    //adding list of application names from use statements
    applicationsToImport = b.getUserData(USED_APPLICATION_NAMES);
  }
  PsiBuilder.Marker m2 = enter_section_(b, l, _COLLAPSE_, "<parse Command Handler Call Expression>");
  // TODO: 19/12/15 need to parse command name together with parameters for each possible application in order to be
  // able to parse the longest possible application name ('open for access' std lib vs 'open' from application dict)
  r = parseDictionaryCommandNameInner(b, l + 1, parsedCommandName, toldApplicationName, areThereUseStatements, applicationsToImport);
  exit_section_(b, l, m2, DICTIONARY_COMMAND_NAME, r, false, null);

  if (!r) return false;
  // TODO: 06/12/15 may be try to avoid creating PSI here!..
  List<AppleScriptCommand> allCommandsWithName = getAllCommandsWithName(b, parsedCommandName.value, toldApplicationName, areThereUseStatements,
          applicationsToImport);

  for (AppleScriptCommand command : allCommandsWithName) {
    r = parseParametersForCommand(b, l + 1, command);
    if (r) {
      break;
    }
  }
  boolean incompleteHandlerCall = !r && allCommandsWithName.size() > 0 && (b.getTokenType() == NLS || b.eof());
  return r || incompleteHandlerCall;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:43,代码来源:AppleScriptGeneratedParserUtil.java

示例8: peekTargetApplicationName

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
@Nullable
private static String peekTargetApplicationName(PsiBuilder b) {
  Stack<String> applicationNameStack = b.getUserData(TOLD_APPLICATION_NAME_STACK);
  String toldApplicationName = null;
  if (applicationNameStack != null && !applicationNameStack.isEmpty()) {
    toldApplicationName = applicationNameStack.peek();
  }
  return toldApplicationName;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:10,代码来源:AppleScriptGeneratedParserUtil.java

示例9: parseTellSimpleStatementInner

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
public static boolean parseTellSimpleStatementInner(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "tellSimpleStatement")) return false;
  if (!nextTokenIs(b, TELL)) return false;
  boolean r;
  boolean pushStateBefore = b.getUserData(APPLICATION_NAME_PUSHED) == Boolean.TRUE;
  b.putUserData(APPLICATION_NAME_PUSHED, false);
  b.putUserData(PARSING_TELL_SIMPLE_STATEMENT, true);
  r = AppleScriptParser.tellSimpleStatement(b, l + 1);
  b.putUserData(PARSING_TELL_SIMPLE_STATEMENT, false);
  popApplicationNameIfWasPushed(b);
  b.putUserData(APPLICATION_NAME_PUSHED, pushStateBefore);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:14,代码来源:AppleScriptGeneratedParserUtil.java

示例10: popApplicationNameIfWasPushed

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static void popApplicationNameIfWasPushed(PsiBuilder b) {
  if (b.getUserData(APPLICATION_NAME_PUSHED) == Boolean.TRUE) {
    Stack<String> dictionaryNameStack = b.getUserData(TOLD_APPLICATION_NAME_STACK);
    if (dictionaryNameStack != null && !dictionaryNameStack.isEmpty()) {//should always be true if r==true
      dictionaryNameStack.pop();
    }
  }
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:9,代码来源:AppleScriptGeneratedParserUtil.java

示例11: parseUsedApplicationNameExternal

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * Add application name from this &lt;use statement&gt; to the set of application names from dictionary of which to
 * import terms if importing condition is not explicitly prohibited by syntax
 *
 * @param b           {@link PsiBuilder}
 * @param l           level deep
 * @param isImporting whether to make terms from this application's dictionary available in the script
 * @return true if this is application reference
 */
public static boolean parseUsedApplicationNameExternal(PsiBuilder b, int l, Parser isImporting) {
  if (!recursion_guard_(b, l, "parseUsedApplicationNameExternal")) return false;
  boolean r;
  if (!nextTokenIs(b, "parseUsedApplicationNameExternal", APPLICATION, APP, SCRIPTING_ADDITIONS)) return false;
  String appName = null;
  r = consumeToken(b, SCRIPTING_ADDITIONS);
  if (r) {
    appName = ApplicationDictionary.SCRIPTING_ADDITIONS_LIBRARY;
  } else {
    PsiBuilder.Marker mAppRef = enter_section_(b, l, _NONE_, "<application reference>");
    PsiBuilder.Marker mCls = enter_section_(b, l, _NONE_, "<dictionary class name>");
    r = consumeToken(b, APPLICATION);
    if (!r) r = consumeToken(b, APP);
    exit_section_(b, l, mCls, DICTIONARY_CLASS_NAME, r, false, null);
    if (r) {
      String appNameStr = b.getTokenText();
      r = consumeToken(b, STRING_LITERAL);
      if (r && !StringUtil.isEmpty(appNameStr)) {
        appName = appNameStr.replace("\"", "");
      }
    }
    exit_section_(b, l, mAppRef, APPLICATION_REFERENCE, r, false, null);
  }
  boolean doTermsImport = isImporting.parse(b, l + 1);
  if (doTermsImport && !StringUtil.isEmpty(appName)) {
    Set<String> usedAppNames = b.getUserData(USED_APPLICATION_NAMES);
    if (usedAppNames == null) {
      usedAppNames = new HashSet<>();
      b.putUserData(USED_APPLICATION_NAMES, usedAppNames);
    }
    usedAppNames.add(appName);
  }
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:44,代码来源:AppleScriptGeneratedParserUtil.java

示例12: parseUseStatement

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * If there is at least one &lt;use statement&gt; in script, set WAS_USE_STATEMENT_USED flag to true
 */
public static boolean parseUseStatement(PsiBuilder b, int l, Parser useStatement) {
  if (!recursion_guard_(b, l, "parseUseStatement")) return false;
  boolean r = useStatement.parse(b, l + 1);
  boolean prevPass = b.getUserData(WAS_USE_STATEMENT_USED) == Boolean.TRUE;
  b.putUserData(WAS_USE_STATEMENT_USED, r || prevPass);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:11,代码来源:AppleScriptGeneratedParserUtil.java

示例13: isTellStatementStart

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * @return true if this is the application reference of a &lt;tell&gt; or &lt;using terms
 * from&gt; statements
 */
public static boolean isTellStatementStart(PsiBuilder b, int l) {
  if (!isInTellStatement(b, l + 1)) return false;
  int i = -1;
  IElementType prevElem = b.rawLookup(i);
  while (prevElem == com.intellij.psi.TokenType.WHITE_SPACE || prevElem == MY
          || prevElem == APPLICATION || prevElem == STRING_LITERAL || prevElem == null
          || prevElem == ID) {
    prevElem = b.rawLookup(--i);
  }
  return prevElem == TELL
          || (b.getUserData(IS_PARSING_USING_TERMS_FROM_STATEMENT) == Boolean.TRUE)
          && prevElem == FROM;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:18,代码来源:AppleScriptGeneratedParserUtil.java

示例14: pushTargetApplicationName

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static Stack<String> pushTargetApplicationName(PsiBuilder b, @NotNull String applicationNameString) {
  Stack<String> dictionaryNameStack = b.getUserData(TOLD_APPLICATION_NAME_STACK);
  if (dictionaryNameStack == null) {
    dictionaryNameStack = new Stack<>();
    b.putUserData(TOLD_APPLICATION_NAME_STACK, dictionaryNameStack);
  }
  dictionaryNameStack.push(applicationNameString);
  b.putUserData(APPLICATION_NAME_PUSHED, true);
  return dictionaryNameStack;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:11,代码来源:AppleScriptGeneratedParserUtil.java

示例15: parseCommandDirectParameterValue

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static boolean parseCommandDirectParameterValue(PsiBuilder b, int l,
                                                          @NotNull CommandDirectParameter parameter) {
    if (!recursion_guard_(b, l, "parseCommandDirectParameterValue")) return false;
    boolean r = false;
//    String parameterTypeSpecifier = parameter.getTypeSpecifier();
    // if we are inside tell compound statement=> direct parameter is optional
    // so it may be wrongly detected instead of parameter selector. So, checking if it is a parameter selector first
    boolean isTellCompound = b.getUserData(PARSING_TELL_COMPOUND_STATEMENT) == Boolean.TRUE;
    if (isTellCompound || parameter.isOptional()) {
      AppleScriptCommand myCmd = parameter.getCommand();
      for (String paramName : myCmd.getParameterNames()) {
        if (nextTokenIs(b, paramName)) return true;
      }
    }
    PsiBuilder.Marker m = enter_section_(b, l, _NONE_, "<parse Command Direct Parameter Value >");
    String parameterTypeSpecifier = parameter.getTypeSpecifier();
    if ("type".equals(parameterTypeSpecifier)) {
      r = typeSpecifier(b, l + 1);
    }
    // see https://bitbucket.org/adernov/applescript-internal/issues/23/coercion-expression-priority
//    else if ("text".equals(parameterTypeSpecifier)) {
//      r = AppleScriptParser.coercionExpressionWrapper(b, l + 1);
//      if (!r) r = AppleScriptParser.concatenationExpressionWrapper(b, l + 1);
//      if (!r) r = AppleScriptParser.stringLiteralExpression(b, l + 1);
//    }
    if (!r)
      r = com.intellij.plugin.applescript.lang.parser.AppleScriptParser.expression(b, l + 1);
    exit_section_(b, l, m, DIRECT_PARAMETER_VAL, r, false, null);
    // A tell statement specifies a default target for all commands contained
    // within it, so the direct parameter is optional.
    return r || parameter.isOptional() || isTellCompound;
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:33,代码来源:AppleScriptGeneratedParserUtil.java


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