Skip to content
This repository was archived by the owner on Mar 6, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"phpactor/code-builder": "^0.4.1",
"phpactor/name-specification": "^0.1",
"phpactor/text-document": "^1.2.4",
"phpactor/worse-reflection": "^0.4.4",
"phpactor/worse-reflection": "^0.4.7",
"webmozart/path-util": "~2.3"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function diagnostics(SourceCode $code): Diagnostics
$namespaceDefinition = $rootNode->getFirstDescendantNode(NamespaceDefinition::class);
$diagnostics[] = new Diagnostic(
ByteOffsetRange::fromInts(
$namespaceDefinition ? $namespaceDefinition->getStart() : 0,
$namespaceDefinition ? $namespaceDefinition->getStartPosition() : 0,
$namespaceDefinition ? $namespaceDefinition->getEndPosition() : 0,
),
sprintf('Namespace should probably be "%s"', $correctNamespace),
Expand All @@ -92,7 +92,7 @@ public function diagnostics(SourceCode $code): Diagnostics

$diagnostics[] = new Diagnostic(
ByteOffsetRange::fromInts(
$classLike ? $classLike->getStart() : 0,
$classLike ? $classLike->getStartPosition() : 0,
$classLike ? $classLike->getEndPosition() : 0
),
sprintf('Class name should probably be "%s"', $correctClassName),
Expand Down Expand Up @@ -156,8 +156,8 @@ private function fixNamespace(SourceFileNode $rootNode, string $correctNamespace
}

return TextEdit::create(
$namespaceDefinition->getStart(),
$namespaceDefinition->getEndPosition() - $namespaceDefinition->getStart(),
$namespaceDefinition->getStartPosition(),
$namespaceDefinition->getEndPosition() - $namespaceDefinition->getStartPosition(),
$statement
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function extractExpression(SourceCode $source, int $offsetStart, ?int $of
return TextEdits::none();
}

$startPosition = $expression->getStart();
$startPosition = $expression->getStartPosition();
$endPosition = $expression->getEndPosition();

$extractedString = rtrim(trim($source->extractSelection($startPosition, $endPosition)), ';');
Expand Down Expand Up @@ -143,7 +143,7 @@ private function resolveEdits(
): array {
if ($statement instanceof ExpressionStatement && $statement->expression === $expression) {
return [
TextEdit::create($statement->getStart(), $statement->getWidth(), $assignment)
TextEdit::create($statement->getStartPosition(), $statement->getWidth(), $assignment)
];
}

Expand All @@ -154,8 +154,8 @@ private function resolveEdits(
}

return [
TextEdit::create($statement->getStart(), 0, $assignment . $indentation),
TextEdit::create($expression->getStart(), strlen($extractedString), '$' . $variableName),
TextEdit::create($statement->getStartPosition(), 0, $assignment . $indentation),
TextEdit::create($expression->getStartPosition(), strlen($extractedString), '$' . $variableName),
];
}

Expand All @@ -169,7 +169,7 @@ private function outerExpression(Node $node, Node $originalNode = null): ?Expres
return $node instanceof Expression ? $node : null;
}

if ($parent->getStart() !== $originalNode->getStart() && $originalNode instanceof Expression) {
if ($parent->getStartPosition() !== $originalNode->getStartPosition() && $originalNode instanceof Expression) {
return $originalNode;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Adapter/TolerantParser/Refactor/TolerantImportName.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ private function updateReferences(Node $node, NameImport $nameImport, TextEdits
}

return $edits->add(TextEdit::create(
$node->getStart(),
$node->getEndPosition() - $node->getStart(),
$node->getStartPosition(),
$node->getEndPosition() - $node->getStartPosition(),
$alias
));
}
Expand Down Expand Up @@ -224,7 +224,7 @@ private function getLastNodeAtPosition(SourceFileNode $sourceNode, ByteOffset $o
if ($node instanceof SourceFileNode) {
/** @var Node $childNode */
foreach ($node->getChildNodes() as $childNode) {
if ($childNode->getStart() > $offset->toInt()) {
if ($childNode->getStartPosition() > $offset->toInt()) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ private function textEditForRenameFromNode(Node $variable, Node $node, string $n

if ($node instanceof Variable || $node instanceof UseVariableName) {
return TextEdit::create(
$node->getStart(),
$node->getEndPosition() - $node->getStart(),
$node->getStartPosition(),
$node->getEndPosition() - $node->getStartPosition(),
'$' . $newName
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function find(TextDocument $source, ByteOffset $offset): ByteOffset
$node = $this->parser->parseSourceFile($source->__toString())->getDescendantNodeAtPosition($offset->toInt());

do {
$offset = ByteOffset::fromInt($node->getStart());
$offset = ByteOffset::fromInt($node->getStartPosition());

if ($interestingOffset = $this->resolveInterestingOffset($source, $offset)) {
return $interestingOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private function appendUnresolvedClassName(string $nameText, array $unresolvedNa
$notFoundCache[$cacheKey] = $notFound;
$unresolvedNames[] = new NameWithByteOffset(
PhpactorQualifiedName::fromString($nameText),
ByteOffset::fromInt($name->getStart()),
ByteOffset::fromInt($name->getStartPosition()),
NameWithByteOffset::TYPE_CLASS
);
}
Expand All @@ -179,7 +179,7 @@ private function appendUnresolvedFunctionName(string $nameText, array $unresolve
$notFoundCache[$cacheKey] = $notFound;
$unresolvedNames[] = new NameWithByteOffset(
PhpactorQualifiedName::fromString($nameText),
ByteOffset::fromInt($name->getStart()),
ByteOffset::fromInt($name->getStartPosition()),
NameWithByteOffset::TYPE_FUNCTION
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Adapter/WorseReflection/Refactor/WorseExtractConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ private function replaceValues(SourceCode $sourceCode, int $offset, string $cons

if ($targetValue == $this->getComparableValue($node)) {
$textEdits[] = TextEdit::create(
$node->getStart(),
$node->getEndPosition() - $node->getStart(),
$node->getStartPosition(),
$node->getEndPosition() - $node->getStartPosition(),
'self::' . $constantName
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function canExtractMethod(SourceCode $source, int $offsetStart, int $offs
) {
$stmt = current($startNode->statements);
assert($stmt instanceof Node);
while ($stmt && $stmt->getStart() < $offsetStart) {
while ($stmt && $stmt->getStartPosition() < $offsetStart) {
$stmt = next($startNode->statements);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function transform(SourceCode $code): TextEdits
$classBuilder = $this->resolveClassBuilder($sourceBuilder, $class);

foreach ($this->missingPropertyNames($rootNode, $class) as [$memberName, $token, $expression]) {
$offset = $this->reflector->reflectOffset($code->__toString(), $expression->getStart());
$offset = $this->reflector->reflectOffset($code->__toString(), $expression->getStartPosition());
$propertyBuilder = $classBuilder
->property($memberName)
->visibility('private');
Expand Down