本文整理匯總了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例11: parseUsedApplicationNameExternal
import com.intellij.lang.PsiBuilder; //導入方法依賴的package包/類
/**
* Add application name from this <use statement> 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;
}
示例12: parseUseStatement
import com.intellij.lang.PsiBuilder; //導入方法依賴的package包/類
/**
* If there is at least one <use statement> 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;
}
示例13: isTellStatementStart
import com.intellij.lang.PsiBuilder; //導入方法依賴的package包/類
/**
* @return true if this is the application reference of a <tell> or <using terms
* from> 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;
}
示例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;
}
示例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;
}