Skip to content

Error reporting #863

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
107f9c3
Bugfix in Dart Analysis Server completion support, don't call complet…
alexander-doroshko Mar 2, 2022
b7caf4c
Call the Dart Analysis Server via dart language-server
alexander-doroshko Mar 2, 2022
21081a7
RUBY-29359 sync `i18n.json`.
Feb 28, 2022
d33b089
RUBY-29359 add a new russian translation for "examples".
Feb 28, 2022
36728d4
IDEA-248152 do not run TODO patterns on indexing
gregsh Mar 5, 2022
1a1695b
CPP-24010 Use the standard JUnit API where appropriate
0x6675636b796f75676974687562 Mar 3, 2022
18c27e4
WEB-54703 The Dart plugin should use .dart_tool/package_config.json, …
alexander-doroshko Mar 9, 2022
e690a98
decouple id and todo scanning
gregsh Mar 10, 2022
f29b888
notnull
cdracm Mar 10, 2022
d011695
[vue] suppress false errors reported by TypeScript language service (…
tomblachut Mar 14, 2022
f82f149
js: make inspection "fix only" WEB-55121
anstarovoyt Mar 14, 2022
7107219
[vue] prevent occasional SOE in NuxtDotFolderSyntheticLibraryProvider…
tomblachut Mar 14, 2022
afea219
[diagrams] WIP on Analyze graph actions
Mar 15, 2022
fc73f94
perforce: use global listener to close annotations on file changes
AMPivovarov Mar 10, 2022
ec68d92
vcs: deprecate FileAnnotation.dispose() method
AMPivovarov Mar 10, 2022
dfe1882
update gradle to 7.4.1
nexoscp Mar 20, 2022
0ac45ba
port gradle build from groovy to kotlin
nexoscp Mar 20, 2022
e25fd95
fixed wired annotations
nexoscp Mar 20, 2022
cf5034c
show error message from calling 'platformio'
nexoscp Mar 20, 2022
2921b9b
some ref
nexoscp Mar 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
public class Angular2HtmlIdIndexer implements LexingIdIndexer {
@Override
public @NotNull Map<IdIndexEntry, Integer> map(@NotNull FileContent inputData) {
return BaseFilterLexerUtil.scanContent(inputData, consumer ->
return BaseFilterLexerUtil.calcIdEntries(inputData, consumer ->
new Angular2HtmlFilterLexer(consumer, SyntaxHighlighterFactory.getSyntaxHighlighter(
Angular2HtmlLanguage.INSTANCE, inputData.getProject(), inputData.getFile()).getHighlightingLexer())).idMap;
Angular2HtmlLanguage.INSTANCE, inputData.getProject(), inputData.getFile()).getHighlightingLexer()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
public class Angular2HtmlTodoIndexer extends VersionedTodoIndexer {
@Override
public @NotNull Map<TodoIndexEntry, Integer> map(@NotNull FileContent inputData) {
return BaseFilterLexerUtil.scanContent(inputData, consumer ->
return BaseFilterLexerUtil.calcTodoEntries(inputData, consumer ->
new Angular2HtmlFilterLexer(consumer, SyntaxHighlighterFactory.getSyntaxHighlighter(
Angular2HtmlLanguage.INSTANCE, inputData.getProject(), inputData.getFile()).getHighlightingLexer())).todoMap;
Angular2HtmlLanguage.INSTANCE, inputData.getProject(), inputData.getFile()).getHighlightingLexer()));
}

@Override
Expand Down
4 changes: 3 additions & 1 deletion AngularJS/test/org/angular2/codeInsight/InspectionsTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.angular2.codeInsight;

import com.intellij.codeHighlighting.HighlightDisplayLevel;
import com.intellij.codeInsight.daemon.impl.analysis.HtmlUnknownTargetInspection;
import com.intellij.htmltools.codeInspection.htmlInspections.HtmlFormInputWithoutLabelInspection;
import com.intellij.lang.javascript.JSTestUtils;
import com.intellij.lang.javascript.inspections.*;
import com.intellij.lang.typescript.inspections.TypeScriptUnresolvedFunctionInspection;
import com.intellij.lang.typescript.inspections.TypeScriptUnresolvedVariableInspection;
Expand Down Expand Up @@ -34,7 +36,7 @@ public void testUnusedSetter() {

public void testMethodCanBeStatic() {
JSMethodCanBeStaticInspection canBeStaticInspection = new JSMethodCanBeStaticInspection();
canBeStaticInspection.myOnlyPrivate = false;
JSTestUtils.setInspectionHighlightLevel(getProject(), canBeStaticInspection, HighlightDisplayLevel.WARNING, getTestRootDisposable());
myFixture.enableInspections(canBeStaticInspection);
myFixture.configureByFiles("methodCanBeStatic.ts", "methodCanBeStatic.html", "package.json");
myFixture.checkHighlighting();
Expand Down
47 changes: 23 additions & 24 deletions Dart/src/com/jetbrains/lang/dart/DartFileListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ public ChangeApplier prepareChange(@NotNull List<? extends @NotNull VFileEvent>

if (event instanceof VFilePropertyChangeEvent) {
if (((VFilePropertyChangeEvent)event).isRename()) {
if (DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getOldValue()) ||
if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getOldValue()) ||
DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(((VFilePropertyChangeEvent)event).getNewValue()) ||
DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getOldValue()) ||
DotPackagesFileUtil.DOT_PACKAGES.equals(((VFilePropertyChangeEvent)event).getNewValue())) {
dotPackageEvents.add(event);
}
Expand All @@ -80,7 +82,8 @@ public ChangeApplier prepareChange(@NotNull List<? extends @NotNull VFileEvent>
}
}
else {
if (DotPackagesFileUtil.DOT_PACKAGES.equals(PathUtil.getFileName(event.getPath()))) {
if (DotPackagesFileUtil.PACKAGE_CONFIG_JSON.equals(PathUtil.getFileName(event.getPath())) ||
DotPackagesFileUtil.DOT_PACKAGES.equals(PathUtil.getFileName(event.getPath()))) {
dotPackageEvents.add(event);
}

Expand Down Expand Up @@ -155,16 +158,24 @@ private static DartLibInfo collectPackagesLibraryRoots(@NotNull final Project pr
final Module module = fileIndex.getModuleForFile(pubspecFile);
if (module == null || !DartSdkLibUtil.isDartSdkEnabled(module)) continue;

final VirtualFile dotPackagesFile = findDotPackagesFile(pubspecFile.getParent());
if (dotPackagesFile != null) {
final Map<String, String> packagesMap = DotPackagesFileUtil.getPackagesMap(dotPackagesFile);
if (packagesMap != null) {
for (Map.Entry<String, String> entry : packagesMap.entrySet()) {
final String packageName = entry.getKey();
final String packagePath = entry.getValue();
if (isPathOutsideProjectContent(fileIndex, packagePath)) {
libInfo.addPackage(packageName, packagePath);
}
Map<String, String> packagesMap = null;
VirtualFile packagesFile = DotPackagesFileUtil.findPackageConfigJsonFile(pubspecFile.getParent());
if (packagesFile != null) {
packagesMap = DotPackagesFileUtil.getPackagesMapFromPackageConfigJsonFile(packagesFile);
}
else {
packagesFile = DotPackagesFileUtil.findDotPackagesFile(pubspecFile.getParent());
if (packagesFile != null) {
packagesMap = DotPackagesFileUtil.getPackagesMap(packagesFile);
}
}

if (packagesMap != null) {
for (Map.Entry<String, String> entry : packagesMap.entrySet()) {
final String packageName = entry.getKey();
final String packagePath = entry.getValue();
if (isPathOutsideProjectContent(fileIndex, packagePath)) {
libInfo.addPackage(packageName, packagePath);
}
}
}
Expand All @@ -173,18 +184,6 @@ private static DartLibInfo collectPackagesLibraryRoots(@NotNull final Project pr
return libInfo;
}

@Nullable
private static VirtualFile findDotPackagesFile(@Nullable VirtualFile dir) {
while (dir != null) {
final VirtualFile file = dir.findChild(DotPackagesFileUtil.DOT_PACKAGES);
if (file != null && !file.isDirectory()) {
return file;
}
dir = dir.getParent();
}
return null;
}

@NotNull
public static Library updatePackagesLibraryRoots(@NotNull final Project project, @NotNull final DartLibInfo libInfo) {
final LibraryTable projectLibraryTable = LibraryTablesRegistrar.getInstance().getLibraryTable(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public final class DartAnalysisServerService implements Disposable {
// https://github.com/dart-lang/webdev/blob/master/webdev/pubspec.yaml#L11
public static final String MIN_WEBDEV_SDK_VERSION = "2.6.0";

// As of the Dart SDK version 2.8.0, the file .dart_tool/package_config.json is preferred over the .packages file.
// https://github.com/dart-lang/sdk/issues/48272
public static final String MIN_PACKAGE_CONFIG_JSON_SDK_VERSION = "2.8.0";

// The dart cli command provides a language server command, `dart language-server`, which
// should be used going forward instead of `dart .../analysis_server.dart.snapshot`.
public static final String MIN_DART_LANG_SERVER_SDK_VERSION = "2.16.0";

private static final long UPDATE_FILES_TIMEOUT = 300;

private static final long CHECK_CANCELLED_PERIOD = 10;
Expand Down Expand Up @@ -300,6 +308,11 @@ public void computedSearchResults(String searchId, List<SearchResult> results, b
@Override
public void serverConnected(@Nullable String version) {
myServerVersion = version != null ? version : "";
// completion_setSubscriptions() are handled here instead of in startServer() as the server version isn't known until this
// serverConnected() call.
if (myServer != null && !shouldUseCompletion2()) {
myServer.completion_setSubscriptions(List.of(CompletionService.AVAILABLE_SUGGESTION_SETS));
}
}

@Override
Expand Down Expand Up @@ -450,6 +463,14 @@ public static boolean isDartSdkVersionSufficientForWebdev(@NotNull final DartSdk
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_WEBDEV_SDK_VERSION) >= 0;
}

public static boolean isDartSdkVersionSufficientForPackageConfigJson(@NotNull final DartSdk sdk) {
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_PACKAGE_CONFIG_JSON_SDK_VERSION) >= 0;
}

public static boolean isDartSdkVersionSufficientForDartLangServer(@NotNull final DartSdk sdk) {
return StringUtil.compareVersionNumbers(sdk.getVersion(), MIN_DART_LANG_SERVER_SDK_VERSION) >= 0;
}

public boolean shouldUseCompletion2() {
return StringUtil.compareVersionNumbers(getServerVersion(), COMPLETION_2_SERVER_VERSION) >= 0;
}
Expand Down Expand Up @@ -1573,20 +1594,21 @@ public void computedSuggestions(int replacementOffset,

for (DartCompletionTimerExtension extension : DartCompletionTimerExtension.getExtensions()) {
extension.dartCompletionEnd();
}
}
}
}

@Override
public void onError(@NotNull final RequestError error) {
// Not a problem. Happens if a file is outside the project, or server is just not ready yet.
latch.countDown();
@Override
public void onError(@NotNull final RequestError error) {
// Not a problem. Happens if a file is outside the project, or server is just not ready yet.
latch.countDown();

for (DartCompletionTimerExtension extension : DartCompletionTimerExtension.getExtensions()) {
extension.dartCompletionError(StringUtil.notNullize(error.getCode()), StringUtil.notNullize(error.getMessage()),
StringUtil.notNullize(error.getStackTrace()));
}
}
});
for (DartCompletionTimerExtension extension : DartCompletionTimerExtension.getExtensions()) {
extension.dartCompletionError(StringUtil.notNullize(error.getCode()),
StringUtil.notNullize(error.getMessage()),
StringUtil.notNullize(error.getStackTrace()));
}
}
});

awaitForLatchCheckingCanceled(server, latch, GET_SUGGESTIONS_TIMEOUT);

Expand Down Expand Up @@ -2013,6 +2035,9 @@ private void startServer(@NotNull final DartSdk sdk) {

final String runtimePath = FileUtil.toSystemDependentName(DartSdkUtil.getDartExePath(sdk));

// If true, then the DAS will be started via `dart language-server`, instead of `dart .../analysis_server.dart.snapshot`
final boolean useDartLangServerCall = isDartSdkVersionSufficientForDartLangServer(sdk);

String analysisServerPath = FileUtil.toSystemDependentName(mySdkHome + "/bin/snapshots/analysis_server.dart.snapshot");
analysisServerPath = System.getProperty("dart.server.path", analysisServerPath);

Expand All @@ -2022,15 +2047,16 @@ private void startServer(@NotNull final DartSdk sdk) {
if (!runtimePathFile.exists()) {
dasStartupErrorMessage = DartBundle.message("dart.vm.file.does.not.exist.at.0", runtimePath);
}
else if (!dasSnapshotFile.exists()) {
else if (!useDartLangServerCall && !dasSnapshotFile.exists()) {
dasStartupErrorMessage = DartBundle.message("analysis.server.snapshot.file.does.not.exist.at.0", analysisServerPath);
}
else if (!runtimePathFile.canExecute()) {
dasStartupErrorMessage = DartBundle.message("dart.vm.file.is.not.executable.at.0", runtimePath);
}
else if (!dasSnapshotFile.canRead()) {
else if (!useDartLangServerCall && !dasSnapshotFile.canRead()) {
dasStartupErrorMessage = DartBundle.message("analysis.server.snapshot.file.is.not.readable.at.0", analysisServerPath);
}

if (!dasStartupErrorMessage.isEmpty()) {
LOG.warn("Failed to start Dart analysis server: " + dasStartupErrorMessage);
stopServer();
Expand Down Expand Up @@ -2060,10 +2086,16 @@ else if (!dasSnapshotFile.canRead()) {
vmArgsRaw = "";
}

@NonNls String serverArgsRaw = "";
// Note that as of Dart 2.12.0 the '--useAnalysisHighlight2' flag is ignored (and is the
// default highlighting mode). We still want to pass it in for earlier SDKs.
serverArgsRaw += " --useAnalysisHighlight2";
@NonNls String serverArgsRaw;
if (useDartLangServerCall) {
serverArgsRaw = "--protocol=analyzer";
}
else {
// Note that as of Dart 2.12.0 the '--useAnalysisHighlight2' flag is ignored (and is the
// default highlighting mode). We still want to pass it in for earlier SDKs.
serverArgsRaw = "--useAnalysisHighlight2";
}

try {
serverArgsRaw += " " + Registry.stringValue("dart.server.additional.arguments");
}
Expand All @@ -2076,8 +2108,9 @@ else if (!dasSnapshotFile.canRead()) {
// serverArgsRaw += " --enable-completion-model";
//}

String firstArgument = useDartLangServerCall ? "language-server" : analysisServerPath;
myServerSocket =
new StdioServerSocket(runtimePath, StringUtil.split(vmArgsRaw, " "), analysisServerPath, StringUtil.split(serverArgsRaw, " "),
new StdioServerSocket(runtimePath, StringUtil.split(vmArgsRaw, " "), firstArgument, StringUtil.split(serverArgsRaw, " "),
debugStream);
myServerSocket.setClientId(getClientId());
myServerSocket.setClientVersion(getClientVersion());
Expand All @@ -2088,10 +2121,6 @@ else if (!dasSnapshotFile.canRead()) {
startedServer.start();
server_setSubscriptions(startedServer);

if (!shouldUseCompletion2()) {
startedServer.completion_setSubscriptions(List.of(CompletionService.AVAILABLE_SUGGESTION_SETS));
}

if (!myInitializationOnServerStartupDone) {
myInitializationOnServerStartupDone = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public void processTransferableData(@NotNull final Project project,
@NotNull final Editor editor,
@NotNull final RangeMarker bounds,
final int caretOffset,
final Ref<? super Boolean> indented,
final List<? extends DartImportsTransferableData> values) {
final @NotNull Ref<? super Boolean> indented,
final @NotNull List<? extends DartImportsTransferableData> values) {
final DartImportsTransferableData data = ContainerUtil.getFirstItem(values);
if (data == null) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.jetbrains.lang.dart.DartBundle;
import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService;
import com.jetbrains.lang.dart.flutter.FlutterUtil;
import com.jetbrains.lang.dart.ide.actions.DartPubActionBase;
import com.jetbrains.lang.dart.psi.DartFile;
Expand Down Expand Up @@ -67,13 +68,15 @@ public final class DartOutdatedDependenciesInspection extends LocalInspectionToo

if (FlutterUtil.isPubspecDeclaringFlutter(pubspecFile)) return null; // 'pub get' will fail anyway

final VirtualFile dotPackagesFile = pubspecFile.getParent().findChild(DotPackagesFileUtil.DOT_PACKAGES);
VirtualFile packagesFile = DartAnalysisServerService.isDartSdkVersionSufficientForPackageConfigJson(sdk)
? DotPackagesFileUtil.getPackageConfigJsonFile(pubspecFile)
: pubspecFile.getParent().findChild(DotPackagesFileUtil.DOT_PACKAGES);

if (dotPackagesFile == null) {
if (packagesFile == null) {
return createProblemDescriptors(manager, psiFile, pubspecFile, DartBundle.message("pub.get.never.done"));
}

if (FileDocumentManager.getInstance().isFileModified(pubspecFile) || pubspecFile.getTimeStamp() > dotPackagesFile.getTimeStamp()) {
if (FileDocumentManager.getInstance().isFileModified(pubspecFile) || pubspecFile.getTimeStamp() > packagesFile.getTimeStamp()) {
return createProblemDescriptors(manager, psiFile, pubspecFile, DartBundle.message("pubspec.edited"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReferenceSet;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.jetbrains.lang.dart.analyzer.DartAnalysisServerService;
import com.jetbrains.lang.dart.sdk.DartSdk;
import com.jetbrains.lang.dart.util.DartResolveUtil;
import com.jetbrains.lang.dart.util.DartUrlResolver;
import com.jetbrains.lang.dart.util.DotPackagesFileUtil;
Expand All @@ -23,11 +25,11 @@
class DartPackageAwareFileReference extends FileReference {
@NotNull private final DartUrlResolver myDartResolver;

DartPackageAwareFileReference(@NotNull final FileReferenceSet fileReferenceSet,
final TextRange range,
final int index,
final String text,
@NotNull final DartUrlResolver dartResolver) {
DartPackageAwareFileReference(@NotNull FileReferenceSet fileReferenceSet,
TextRange range,
int index,
String text,
@NotNull DartUrlResolver dartResolver) {
super(fileReferenceSet, range, index, text);
myDartResolver = dartResolver;
}
Expand All @@ -41,8 +43,22 @@ class DartPackageAwareFileReference extends FileReference {
if (psiDirectory != null) {
return new ResolveResult[]{new PsiElementResolveResult(psiDirectory)};
}
VirtualFile dotPackages = pubspecYamlFile == null ? null : pubspecYamlFile.getParent().findChild(DotPackagesFileUtil.DOT_PACKAGES);
final PsiFile psiFile = dotPackages == null ? null : containingFile.getManager().findFile(dotPackages);

DartSdk sdk = DartSdk.getDartSdk(containingFile.getProject());
VirtualFile packagesFile;
if (sdk != null && pubspecYamlFile != null) {
if (DartAnalysisServerService.isDartSdkVersionSufficientForPackageConfigJson(sdk)) {
packagesFile = DotPackagesFileUtil.getPackageConfigJsonFile(pubspecYamlFile);
}
else {
packagesFile = pubspecYamlFile.getParent().findChild(DotPackagesFileUtil.DOT_PACKAGES);
}
}
else {
packagesFile = null;
}

final PsiFile psiFile = packagesFile == null ? null : containingFile.getManager().findFile(packagesFile);
if (psiFile != null) {
return new ResolveResult[]{new PsiElementResolveResult(psiFile)};
}
Expand Down
Loading