Search in sources :

Example 1 with SwaggerFileFinder

use of com.reprezen.swagedit.core.utils.SwaggerFileFinder in project KaiZen-OpenAPI-Editor by RepreZen.

the class QuickOutline method handleMultiView.

protected void handleMultiView() {
    currentScope = currentScope.next();
    SwaggerFileFinder fileFinder = new SwaggerFileFinder(fileContentType);
    IEditorInput input = editor.getEditorInput();
    IFile currentFile = null;
    if (input instanceof IFileEditorInput) {
        currentFile = ((IFileEditorInput) input).getFile();
    }
    Iterable<IFile> files = fileFinder.collectFiles(currentScope, currentFile);
    setInfoText(statusMessage());
    if (currentScope == Scope.LOCAL) {
        treeViewer.setAutoExpandLevel(2);
    } else {
        treeViewer.setAutoExpandLevel(0);
    }
    setInput(Model.parseYaml(files, getSchema()));
}
Also used : SwaggerFileFinder(com.reprezen.swagedit.core.utils.SwaggerFileFinder) IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with SwaggerFileFinder

use of com.reprezen.swagedit.core.utils.SwaggerFileFinder in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonReferenceProposalProvider method getProposals.

/**
     * Returns collection of JSON reference proposals.
     * 
     * If the scope is local, it will only return JSON references from within the current document.
     * 
     * If the scope is project, it will return all JSON references from within the current document and from all
     * documents inside the same project.
     * 
     * If the scope is workspace, it will return all JSON references from within the current document and from all
     * documents inside the same workspace.
     * 
     * @param pointer
     * @param document
     * @param scope
     * @return proposals
     */
public Collection<Proposal> getProposals(JsonPointer pointer, JsonDocument document, Scope scope) {
    final ContextType type = contextTypes.get(pointer.toString());
    final IFile currentFile = getActiveFile();
    final IPath basePath = currentFile.getParent().getFullPath();
    final List<Proposal> proposals = Lists.newArrayList();
    if (scope == Scope.LOCAL) {
        proposals.addAll(type.collectProposals(document, null));
    } else if (!type.isLocalOnly()) {
        final SwaggerFileFinder fileFinder = new SwaggerFileFinder(fileContentType);
        for (IFile file : fileFinder.collectFiles(scope, currentFile)) {
            IPath relative = file.equals(currentFile) ? null : file.getFullPath().makeRelativeTo(basePath);
            if (file.equals(currentFile)) {
                proposals.addAll(type.collectProposals(document, relative));
            } else {
                proposals.addAll(type.collectProposals(manager.getDocument(file.getLocationURI()), relative));
            }
        }
    }
    return proposals;
}
Also used : ContextType(com.reprezen.swagedit.core.assist.contexts.ContextType) IFile(org.eclipse.core.resources.IFile) SwaggerFileFinder(com.reprezen.swagedit.core.utils.SwaggerFileFinder) IPath(org.eclipse.core.runtime.IPath)

Aggregations

SwaggerFileFinder (com.reprezen.swagedit.core.utils.SwaggerFileFinder)2 IFile (org.eclipse.core.resources.IFile)2 ContextType (com.reprezen.swagedit.core.assist.contexts.ContextType)1 IPath (org.eclipse.core.runtime.IPath)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IFileEditorInput (org.eclipse.ui.IFileEditorInput)1