Search in sources :

Example 1 with DartId

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);
}
Also used : PsiFile(com.intellij.psi.PsiFile) DartId(com.jetbrains.lang.dart.psi.DartId) PsiElement(com.intellij.psi.PsiElement) Location(com.intellij.execution.Location)

Example 2 with DartId

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;
}
Also used : DartId(com.jetbrains.lang.dart.psi.DartId)

Example 3 with DartId

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;
}
Also used : DartId(com.jetbrains.lang.dart.psi.DartId)

Aggregations

DartId (com.jetbrains.lang.dart.psi.DartId)3 Location (com.intellij.execution.Location)1 PsiElement (com.intellij.psi.PsiElement)1 PsiFile (com.intellij.psi.PsiFile)1