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; }
public PositionTreeVisitor(LSContext context) { this.context = context; this.position = context.get(DocumentServiceKeys.POSITION_KEY).getPosition(); this.symTable = SymbolTable.getInstance(context.get(DocumentServiceKeys.COMPILER_CONTEXT_KEY)); this.position.setLine(this.position.getLine() + 1); this.nodeStack = new Stack<>(); this.context.put(NodeContextKeys.NODE_STACK_KEY, nodeStack); }
@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)); }
dtoFactory.createDto(org.eclipse.lsp4j.Position.class); position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); renameParams.setPosition(position); renameSettings.setRenameKind(RenameKind.JAVA_ELEMENT);
org.eclipse.lsp4j.Position position = dtoFactory.createDto(org.eclipse.lsp4j.Position.class); position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); params.setPosition(position); String location =
position.setLine(cursorPosition.getLine()); renameParams.setPosition(position);
org.eclipse.lsp4j.Position position = dtoFactory.createDto(org.eclipse.lsp4j.Position.class); position.setCharacter(cursorPosition.getCharacter()); position.setLine(cursorPosition.getLine()); params.setPosition(position); params.setRenameKind(RenameKind.JAVA_ELEMENT);
Position _position = new Position(); final Procedure1<Position> _function_3 = (Position it_2) -> { it_2.setLine(4); it_2.setCharacter(22); };