use of ool.intellij.plugin.psi.macro.param.descriptor.MacroParamDescriptor in project oxy-template-support-plugin by mutant-industries.
the class MacroParamDocumentationProvider method generateDoc.
@Nullable
@Override
public String generateDoc(PsiElement element, PsiElement originalElement) {
MacroParamDescriptor macroParamDescriptor;
MacroCall macroCall;
if ((macroParamDescriptor = element.getUserData(MACRO_PARAM_DESCRIPTOR_KEY)) == null && element.getNode() != null && element.getNode().getElementType() == OxyTemplateTypes.T_MACRO_PARAM_NAME && (macroCall = PsiTreeUtil.getParentOfType(element, MacroCall.class)) != null) {
macroParamDescriptor = macroCall.getParamSuggestionSet().getByName(element.getText());
}
if (macroParamDescriptor != null) {
return macroParamDescriptor.generateDoc();
}
if (element instanceof FakeDocumentationPsiElement) {
return generateJsMacroDocumentation(((FakeDocumentationPsiElement) element).getMacro());
}
return null;
}
use of ool.intellij.plugin.psi.macro.param.descriptor.MacroParamDescriptor in project oxy-template-support-plugin by mutant-industries.
the class InnerJsTypeEvaluator method getMacroFirstParameterType.
// -------------------------------------------------------------------
@NotNull
private JSType getMacroFirstParameterType(@NotNull JSProperty macro) {
assert OxyTemplateIndexUtil.isMacro(macro);
JSTypeSource typeSource = JSTypeSourceFactory.createTypeSource(myContext.targetFile, true);
List<JSRecordTypeImpl.TypeMember> members = new LinkedList<>();
for (MacroParamDescriptor paramDescriptor : MacroParamHelper.getJsMacroParamSuggestions(macro, false)) {
if (!paramDescriptor.isDocumented()) {
continue;
}
JSRecordTypeImpl.PropertySignature signature = new JSRecordTypeImpl.PropertySignatureImpl(paramDescriptor.getName(), paramDescriptor.getType(), !paramDescriptor.isRequired());
members.add(signature);
}
JSRecordTypeImpl type = new JSRecordTypeImpl(typeSource, ImmutableList.copyOf(members));
type.accept(new SimplifiedClassNameResolver(myContext.targetFile));
return type;
}
use of ool.intellij.plugin.psi.macro.param.descriptor.MacroParamDescriptor in project oxy-template-support-plugin by mutant-industries.
the class ParamSuggestionProvider method compute.
@Nullable
@Override
public Result<MacroParamSuggestionSet> compute() {
MacroParamSuggestionSet macroParamSuggestions = getMacroParamSuggestions();
Set<PsiElement> cacheDependencies = new HashSet<>();
for (MacroParamDescriptor descriptor : macroParamSuggestions) {
if (descriptor.getType() == null) {
continue;
}
SimplifiedClassNameResolver simplifiedClassNameResolver = new SimplifiedClassNameResolver(macro.getContainingFile());
descriptor.getType().accept(simplifiedClassNameResolver);
cacheDependencies.addAll(simplifiedClassNameResolver.getResolvedClassList());
}
cacheDependencies.addAll(this.cacheDependencies);
return Result.create(macroParamSuggestions, cacheDependencies);
}
use of ool.intellij.plugin.psi.macro.param.descriptor.MacroParamDescriptor in project oxy-template-support-plugin by mutant-industries.
the class MacroParamDocumentationProvider method getDocumentationElementForLookupItem.
@Nullable
@Override
public PsiElement getDocumentationElementForLookupItem(PsiManager psiManager, Object object, PsiElement element) {
if (object instanceof MacroParamDescriptor) {
MacroParamDescriptor descriptor = (MacroParamDescriptor) object;
/**
* We just need to pass the descriptor attached to some element, that will be ignored by other providers
*/
element.putUserData(MACRO_PARAM_DESCRIPTOR_KEY, descriptor);
return element;
}
return null;
}
use of ool.intellij.plugin.psi.macro.param.descriptor.MacroParamDescriptor in project oxy-template-support-plugin by mutant-industries.
the class MacroParamDocumentationProvider method generateJsMacroDocumentation.
private static String generateJsMacroDocumentation(@NotNull JSProperty macro) {
JSDocComment comment;
MacroParamSuggestionSet paramDescriptors = MacroParamHelper.getJsMacroParamSuggestions(macro, false);
String qualifiedName = OxyTemplateIndexUtil.getMacroFullyQualifiedName(macro);
assert qualifiedName != null;
StringBuilder result = new StringBuilder();
result.append("<PRE><b>").append(qualifiedName).append("</b>( [ optional ] params )\n</PRE> ");
if ((comment = JSStubBasedPsiTreeUtil.findDocComment(macro)) != null) {
JSDocPlainCommentBuilder builder = new JSDocPlainCommentBuilder();
JSDocumentationUtils.processDocumentationTextFromComment(comment.getNode(), builder);
String doc = builder.getDoc().trim();
if (doc.length() > 0) {
result.append(doc).append("<br/>");
}
}
if (paramDescriptors.size() != 0) {
result.append("<br/><b>").append(I18nSupport.message("macro.param.block.heading")).append("</b><ul>");
for (MacroParamDescriptor descriptor : paramDescriptors) {
result.append("<li>").append(descriptor.getName()).append(" ").append(descriptor.generateTypeInfo());
if (!StringUtil.isEmpty(descriptor.getDocText())) {
result.append(" - ").append(descriptor.getDocText());
}
result.append("</li>");
}
result.append("</ul>");
}
return result.toString();
}
Aggregations