Package com.jetbrains.lang.dart.psi

Examples of com.jetbrains.lang.dart.psi.DartReference


    final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (project == null || editor == null) return null;

    final PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    final PsiElement psiElement = file == null ? null : file.findElementAt(editor.getCaretModel().getOffset());
    final DartReference dartReference = PsiTreeUtil.getParentOfType(psiElement, DartReference.class);
    if (dartReference != null) {
      return dartReference.resolveDartClass().getDartClass();
    }
    return PsiTreeUtil.getParentOfType(psiElement, DartClass.class);
  }
View Full Code Here


import java.util.Collections;
import java.util.List;

public class DartFixesUtil {
  public static boolean isStaticContext(PsiFile file, int startOffset) {
    DartReference leftReference =
      DartResolveUtil.getLeftReference(PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), DartReference.class));
    return leftReference != null && DartComponentType.typeOf(leftReference.resolve()) == DartComponentType.CLASS;
  }
View Full Code Here

      DartResolveUtil.getLeftReference(PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), DartReference.class));
    return leftReference != null && DartComponentType.typeOf(leftReference.resolve()) == DartComponentType.CLASS;
  }

  public static List<BaseCreateFix> findFixesForUnresolved(PsiFile file, int startOffset) {
    final DartReference reference = PsiTreeUtil.getParentOfType(file.findElementAt(startOffset), DartReference.class);
    final String name = reference != null ? reference.getText() : null;
    if (reference == null || name == null) {
      return Collections.emptyList();
    }
    final boolean isLValue = DartResolveUtil.isLValue(reference);
    final DartReference leftReference = DartResolveUtil.getLeftReference(reference);

    final List<BaseCreateFix> result = new ArrayList<BaseCreateFix>();

    // chain
    if (leftReference != null) {
      final PsiElement leftTarget = leftReference.resolve();
      final DartComponentType leftTargetType = DartComponentType.typeOf(leftTarget != null ? leftTarget.getParent() : null);
      result.add(new CreateDartGetterSetterAction(name, !isLValue, leftTargetType == DartComponentType.CLASS));
      result.add(new CreateFieldAction(name, leftTargetType == DartComponentType.CLASS));
      if (DartResolveUtil.aloneOrFirstInChain(reference)) {
        result.add(new CreateGlobalDartGetterSetterAction(name, false));
View Full Code Here

  }

  @Nullable
  @Override
  protected PsiElement findAnchor(PsiElement element) {
    DartReference leftReference = DartResolveUtil.getLeftReference(PsiTreeUtil.getParentOfType(element, DartReference.class));
    return leftReference == null ? super.findAnchor(element) : DartResolveUtil.getBody(leftReference.resolveDartClass().getDartClass());
  }
View Full Code Here

  }

  @Nullable
  @Override
  protected PsiElement findAnchor(PsiElement element) {
    DartReference leftReference = DartResolveUtil.getLeftReference(PsiTreeUtil.getParentOfType(element, DartReference.class));
    return leftReference == null ? super.findAnchor(element) : DartResolveUtil.getBody(leftReference.resolveDartClass().getDartClass());
  }
View Full Code Here

TOP

Related Classes of com.jetbrains.lang.dart.psi.DartReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.