public void beforeCompletion(@NotNull CompletionInitializationContext context) { boolean acceptPathSeparator = false; { final int offset = context.getEditor().getCaretModel().getOffset(); PsiElement element = context.getFile().findElementAt(offset); if (element != null) { int prefixLength = offset - element.getTextRange().getStartOffset(); BipartiteString caretBipartiteElementText = splitByPrefixLength(element.getText(), prefixLength); Character separator = extractDirectoryTrailingFileSeparator(caretBipartiteElementText); acceptPathSeparator = separator != null; } } final OffsetMap offsetMap = context.getOffsetMap(); int idEnd = offsetMap.getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET); final String text = context.getFile().getText(); while (idEnd < text.length()) { final char ch = text.charAt(idEnd); if (acceptPathSeparator) { if (ch == JstdConfigFileUtils.UNIX_PATH_SEPARATOR || ch == JstdConfigFileUtils.WINDOWS_PATH_SEPARATOR) { idEnd++; break; } } boolean acceptedChar = Character.isJavaIdentifierPart(ch) || IDENTIFIER_END_PATTERN.indexOf(ch) >= 0; if (acceptedChar) { idEnd++; } else { break; } } offsetMap.addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, idEnd); }
protected TextRegion getSelection(final CompletionParameters parameters) { TextRegion _xblockexpression = null; { final OffsetMap offsets = this.getOffsets(parameters); final int startOffset = offsets.getOffset(CompletionInitializationContext.START_OFFSET); final int endOffset = offsets.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET); _xblockexpression = new TextRegion(startOffset, (endOffset - startOffset)); } return _xblockexpression; }