Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[analysis_server] Extension has kind CLASS in search.getElementDeclarations #50603

Closed
sstasi95 opened this issue Dec 1, 2022 · 1 comment
Closed
Assignees
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request

Comments

@sstasi95
Copy link
Contributor

sstasi95 commented Dec 1, 2022

Hi,

The request search.getElementDeclarations returns kind CLASS for Extensions, but I think it should return kind EXTENSION.
Code to reproduce the issue (using package:analysis_server_lib):

import 'dart:async';
import 'dart:io';

import 'package:analysis_server_lib/analysis_server_lib.dart';
import 'package:path/path.dart' as path;

class ServerHelper {
  static Future<ServerHelper> create() async {
    return ServerHelper(await AnalysisServer.create());
  }

  final AnalysisServer server;
  Directory tempDir;
  Map<String, List<AnalysisError>> errors = {};

  ServerHelper(this.server) : tempDir = Directory.systemTemp.createTempSync('tests');

  Future init() {
    server.analysis.onErrors.listen((AnalysisErrors e) {
      if (e.errors.isEmpty) {
        errors.remove(e.file);
      } else {
        errors[e.file] = e.errors;
      }
    });

    server.server.setSubscriptions(['STATUS']);
    return server.analysis.setAnalysisRoots([tempDir.path], []);
  }

  Stream get onAnalysisFinished {
    return server.server.onStatus.where((ServerStatus status) {
      return status.analysis != null && status.analysis!.isAnalyzing == false;
    });
  }

  Future<String> createFile(String filePath, String text) {
    String fullPath = path.join(tempDir.path, filePath);
    return server.analysis.updateContent(
      {fullPath: new AddContentOverlay(text)},
    ).then((_) => fullPath);
  }

  void dispose() {
    server.dispose();
    tempDir.deleteSync(recursive: true);
  }
}

Future<void> main() async {
  final helper = await ServerHelper.create();
  await helper.init();
  String main = await helper.createFile('int_ext.dart', 'extension IntExt on int {}');

  final member = await helper.server.search.getElementDeclarations(file: main);
  for (final res in member.declarations) {
    print('${res.name} - ${res.kind}'); // prints IntExt - CLASS, but it should print IntExt - EXTENSION
  }

  helper.dispose();
}
  • analysis_server_lib version: 0.2.3
  • dart --version: Dart SDK version: 2.18.4 (stable) (Tue Nov 1 15:15:07 2022 +0000) on "macos_arm64"

Thanks,

Simone

@srawlins srawlins added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-server labels Dec 6, 2022
@scheglov scheglov self-assigned this Dec 6, 2022
@scheglov scheglov added the P3 A lower priority bug or feature request label Dec 6, 2022
@scheglov
Copy link
Contributor

scheglov commented Dec 6, 2022

copybara-service bot pushed a commit that referenced this issue Dec 7, 2022
…ations

Bug: #50603
Change-Id: I22b4d827bc9472544cf3c3aad3473de8050e2f6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274085
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov scheglov closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants