use of com.reprezen.swagedit.core.assist.contexts.ContextType in project KaiZen-OpenAPI-Editor by RepreZen.
the class JsonContentAssistProcessor method initTextMessages.
protected String[] initTextMessages() {
IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
String bindingKey = bindingService.getBestActiveBindingFormattedFor(EDIT_CONTENT_ASSIST);
ContextType contextType = referenceProposalProvider.getContextTypes().get(getCurrentPath() != null ? getCurrentPath().toString() : "");
String context = contextType != null ? contextType.label() : "";
return new String[] { //
String.format(Messages.content_assist_proposal_project, bindingKey, context), String.format(Messages.content_assist_proposal_workspace, bindingKey, context), String.format(Messages.content_assist_proposal_local, bindingKey, context) };
}
use of com.reprezen.swagedit.core.assist.contexts.ContextType 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;
}
Aggregations