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


Java PsiBuilder.getTokenText方法代码示例

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


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

示例1: parseCommandParameterSelector

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static boolean parseCommandParameterSelector(PsiBuilder b, int l, AppleScriptCommand command,
                                                     StringHolder parsedParameterSelector) {
  if (!recursion_guard_(b, l, "parseCommandParameterSelector")) return false;
  boolean r = false;
  PsiBuilder.Marker m = enter_section_(b, l, _NONE_, "<parse Command Parameter Selector>");//todo check this _AND_
  parsedParameterSelector.value = b.getTokenText() == null ? "" : b.getTokenText();
  while (!b.eof() && b.getTokenType() != NLS && b.getTokenType() != COMMENT) {
    b.advanceLexer();
    if (command.getParameterByName(parsedParameterSelector.value) != null) {
      r = true;
      break;
    }
    parsedParameterSelector.value += " " + b.getTokenText();
  }
  exit_section_(b, l, m, COMMAND_PARAMETER_SELECTOR, r, false, null);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:18,代码来源:AppleScriptGeneratedParserUtil.java

示例2: parseStdLibCommandName

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static boolean parseStdLibCommandName(PsiBuilder b, int l, StringHolder parsedName) {
  if (!recursion_guard_(b, l, "parseStdLibCommandName")) return false;
  boolean r = false;
  parsedName.value = "";
  parsedName.value = b.getTokenText() == null ? "" : b.getTokenText();
  PsiBuilder.Marker m = enter_section_(b);
  boolean commandWithPrefixExists = ParsableScriptSuiteRegistryHelper.isStdCommandWithPrefixExist(parsedName.value);
  String nextTokenText = parsedName.value;
  while (b.getTokenText() != null && commandWithPrefixExists) {
    b.advanceLexer(); //advance lexer in any case
    nextTokenText += " " + b.getTokenText();
    commandWithPrefixExists = ParsableScriptSuiteRegistryHelper.isStdCommandWithPrefixExist(nextTokenText);
    if (commandWithPrefixExists) {
      parsedName.value = nextTokenText;
    } else if (ParsableScriptSuiteRegistryHelper.isStdCommand(parsedName.value)) {
      r = true;
      break;
    }
  }
  exit_section_(b, m, null, r);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:23,代码来源:AppleScriptGeneratedParserUtil.java

示例3: 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

示例4: tryToParseStdProperty

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * @param b {@link PsiBuilder}
 * @param l level deep
 * @return true if parsed token(s) is the property of the scripting additions library
 */
private static boolean tryToParseStdProperty(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "tryToParseStdProperty")) return false;
  boolean r = false;
  PsiBuilder.Marker m = enter_section_(b);
  StringHolder currentTokenText = new StringHolder();
  currentTokenText.value = b.getTokenText() == null ? "" : b.getTokenText();
  boolean propertyWithPrefixExists = ParsableScriptSuiteRegistryHelper
          .isStdPropertyWithPrefixExist(currentTokenText.value);
  String nextTokenText = currentTokenText.value;
  while (b.getTokenText() != null && propertyWithPrefixExists) {
    b.advanceLexer(); //advance lexer in any case
    nextTokenText += " " + b.getTokenText();
    propertyWithPrefixExists = ParsableScriptSuiteRegistryHelper.isStdPropertyWithPrefixExist(nextTokenText);
    if (propertyWithPrefixExists) {
      currentTokenText.value = nextTokenText;
    } else if (ParsableScriptSuiteRegistryHelper.isStdProperty(currentTokenText.value)) {
      r = true;
      break;
    }
  }
  exit_section_(b, m, null, r);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:29,代码来源:AppleScriptGeneratedParserUtil.java

示例5: tryToParseApplicationProperty

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * @param b               {@link PsiBuilder}
 * @param l               level deep
 * @param applicationName name of the application
 * @return true if parsed token(s) is the property of the specified application
 */
private static boolean tryToParseApplicationProperty(PsiBuilder b, int l, @NotNull String applicationName) {
  if (!recursion_guard_(b, l, "tryToParseApplicationProperty")) return false;
  boolean r = false;
  PsiBuilder.Marker m = enter_section_(b);
  StringHolder currentTokenText = new StringHolder();
  currentTokenText.value = b.getTokenText() == null ? "" : b.getTokenText();
  boolean propertyWithPrefixExist = ParsableScriptSuiteRegistryHelper.isPropertyWithPrefixExist(applicationName,
          currentTokenText.value);
  //find the longest lexeme
  String nextTokenText = currentTokenText.value;
  while (b.getTokenText() != null && propertyWithPrefixExist) {
    b.advanceLexer(); //advance lexer in any case
    nextTokenText += " " + b.getTokenText();
    propertyWithPrefixExist = ParsableScriptSuiteRegistryHelper.isPropertyWithPrefixExist(applicationName,
            nextTokenText);
    if (propertyWithPrefixExist) {
      currentTokenText.value = nextTokenText;
    } else if (ParsableScriptSuiteRegistryHelper.isApplicationProperty(applicationName, currentTokenText.value)) {
      r = true;
      break;
    }
  }
  exit_section_(b, m, null, r);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:32,代码来源:AppleScriptGeneratedParserUtil.java

示例6: 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

示例7: 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

示例8: parseApplicationName

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
 * @param b                           {@link PsiBuilder}
 * @param l                           Level deep
 * @param tellStatementStartCondition If this is the application reference of a &lt;tell&gt; or &lt;using terms
 *                                    from&gt; statements
 * @return true if parsed
 */
public static boolean parseApplicationName(PsiBuilder b, int l, Parser tellStatementStartCondition) {
  if (!recursion_guard_(b, l, "parseApplicationName")) return false;
  boolean r;
  consumeToken(b, THE_KW);
  if (!nextTokenIs(b, "", APPLICATION, APP)) return false;

  PsiBuilder.Marker mCls = enter_section_(b, l, _NONE_, "<parse application name>");
  r = consumeToken(b, APPLICATION);
  if (!r) r = consumeToken(b, APP);
  exit_section_(b, l, mCls, DICTIONARY_CLASS_NAME, r, false, null);

  if (!nextTokenIs(b, "", STRING_LITERAL, ID)) return false;
  PsiBuilder.Marker mProp = enter_section_(b, l, _NONE_, "<parse application name>");
  boolean idReference = consumeToken(b, ID);
  exit_section_(b, l, mProp, DICTIONARY_PROPERTY_NAME, idReference, false, null);
  PsiBuilder.Marker m = enter_section_(b);
  String applicationNameString = b.getTokenText();
  r = consumeToken(b, STRING_LITERAL);

  // if this is start of <tell compound> or <tell simple> or <using terms from> statements, push the application name
  // which dictionary will be consulted for terms parsing (only the last pushed application is queried)
  if (r && applicationNameString != null) {
    applicationNameString = applicationNameString.replace("\"", "");
    if (!StringUtil.isEmptyOrSpaces(applicationNameString) && tellStatementStartCondition.parse(b, l + 1)) {
      pushTargetApplicationName(b, applicationNameString);
    }
  }
  exit_section_(b, m, null, r);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:38,代码来源:AppleScriptGeneratedParserUtil.java

示例9: tryToParseStdConstant

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static boolean tryToParseStdConstant(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "tryToParseStdConstant")) return false;
  StringHolder currentTokenText = new StringHolder();
  currentTokenText.value = b.getTokenText() == null ? "" : b.getTokenText();
  boolean r = false, propertyOrClassExists = false, constantWithPrefixExists = ParsableScriptSuiteRegistryHelper
          .isStdConstantWithPrefixExist(currentTokenText.value);
  String nextTokenText = currentTokenText.value;
  PsiBuilder.Marker m = enter_section_(b);
  while (b.getTokenText() != null && constantWithPrefixExists) {
    b.advanceLexer();
    nextTokenText += " " + b.getTokenText();
    constantWithPrefixExists = ParsableScriptSuiteRegistryHelper.isStdConstantWithPrefixExist(nextTokenText);
    if (constantWithPrefixExists) {
      currentTokenText.value = nextTokenText;
    } else if (ParsableScriptSuiteRegistryHelper.isStdConstant(currentTokenText.value)) {
      r = true;
      break;
    }
  }
  if (r) {
    // grammar allows className and propertyName as primaryExpression, so we should match the longest token between
    // className or propertyName tokens. We check and return false if the property or class with the longer name
    // exists, as it will be parsed later
    currentTokenText.value += " " + b.getTokenText();
    propertyOrClassExists = ParsableScriptSuiteRegistryHelper
            .isStdPropertyWithPrefixExist(currentTokenText.value) ||
            ParsableScriptSuiteRegistryHelper
                    .isStdClassWithPrefixExist(currentTokenText.value);
  }
  r = r && !propertyOrClassExists;
  exit_section_(b, m, null, r);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:34,代码来源:AppleScriptGeneratedParserUtil.java

示例10: tryToParseApplicationConstant

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
private static boolean tryToParseApplicationConstant(PsiBuilder b, int l, @NotNull String applicationName) {
  if (!recursion_guard_(b, l, "tryToParseApplicationConstant")) return false;
  StringHolder currentTokenText = new StringHolder();
  currentTokenText.value = b.getTokenText() == null ? "" : b.getTokenText();
  boolean r = false, propertyOrClassExists = false, constantWithPrefixExists = ParsableScriptSuiteRegistryHelper
          .isConstantWithPrefixExist(applicationName, currentTokenText.value);
  String nextTokenText = currentTokenText.value;
  PsiBuilder.Marker m = enter_section_(b);
  while (b.getTokenText() != null && constantWithPrefixExists) {
    b.advanceLexer();
    nextTokenText += " " + b.getTokenText();
    constantWithPrefixExists = ParsableScriptSuiteRegistryHelper
            .isConstantWithPrefixExist(applicationName, nextTokenText);
    if (constantWithPrefixExists) {
      currentTokenText.value = nextTokenText;
    } else if (ParsableScriptSuiteRegistryHelper.isApplicationConstant(applicationName, currentTokenText.value)) {
      r = true;
      break;
    }
  }
  if (r) {
    // grammar allows className and propertyName as primaryExpression, so we should match the longest token between
    // className or propertyName tokens. We check and return false if the property or class with the longer name
    // exists, as it will be parsed later
    propertyOrClassExists = ParsableScriptSuiteRegistryHelper
            .isPropertyWithPrefixExist(applicationName, currentTokenText.value) ||
            ParsableScriptSuiteRegistryHelper
                    .isClassWithPrefixExist(applicationName, currentTokenText.value);
    if (propertyOrClassExists) {
      currentTokenText.value += " " + b.getTokenText();
      propertyOrClassExists = ParsableScriptSuiteRegistryHelper
              .isPropertyWithPrefixExist(applicationName, currentTokenText.value) ||
              ParsableScriptSuiteRegistryHelper
                      .isClassWithPrefixExist(applicationName, currentTokenText.value);
    }
  }
  r = r && !propertyOrClassExists;
  exit_section_(b, m, null, r);
  return r;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:41,代码来源:AppleScriptGeneratedParserUtil.java

示例11: parseCommandNameForApplication

import com.intellij.lang.PsiBuilder; //导入方法依赖的package包/类
/**
   * @param b               {@link PsiBuilder}
   * @param l               level deep
   * @param parsedName      holder for parsed term string
   * @param applicationName name of the application, which dictionary terms will be queried
   * @param checkStdLib     whether to check in scripting additions library if no terms were found in this application
   * @return true if command name was parsed
   */
  private static boolean parseCommandNameForApplication(PsiBuilder b, int l,
                                                        StringHolder parsedName,
                                                        @NotNull String applicationName,
                                                        boolean checkStdLib) {
    if (!recursion_guard_(b, l, "parseCommandNameForApplication")) return false;
    boolean r = false;
    parsedName.value = "";
    PsiBuilder.Marker m = enter_section_(b);
    parsedName.value = b.getTokenText() == null ? "" : b.getTokenText();

    boolean commandWithPrefixExists = ParsableScriptSuiteRegistryHelper.isCommandWithPrefixExist(applicationName,
            parsedName.value);
    String nextTokenText = parsedName.value;
    while (b.getTokenText() != null && commandWithPrefixExists) {
      b.advanceLexer(); //advance lexer to the next token
      nextTokenText += " " + b.getTokenText();
      commandWithPrefixExists = ParsableScriptSuiteRegistryHelper
              .isCommandWithPrefixExist(applicationName, nextTokenText);
      if (commandWithPrefixExists) {
        //if command with prefix exists, append token text
        parsedName.value = nextTokenText;
      } else if (ParsableScriptSuiteRegistryHelper.isApplicationCommand(applicationName, parsedName.value)) {
        //if there is std command with longer prefix exists do not parse it here
        r = !checkStdLib || !ParsableScriptSuiteRegistryHelper.isStdCommandWithPrefixExist(nextTokenText);
        // if there is class name with longer prefix exists !! AND !! next is NLS token => do not this as command name
//        boolean longerClassNameExists = ParsableScriptSuiteRegistryHelper
//                .isClassWithPrefixExist(applicationName, nextTokenText);
//        if (r && longerClassNameExists) {
//          while (b.getTokenType() != NLS) {
//            b.advanceLexer();
//            nextTokenText += " " + b.getTokenText();
//          }
//          r = ParsableScriptSuiteRegistryHelper.isApplicationClass(applicationName, nextTokenText);
//        }
        r = r && !ParsableScriptSuiteRegistryHelper.isClassWithPrefixExist(applicationName, nextTokenText);
        break;
      }
    }
    exit_section_(b, m, null, r);
    return r;
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:50,代码来源:AppleScriptGeneratedParserUtil.java


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