private static void setPosition(Position position, int[] coords) { assert coords.length == 2; position.setLine(coords[0]); position.setCharacter(coords[1]); }
private static Position createPosition(IDocument document, int offset) { Position start = new Position(); try { int lineOfOffset = document.getLineOfOffset(offset); start.setLine(Integer.valueOf(lineOfOffset)); start.setCharacter(Integer.valueOf(offset - document.getLineOffset(lineOfOffset))); } catch (BadLocationException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } return start; }
Position clone(Position position) { if (position == null) { return null; } int line = position.getLine(); int character = position.getCharacter(); Position cloned = new Position(); cloned.setLine(line); cloned.setCharacter(character); return cloned; } }
public Position toPosition(int offset) { int line = lineNumber(offset); int startOfLine = startOfLine(line); int column = offset - startOfLine; Position pos = new Position(); pos.setCharacter(column); pos.setLine(line); return pos; }
@SuppressWarnings("restriction") private static Range convertRange(IOpenable openable, IProblem problem) { try { return JDTUtils.toRange(openable, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); } catch (CoreException e) { // In case failed to open the IOpenable's buffer, use the IProblem's information to calculate the range. Position start = new Position(); Position end = new Position(); start.setLine(problem.getSourceLineNumber() - 1);// The protocol is 0-based. end.setLine(problem.getSourceLineNumber() - 1); if (problem instanceof DefaultProblem) { DefaultProblem dProblem = (DefaultProblem) problem; start.setCharacter(dProblem.getSourceColumnNumber() - 1); int offset = 0; if (dProblem.getSourceStart() != -1 && dProblem.getSourceEnd() != -1) { offset = dProblem.getSourceEnd() - dProblem.getSourceStart() + 1; } end.setCharacter(dProblem.getSourceColumnNumber() - 1 + offset); } return new Range(start, end); } }
public static Pair<BLangNode, Object> getBLangNode(int line, int column, String uri, WorkspaceDocumentManager documentManager, LSCompiler lsCompiler, LSContext context) { Position position = new Position(); position.setLine(line); position.setCharacter(column + 1); context.put(DocumentServiceKeys.FILE_URI_KEY, uri); TextDocumentIdentifier identifier = new TextDocumentIdentifier(uri); context.put(DocumentServiceKeys.POSITION_KEY, new TextDocumentPositionParams(identifier, position)); List<BLangPackage> bLangPackages = lsCompiler.getBLangPackages(context, documentManager, false, LSCustomErrorStrategy.class, true); // Get the current package. BLangPackage currentBLangPackage = CommonUtil.getCurrentPackageByFileName(bLangPackages, uri); context.put(DocumentServiceKeys.CURRENT_PACKAGE_NAME_KEY, currentBLangPackage.symbol.getName().getValue()); // Run the position calculator for the current package. PositionTreeVisitor positionTreeVisitor = new PositionTreeVisitor(context); currentBLangPackage.accept(positionTreeVisitor); return new ImmutablePair<>(context.get(NodeContextKeys.NODE_KEY), context.get(NodeContextKeys.PREVIOUSLY_VISITED_NODE_KEY)); }
ch = document.getChar(pos); range.getEnd().setCharacter(range.getEnd().getCharacter() + length); length = 1; pos = offset - 1; range.getStart().setCharacter(range.getStart().getCharacter() - length); replacement = checkReplacementEnd(document, replacement, offset); } else if (proposal.getKind() == CompletionProposal.ANONYMOUS_CLASS_CONSTRUCTOR_INVOCATION) { range.getEnd().setCharacter(range.getEnd().getCharacter() + length);
org.eclipse.lsp4j.Position position = dtoFactory.createDto(org.eclipse.lsp4j.Position.class); position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); renameParams.setPosition(position);
TextPosition cursorPosition = editor.getCursorPosition(); org.eclipse.lsp4j.Position position = dtoFactory.createDto(org.eclipse.lsp4j.Position.class); position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); params.setPosition(position);
position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); renameParams.setPosition(position);
TextPosition cursorPosition = editor.getCursorPosition(); org.eclipse.lsp4j.Position position = dtoFactory.createDto(org.eclipse.lsp4j.Position.class); position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); params.setPosition(position);
final Procedure1<Position> _function_3 = (Position it_2) -> { it_2.setLine(4); it_2.setCharacter(22); }; Position _doubleArrow_1 = ObjectExtensions.<Position>operator_doubleArrow(_position, _function_3);