use of com.jetbrains.lang.dart.psi.DartId in project intellij-plugins by JetBrains.
the class DartTestLocationProviderTest method doTest.
private void doTest(@NotNull final String locationHint, @NotNull final String fileContents) {
final int caretOffset = fileContents.indexOf("<caret>");
assertTrue(caretOffset != -1);
final String realContents = fileContents.substring(0, caretOffset) + fileContents.substring(caretOffset + "<caret>".length());
myFixture.configureByText("test.dart", realContents);
final PsiFile file = myFixture.getFile();
final PsiElement elementAtOffset = file.findElementAt(caretOffset);
final PsiElement targetId = elementAtOffset == null ? null : elementAtOffset.getParent();
final List<Location> locations = DartTestLocationProvider.INSTANCE.getLocationForTest(file, locationHint);
assertEquals(1, locations.size());
final Location location = locations.get(0);
final PsiElement element = location.getPsiElement();
final DartId foundId = PsiTreeUtil.findChildOfType(element, DartId.class);
assertEquals(targetId, foundId);
}
use of com.jetbrains.lang.dart.psi.DartId in project intellij-plugins by JetBrains.
the class DartNamedElementImpl method setName.
@Override
public PsiElement setName(@NonNls @NotNull String newElementName) throws IncorrectOperationException {
final DartId identifier = getId();
final DartId identifierNew = DartElementGenerator.createIdentifierFromText(getProject(), newElementName);
if (identifierNew != null) {
getNode().replaceChild(identifier.getNode(), identifierNew.getNode());
}
return this;
}
use of com.jetbrains.lang.dart.psi.DartId in project intellij-plugins by JetBrains.
the class DartLibraryComponentReferenceExpressionBase method handleElementRename.
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
final DartId identifier = PsiTreeUtil.getChildOfType(this, DartId.class);
final DartId identifierNew = DartElementGenerator.createIdentifierFromText(getProject(), newElementName);
if (identifier != null && identifierNew != null) {
getNode().replaceChild(identifier.getNode(), identifierNew.getNode());
}
return this;
}
Aggregations