question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Classes compile outside vscode in CLI, but in vs-code problem section displays errors and editor highlights code lines in red

See original GitHub issue

Java Code is compiling neatly, outside the Vs-Code IDE i.e., from command line and other IDE’s like IntelliJ, but when I import my project into VS-Code there are some errors displayed in problems section. Some of them are shown here with screenshots

Environment
  • Operating System: Windows 10
  • JDK version: 1.8 - J9 VM
  • Visual Studio Code version: 1.47.2
  • Java extension version: v0.64
  • Build tool: Gradle, wrapper version, 4.8.1
Steps To Reproduce the
  1. Create a project having src/main/resources and add your java code directly inside src\main
  2. Java Model Exception: Java Model Status [Cannot nest '<project>/src/main/resources' inside '<project>/src/main'. To enable the nesting exclude 'resources/' from 'junit_tests/src/main']
Current Result
  • Below is the Java language server log file excerpt image

  • I have tried excluding the resources folder, but no luck, problems section still has this.

  • All these compile times issues or problems shown in the problems section in vsc-code are not detected in IntelliJ IDE. Not sure why the is is happening.

  • The code/java intellisense cannot trace the relationship between so, red marks with lines highlighted is shown, but actually that’s not the case, as the classes are compiled perfectly from command line.

  • Some of the compiler issues, shown in the problems section are -2-another-problem-shown-in-vscode

  • 3-failed-to-configure-project

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
snjezacommented, Nov 4, 2020

Another oddity in this is that I can’t find sources for any of the java built-in classes, but AFAIK my settings.json is setup correctly

@dragozir Could you try replace

 "sources": "/usr/lib/jvm/openjdk-14/src.zip",

with

 "sources": "/usr/lib/jvm/openjdk-14/lib/src.zip",

or remove this line. You should install the java-14-openjdk-src package.

0reactions
ivorobioffcommented, May 18, 2021

I have similar issue in tests as well. It shows:

The method getByIds(Collection<String>, Class<T>) in the type DataProvider
is not applicable for the arguments (Collection<String>, capture#8-of ? extends Class<? extends Identifiable>)
Java(67108979)

However, it compiles fine from command line and IntelliJ.

Here’s a piece of code:

        Stream.of(
                new Pair<>(products, Product.class),
                new Pair<>(orders, Order.class),
                new Pair<>(cars, Car.class)
        ).forEach(source -> {

            lenient().when(dataProvider.getByIds(anyCollection(), eq(source.getValue1())))
                    .thenAnswer(a -> {
                        Organization organization = (Organization) principalProvider.getPrincipal();

                        Collection<String> ids = a.getArgument(0);
                        return source.getValue0()
                                .get(organization.getCompanyId())
                                .stream()
                                .filter(p -> ids.contains(p.getId()))
                                .collect(toList());
                    });

Here’s a bit of info about my vscode


Version: 1.56.2 (user setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19042
Read more comments on GitHub >

github_iconTop Results From Across the Web

Language Server Extension Guide - Visual Studio Code
Learn how to create Language Servers to provide rich language features in Visual Studio Code.
Read more >
Configure VS Code for Microsoft C++
Configure VS Code for Microsoft C++. In this tutorial, you configure Visual Studio Code to use the Microsoft Visual C++ compiler and debugger...
Read more >
TypeScript tutorial with Visual Studio Code
TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. It offers classes, modules, and interfaces to help you build robust...
Read more >
Syntax Highlight Guide | Visual Studio Code Extension API
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords...
Read more >
Command Line Interface (CLI) - Visual Studio Code
'code' is not recognized as an internal or external command ... Your OS cannot find the VS Code binary code on its path....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found