Java Code Examples for com.intellij.lang.PsiBuilder.putUserData()

The following are Jave code examples for showing how to use putUserData() of the com.intellij.lang.PsiBuilder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 6 votes
/**
 * @param b                       {@link PsiBuilder}
 * @param l                       level deep
 * @param parsedCommandDefinition command for which pars the parameters
 * @return true if rule matches, false otherwise
 */
private static boolean parseParametersForCommand(PsiBuilder b, int l,
                                                 @NotNull final AppleScriptCommand parsedCommandDefinition) {
  if (!recursion_guard_(b, l, "parseParametersForCommand")) return false;
  boolean r = true;
  PsiBuilder.Marker m = enter_section_(b, l, _NONE_, "<parse command handler call parameters>");
  b.putUserData(PARSING_COMMAND_HANDLER_CALL_PARAMETERS, true);
  if (parsedCommandDefinition.getDirectParameter() != null) {
    consumeToken(b, OF); //not mandatory
    r = parseCommandDirectParameterValue(b, l + 1, parsedCommandDefinition.getDirectParameter());
  }
  if (!parsedCommandDefinition.getParameters().isEmpty()) {
    r = parseCommandParameters(b, l + 1, parsedCommandDefinition);
  }
  exit_section_(b, l, m, null, r, false, null);
  b.putUserData(PARSING_COMMAND_HANDLER_CALL_PARAMETERS, false);
  return true;
}
 
Example 2
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 3
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 6 votes
/**
 * 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;
}
 
Example 4
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
public static boolean parseAssignmentStatementInner(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseAssignmentStatementInner")) return false;
  boolean r;
  b.putUserData(PARSING_COMMAND_ASSIGNMENT_STATEMENT, true);
  r = AppleScriptParser.assignmentStatement(b, l + 1);
  b.putUserData(PARSING_COMMAND_ASSIGNMENT_STATEMENT, false);
  return r;
}
 
Example 5
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
public static boolean parseLiteralExpression(PsiBuilder b, int l, Parser literalExpression) {
  if (!recursion_guard_(b, l, "parseLiteralExpression")) return false;
  boolean r;
  b.putUserData(PARSING_LITERAL_EXPRESSION, true);
  r = literalExpression.parse(b, l + 1);
  b.putUserData(PARSING_LITERAL_EXPRESSION, false);
  return r;
}
 
Example 6
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
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;
}
 
Example 7
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
/**
 * For custom parsing, so not to detect 'referenceIdentifier to ...' as labeled handler call
 */
public static boolean parseTellSimpleObjectReference(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseTellSimpleObjectReference")) return false;
  boolean r;
  r = nextTokenIsFast(b, LPAREN) && AppleScriptParser.parenthesizedExpression(b, l + 1);
  if (!r) {
    b.putUserData(PARSING_TELL_SIMPLE_OBJECT_REF, true);
    r = AppleScriptParser.expression(b, l + 1);
    b.putUserData(PARSING_TELL_SIMPLE_OBJECT_REF, false);
  }
  return r;
}
 
Example 8
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 9
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 10
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
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;
}
 
Example 11
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
private static boolean parseBooleanParameter(PsiBuilder b, int l, AppleScriptCommand command, StringHolder
        parsedParameterSelector) {
  if (!recursion_guard_(b, l, "parseBooleanParameter")) return false;
  boolean r;
  //need to rollback with/without if there is no match
  PsiBuilder.Marker m = enter_section_(b, l, _NONE_, "<parse Boolean Parameter>");
  b.putUserData(PARSING_COMMAND_HANDLER_BOOLEAN_PARAMETER, true);
  r = consumeToken(b, WITH);
  if (!r) r = consumeToken(b, WITHOUT);
  if (!r) r = consumeToken(b, LAND); //for cases like: '...with regexp and all occurrences without case sensitive'
  r = r && parseCommandParameterSelector(b, l + 1, command, parsedParameterSelector);
  exit_section_(b, l, m, null, r, false, null);
  b.putUserData(PARSING_COMMAND_HANDLER_BOOLEAN_PARAMETER, false);
  return r;
}
 
Example 12
Project: AppleScript-IDEA   File: AppleScriptGeneratedParserUtil.java   Source Code and License Vote up 5 votes
public static boolean parseCommandParametersExpression(PsiBuilder b, int l) {
  if (!recursion_guard_(b, l, "parseCommandParametersExpression")) return false;
  boolean r;
  b.putUserData(PARSING_COMMAND_HANDLER_CALL_PARAMETERS, true);
  r = AppleScriptParser.expression(b, l + 1);
  b.putUserData(PARSING_COMMAND_HANDLER_CALL_PARAMETERS, false);
  return r;
}