Search in sources :

Example 21 with DartAnalysisServerService

use of com.jetbrains.lang.dart.analyzer.DartAnalysisServerService in project intellij-plugins by JetBrains.

the class QuickAssistSet method getQuickAssists.

public List<SourceChange> getQuickAssists(@NotNull final Editor editor, @NotNull final PsiFile psiFile) {
    final long psiModificationCount = psiFile.getManager().getModificationTracker().getModificationCount();
    final String filePath = psiFile.getVirtualFile().getPath();
    final Caret currentCaret = editor.getCaretModel().getPrimaryCaret();
    final int offset = currentCaret.getSelectionStart();
    final int length = currentCaret.getSelectionEnd() - offset;
    if (lastPsiModificationCount == psiModificationCount && ObjectUtilities.equals(lastFilePath, filePath) && lastOffset == offset && lastLength == length) {
        return lastSourceChanges;
    }
    lastFilePath = filePath;
    lastOffset = offset;
    lastLength = length;
    lastPsiModificationCount = psiModificationCount;
    final DartAnalysisServerService service = DartAnalysisServerService.getInstance(psiFile.getProject());
    service.updateFilesContent();
    lastSourceChanges = service.edit_getAssists(psiFile.getVirtualFile(), offset, length);
    return lastSourceChanges;
}
Also used : DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService) Caret(com.intellij.openapi.editor.Caret)

Example 22 with DartAnalysisServerService

use of com.jetbrains.lang.dart.analyzer.DartAnalysisServerService in project intellij-plugins by JetBrains.

the class ReanalyzeDartSourcesAction method actionPerformed.

@Override
public void actionPerformed(@NotNull final AnActionEvent e) {
    final Project project = e.getProject();
    if (isApplicable(project)) {
        DartAnalysisServerService das = DartAnalysisServerService.getInstance(project);
        if (das.isServerProcessActive()) {
            das.analysis_reanalyze();
        } else {
            // Ensure the server is properly stopped.
            das.restartServer();
            // The list of projects was probably lost when the server crashed. Prime it with the current project to get the server restarted.
            das.serverReadyForRequest(project);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)

Aggregations

DartAnalysisServerService (com.jetbrains.lang.dart.analyzer.DartAnalysisServerService)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)11 Project (com.intellij.openapi.project.Project)3 TextRange (com.intellij.openapi.util.TextRange)3 PsiFile (com.intellij.psi.PsiFile)3 Document (com.intellij.openapi.editor.Document)2 PsiElement (com.intellij.psi.PsiElement)2 UsageInfo (com.intellij.usageView.UsageInfo)2 DartServerData (com.jetbrains.lang.dart.analyzer.DartServerData)2 SourceChange (org.dartlang.analysis.server.protocol.SourceChange)2 SourceEdit (org.dartlang.analysis.server.protocol.SourceEdit)2 SourceFileEdit (org.dartlang.analysis.server.protocol.SourceFileEdit)2 GetServerPortConsumer (com.google.dart.server.GetServerPortConsumer)1 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 PsiElement2UsageTargetAdapter (com.intellij.find.findUsages.PsiElement2UsageTargetAdapter)1 ASTNode (com.intellij.lang.ASTNode)1 Annotation (com.intellij.lang.annotation.Annotation)1 AnnotationSession (com.intellij.lang.annotation.AnnotationSession)1 Notification (com.intellij.notification.Notification)1 Caret (com.intellij.openapi.editor.Caret)1