Search in sources :

Example 1 with IFileSpecification

use of org.apache.flex.compiler.filespecs.IFileSpecification in project vscode-nextgenas by BowlerHatLLC.

the class LanguageServerFileSpecGetter method getFileSpecification.

public IFileSpecification getFileSpecification(String filePath) {
    Path path = Paths.get(filePath);
    if (sourceByPath.containsKey(path)) {
        String code = sourceByPath.get(path);
        if (path.endsWith(MXML_FILE_EXTENSION)) {
            code = fixUnclosedXMLComment(code);
            code = fixUnclosedScriptCDATA(code);
        }
        return new StringFileSpecification(filePath, code);
    }
    return new FileSpecification(filePath);
}
Also used : Path(java.nio.file.Path) StringFileSpecification(org.apache.flex.compiler.internal.filespecs.StringFileSpecification) StringFileSpecification(org.apache.flex.compiler.internal.filespecs.StringFileSpecification) IFileSpecification(org.apache.flex.compiler.filespecs.IFileSpecification) FileSpecification(org.apache.flex.compiler.filespecs.FileSpecification)

Example 2 with IFileSpecification

use of org.apache.flex.compiler.filespecs.IFileSpecification in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method didChangeWatchedFiles.

/**
     * Called when certain files in the workspace are added, removed, or
     * changed, even if they are not considered open for editing. Also checks if
     * the project configuration strategy has changed. If it has, checks for
     * errors on the whole project.
     */
public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) {
    boolean needsFullCheck = false;
    for (FileEvent event : params.getChanges()) {
        Path path = LanguageServerUtils.getPathFromLanguageServerURI(event.getUri());
        if (path == null) {
            continue;
        }
        File file = path.toFile();
        String fileName = file.getName();
        if ((fileName.endsWith(AS_EXTENSION) || fileName.endsWith(MXML_EXTENSION)) && currentWorkspace != null) {
            if (event.getType().equals(FileChangeType.Deleted)) {
                IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(file.getAbsolutePath());
                currentWorkspace.fileRemoved(fileSpec);
                needsFullCheck = true;
            } else if (event.getType().equals(FileChangeType.Created)) {
                IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(file.getAbsolutePath());
                currentWorkspace.fileAdded(fileSpec);
            } else if (event.getType().equals(FileChangeType.Changed)) {
                IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(file.getAbsolutePath());
                currentWorkspace.fileChanged(fileSpec);
                checkFilePathForProblems(path, false);
            }
        }
    }
    if (needsFullCheck || projectConfigStrategy.getChanged()) {
        checkProjectForProblems();
    }
}
Also used : Path(java.nio.file.Path) FileEvent(org.eclipse.lsp4j.FileEvent) IFileSpecification(org.apache.flex.compiler.filespecs.IFileSpecification) File(java.io.File)

Example 3 with IFileSpecification

use of org.apache.flex.compiler.filespecs.IFileSpecification in project vscode-nextgenas by BowlerHatLLC.

the class ActionScriptTextDocumentService method didChange.

/**
     * Called when a change is made to a file open for editing in Visual Studio
     * Code. Receives incremental changes that need to be applied to the
     * in-memory String that we store for this file.
     */
@Override
public void didChange(DidChangeTextDocumentParams params) {
    VersionedTextDocumentIdentifier textDocument = params.getTextDocument();
    String textDocumentUri = textDocument.getUri();
    if (!textDocumentUri.endsWith(AS_EXTENSION) && !textDocumentUri.endsWith(MXML_EXTENSION)) {
        return;
    }
    Path path = LanguageServerUtils.getPathFromLanguageServerURI(textDocumentUri);
    if (path != null) {
        for (TextDocumentContentChangeEvent change : params.getContentChanges()) {
            if (change.getRange() == null) {
                sourceByPath.put(path, change.getText());
            } else {
                String existingText = sourceByPath.get(path);
                String newText = patch(existingText, change);
                sourceByPath.put(path, newText);
            }
        }
        if (currentWorkspace != null) {
            IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(path.toAbsolutePath().toString());
            currentWorkspace.fileChanged(fileSpec);
        }
        //we do a quick check of the current file on change for better
        //performance while typing. we'll do a full check when we save the
        //file later
        checkFilePathForProblems(path, true);
    }
}
Also used : Path(java.nio.file.Path) VersionedTextDocumentIdentifier(org.eclipse.lsp4j.VersionedTextDocumentIdentifier) IFileSpecification(org.apache.flex.compiler.filespecs.IFileSpecification) TextDocumentContentChangeEvent(org.eclipse.lsp4j.TextDocumentContentChangeEvent)

Aggregations

Path (java.nio.file.Path)3 IFileSpecification (org.apache.flex.compiler.filespecs.IFileSpecification)3 File (java.io.File)1 FileSpecification (org.apache.flex.compiler.filespecs.FileSpecification)1 StringFileSpecification (org.apache.flex.compiler.internal.filespecs.StringFileSpecification)1 FileEvent (org.eclipse.lsp4j.FileEvent)1 TextDocumentContentChangeEvent (org.eclipse.lsp4j.TextDocumentContentChangeEvent)1 VersionedTextDocumentIdentifier (org.eclipse.lsp4j.VersionedTextDocumentIdentifier)1