@Override public boolean supportsInlineOptionFlag(char flag, PsiElement context) { return StringUtil.containsChar("imsU", flag); }
public static boolean hasPlaceholder(@Nullable String formatString) { return formatString != null && StringUtil.containsChar(formatString, '%'); }
private static void parseFlags(@NotNull FormatState state) { String knownFlags = "#0+- "; StringBuilder flags = new StringBuilder(state.flags); while (state.nBytes < state.format.length()) { if (StringUtil.containsChar(knownFlags, state.format.charAt(state.nBytes))) { flags.append(state.format.charAt(state.nBytes)); } else { state.flags = flags.toString(); return; } state.nBytes++; } state.flags = flags.toString(); }
public boolean matchBuildFlag(@NotNull String name) { if (name.isEmpty()) return false; if (StringUtil.containsChar(name, ',')) { // comma separated list for (String tag : StringUtil.split(name, ",")) { if (!matchBuildFlag(tag)) { return false; } } return true; } // bad syntax, reject always if (name.startsWith("!!")) return false; // negation if (name.startsWith("!")) return !matchBuildFlag(name.substring(1)); if (matchOS(name)) return true; if (GoConstants.KNOWN_COMPILERS.contains(name)) { return myTarget.compiler == null || name.equals(myTarget.compiler); } if (GoConstants.KNOWN_VERSIONS.contains(name)) { return myTarget.goVersion == null || GoSdkUtil.compareVersions(myTarget.goVersion, StringUtil.trimStart(name, "go")) >= 0; } if ("cgo".equals(name)) { return myTarget.cgoEnabled == ThreeState.YES; } return myTarget.supportsFlag(name); }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, "()", false, 1); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, "();", false, 1); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, ";", false, 1); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, " {}", false, 2); PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return; } Project project = editor.getProject(); if (project != null) { int completionCharOffset = getCompletionCharOffset(editor); if (completionCharOffset == -1) { EditorModificationUtil.insertStringAtCaret(editor, ":", false, 1); if (myWithSpace) { EditorModificationUtil.insertStringAtCaret(editor, " ", false, 1); } PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument()); } else { editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1); } if (myTriggerAutoPopup) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null); } } }
public void handleInsert(InsertionContext context, LookupElement item) { Editor editor = context.getEditor(); char completionChar = context.getCompletionChar(); if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) { return;
protected boolean isPodTag(CharSequence buffer, int offset, int bufferEnd) { if (offset + 1 < bufferEnd) { return StringUtil.containsChar("IBCLEFSXZ", buffer.charAt(offset)) && buffer.charAt(offset + 1) == '<'; } return false; }
@Contract(pure = true) public static int indexOfAny(@NotNull final CharSequence s, @NotNull final String chars, final int start, int end) { end = min(end, s.length()); for (int i = max(start, 0); i < end; i++) { if (containsChar(chars, s.charAt(i))) return i; } return -1; }
@Contract(pure = true) public static int lastIndexOfAny(@NotNull CharSequence s, @NotNull final String chars) { for (int i = s.length() - 1; i >= 0; i--) { if (containsChar(chars, s.charAt(i))) return i; } return -1; }
private PerlExportDescriptor(@NotNull String realPackage, @NotNull String realName, @NotNull String importedName) { myRealPackage = realPackage; if (realName.length() > 0 && StringUtil.containsChar(ALL_SIGILS, realName.charAt(0))) // canonical export { mySigil = realName.charAt(0); myRealName = realName.substring(1); myImportedName = importedName.substring(1); } else // suppose it's sigilles code { mySigil = '&'; myImportedName = importedName; myRealName = realName; } } @NotNull
public static PsiElement getRegexModifierDoc(PsiElement element) { String text = element.getText(); assert text != null; String anchor = "Modifiers"; if (text.length() > 0) { char firstChar = text.charAt(0); if (StringUtil.containsChar("msixpn", firstChar)) { anchor = "" + firstChar; } else if (StringUtil.containsChar("adlux", firstChar)) { anchor = "/" + firstChar; } else if (StringUtil.containsChar("cgeor", firstChar)) { anchor = "Other Modifiers"; } } return resolveDocLink("perlre/\"" + anchor + "\"", element); }
List<String> filter = ContainerUtil.filter(PhpNameSuggestionUtil.variableNameByType((Parameter) psiElement, psiElement.getProject(), false), s -> !StringUtil.containsChar(s, '\\'));
/** * Checks if lexer is at close tag with possible chomp modifier and returns close tag length * * @param buffer chars buffer * @param offset current offset * @param bufferEnd buffer end * @return close tag length or -1 of we are not at it */ protected int checkCloseTagAndGetLength(CharSequence buffer, int offset, int bufferEnd) { if (offset >= bufferEnd) { return -1; } String endTag = getEndTag(); if (isBufferAtString(buffer, offset, endTag)) { return endTag.length(); } if (StringUtil.containsChar(CHOMP_MODIFIERS, buffer.charAt(offset)) && isBufferAtString(buffer, offset + 1, endTag)) { return endTag.length() + 1; } return -1; }
@NotNull @Override public Result checkAutoPopup(char typedChar, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { int currentOffset = editor.getCaretModel().getOffset(); if (currentOffset > 0) { currentOffset--; } PsiElement element = file.findElementAt(currentOffset); if (element == null) { return super.checkAutoPopup(typedChar, project, editor, file); } IElementType elementType = PsiUtilCore.getElementType(element); if (typedChar == '>' && elementType == OPERATOR_MINUS || typedChar == ':' && elementType == COLON || typedChar == ' ' && (AUTO_OPENED_TOKENS.contains(elementType) || element.getParent() instanceof PsiPerlStringList) || typedChar == '{' && SIGILS.contains(elementType) || StringUtil.containsChar("$@%#", typedChar)) { AutoPopupController.getInstance(project).scheduleAutoPopup(editor); return Result.STOP; } return super.checkAutoPopup(typedChar, project, editor, file); } }
/** * We've met identifier (variable name) */ @NotNull protected IElementType getUnbracedVariableNameToken() { popState(); char currentChar; if ( !myParensStack.isEmpty() && yylength() == 1 && StringUtil.containsChar(",=)", currentChar = yytext().charAt(0)) && myParensStack.peek() == 1 && myParensStack.peekAdditional() == SUB_SIGNATURE) { if (currentChar == ',') { yybegin(YYINITIAL); return COMMA; } else if (currentChar == '=') { yybegin(BLOCK_AS_VALUE); return OPERATOR_ASSIGN; } else if (currentChar == ')') { return getRightParen(SUB_ATTRIBUTES); } } return getVariableNameTokenBySigil(); }
if (text.length() == 1 && StringUtil.containsChar(POD_COMMANDS, text.charAt(0))) { EditorModificationUtil.insertStringAtCaret(editor, ">", false, false, 0);