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

no autocompletions or hints for referenced libraries. #3078

Open
veksha opened this issue Mar 1, 2024 · 4 comments
Open

no autocompletions or hints for referenced libraries. #3078

veksha opened this issue Mar 1, 2024 · 4 comments

Comments

@veksha
Copy link

veksha commented Mar 1, 2024

Hi.
my OS is Windows 11. my editor is CudaText.

i get no autocompletions or hover hints for referenced libraries like for example - jackson.
e.g. lsp server cannot complete "JsonFactory" or "factory.createGenerator"

please help. what am i doing wrong?
file compiles without error.
i am not using maven/gradle. just simple file test.java and jackson-core-2.5.4.jar in the same folder.

settings:

{
    "java.project.ReferencedLibraries": {
        "include": ["jackson-core-2.5.4.jar"]
    }
}

test.java file:

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.io.SerializedString;
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;

import java.io.StringWriter;

public class test {
    public static void main(String[] args) {
        try {
            JsonFactory factory = new JsonFactory();
            StringWriter writer = new StringWriter();
            JsonGenerator generator = factory.createGenerator(writer);

            DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
            generator.setPrettyPrinter(prettyPrinter);

            generator.writeStartObject();
            generator.writeStringField("name", "Yura");
            generator.writeNumberField("age", 30);
            generator.writeEndObject();
            generator.close();

            System.out.println("Generated JSON: " + writer.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

debug log:

Mar 1, 2024, 10:29:27 PM Main thread is waiting
Mar 1, 2024, 10:29:27 PM >> initialize
Mar 1, 2024, 10:29:27 PM Initializing Java Language Server 1.33.0.202402151717
Mar 1, 2024, 10:29:27 PM Starting org.eclipse.m2e.core
Mar 1, 2024, 10:29:27 PM Started org.eclipse.m2e.core 2ms
Mar 1, 2024, 10:29:28 PM Created adapter factory; available factories [file-lock, rwlock-local, semaphore-local, noop]; available name mappers [discriminating, file-gav, file-hgav, file-static, gav, static]
Mar 1, 2024, 10:29:29 PM Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\yura\.m2\repository
Mar 1, 2024, 10:29:29 PM Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\yura\.m2\repository
Mar 1, 2024, 10:29:29 PM Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\yura\.m2\repository
Mar 1, 2024, 10:29:29 PM Refreshing (1 files): [L/jdt.ls-java-project/pom.xml]
Mar 1, 2024, 10:29:29 PM Nothing changed in this cycle.
Mar 1, 2024, 10:29:29 PM Refresh takes 6 ms
Mar 1, 2024, 10:29:29 PM Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\yura\.m2\repository
Mar 1, 2024, 10:29:29 PM Using manager EnhancedLocalRepositoryManager with priority 10.0 for C:\Users\yura\.m2\repository
Mar 1, 2024, 10:29:29 PM ProjectRegistryRefreshJob finished 1458ms
Mar 1, 2024, 10:29:29 PM Starting org.eclipse.buildship.core
Mar 1, 2024, 10:29:29 PM Gradle version information cache is up-to-date. Trying to read.
Mar 1, 2024, 10:29:29 PM Started org.eclipse.buildship.core 29ms
Mar 1, 2024, 10:29:29 PM Static Commands: []
Mar 1, 2024, 10:29:29 PM Non-Static Commands: [java.project.import, java.project.changeImportedProjects, java.navigate.openTypeHierarchy, java.project.resolveStackTraceLocation, java.edit.handlePasteEvent, java.edit.stringFormatting, java.project.getSettings, java.project.resolveWorkspaceSymbol, java.project.upgradeGradle, java.project.createModuleInfo, java.vm.getAllInstalls, java.edit.organizeImports, java.project.refreshDiagnostics, java.project.removeFromSourcePath, java.project.listSourcePaths, java.project.getAll, java.reloadBundles, java.project.isTestFile, java.project.resolveText, java.project.getClasspaths, java.navigate.resolveTypeHierarchy, java.edit.smartSemicolonDetection, java.project.updateSourceAttachment, java.project.updateClassPaths, java.decompile, java.protobuf.generateSources, java.project.resolveSourceAttachment, java.project.updateJdk, java.project.addToSourcePath, java.completion.onDidSelect]
Mar 1, 2024, 10:29:29 PM RepositoryRegistryUpdateJob finished 1ms
Mar 1, 2024, 10:29:29 PM >> initialized
Mar 1, 2024, 10:29:30 PM Workspace initialized in 905ms
Mar 1, 2024, 10:29:30 PM >> initialization job finished
Mar 1, 2024, 10:29:30 PM >> workspace/didChangeConfiguration
Mar 1, 2024, 10:29:30 PM >> registerWatchers'
Mar 1, 2024, 10:29:30 PM >> watchers registered
Mar 1, 2024, 10:29:30 PM >> java/buildWorkspace (incremental)
Mar 1, 2024, 10:29:30 PM >> New configuration: {java={project={ReferencedLibraries={include=[jackson-core-2.5.4.jar]}}}}
Mar 1, 2024, 10:29:30 PM >> document/didOpen
Mar 1, 2024, 10:29:30 PM >> build jobs finished
Mar 1, 2024, 10:29:30 PM >> textDocument/semanticTokens/full
Mar 1, 2024, 10:29:31 PM Reconciled 1. Took 3 ms
Mar 1, 2024, 10:29:31 PM begin problem for /test.java
Mar 1, 2024, 10:29:31 PM 1 problems reported for /test.java
File: C:\Users\yura\Desktop\test.java
Line 1: [Java,Wrn:16]: test.java is a non-project file, only syntax errors are reported
Mar 1, 2024, 10:29:31 PM Validated 1. Took 71 ms
@snjeza
Copy link
Contributor

snjeza commented Mar 2, 2024

@veksha You can try the following

  • create the lib directory
  • move jackson-core-2.5.4.jar to the lib directory

@veksha
Copy link
Author

veksha commented Mar 2, 2024

@veksha You can try the following

  • create the lib directory
  • move jackson-core-2.5.4.jar to the lib directory

thank you for answer. i tried - no change. :(

@snjeza
Copy link
Contributor

snjeza commented Mar 2, 2024

Could you try to clean the workspace?

  • Open the command palette (F1)
  • select Java: Clean the Java Language Server Workspace
  • select Restart and delete from the confirmation prompt

@veksha
Copy link
Author

veksha commented Mar 2, 2024

@snjeza i have CudaText and its lsp plugin has no support for code actions yet (i assume this is code action).
but i can manually delete any files just tell me where to look. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants