本文整理汇总了Java中com.intellij.psi.javadoc.PsiDocComment类的典型用法代码示例。如果您正苦于以下问题:Java PsiDocComment类的具体用法?Java PsiDocComment怎么用?Java PsiDocComment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiDocComment类属于com.intellij.psi.javadoc包,在下文中一共展示了PsiDocComment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlaceholderText
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
private static String getPlaceholderText(PsiElement element) {
if (element instanceof PsiImportList) {
return "...";
}
else if (element instanceof PsiMethod || element instanceof PsiClassInitializer || element instanceof PsiClass) {
return "{...}";
}
else if (element instanceof PsiDocComment) {
return "/**...*/";
}
else if (element instanceof PsiFile) {
return "/.../";
}
else if (element instanceof PsiAnnotation) {
return "@{...}";
}
else if (element instanceof PsiReferenceParameterList) {
return SMILEY;
}
else if (element instanceof PsiComment) {
return "//...";
}
return "...";
}
示例2: ClsMemberImpl
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
protected ClsMemberImpl(T stub) {
super(stub);
myDocComment = !isDeprecated() ? null : new AtomicNotNullLazyValue<PsiDocComment>() {
@NotNull
@Override
protected PsiDocComment compute() {
return new ClsDocCommentImpl(ClsMemberImpl.this);
}
};
myNameIdentifier = new AtomicNotNullLazyValue<PsiIdentifier>() {
@NotNull
@Override
protected PsiIdentifier compute() {
return new ClsIdentifierImpl(ClsMemberImpl.this, getName());
}
};
}
示例3: getTokenizer
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@NotNull
@Override
public Tokenizer getTokenizer(PsiElement element) {
if (TokenSets.STRING_LITERAL_SET.contains(element.getNode().getElementType())) {
return myStringTokenizer;
}
if (element instanceof GrNamedElement) {
final PsiElement name = ((GrNamedElement)element).getNameIdentifierGroovy();
if (TokenSets.STRING_LITERAL_SET.contains(name.getNode().getElementType())) {
return EMPTY_TOKENIZER;
}
}
if (element instanceof PsiDocComment) return myDocCommentTokenizer;
//if (element instanceof GrLiteralImpl && ((GrLiteralImpl)element).isStringLiteral()) return myStringTokenizer;
return super.getTokenizer(element);
}
示例4: getDocComment
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@Override
public PsiDocComment getDocComment(){
final PsiFieldStub stub = getStub();
if (stub != null && !stub.hasDocComment()) return null;
CompositeElement treeElement = getNode();
if (getTypeElement() != null) {
PsiElement element = treeElement.findChildByRoleAsPsiElement(ChildRole.DOC_COMMENT);
return element instanceof PsiDocComment ? (PsiDocComment)element : null;
}
else {
ASTNode prevField = treeElement.getTreePrev();
while(prevField.getElementType() != JavaElementType.FIELD){
prevField = prevField.getTreePrev();
}
return ((PsiField)SourceTreeToPsiMap.treeElementToPsi(prevField)).getDocComment();
}
}
示例5: visitDocComment
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@Override
public void visitDocComment(PsiDocComment comment) {
super.visitDocComment(comment);
final PsiDocTag[] tags = comment.getTags();
for (PsiDocTag tag : tags) {
if (Comparing.strEqual(tag.getName(), SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)) {
final PsiElement[] dataElements = tag.getDataElements();
if (dataElements != null && dataElements.length > 0) {
final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(comment, PsiModifierListOwner.class);
if (listOwner != null) {
final RefElementImpl element = (RefElementImpl)myRefManager.getReference(listOwner);
if (element != null) {
String suppression = "";
for (PsiElement dataElement : dataElements) {
suppression += "," + dataElement.getText();
}
element.addSuppression(suppression);
}
}
}
}
}
}
示例6: implementMethodInClass
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
private static void implementMethodInClass(@NotNull PsiMethod method,
@NotNull PsiClass aClass) {
final PsiMethod newMethod = (PsiMethod)aClass.add(method);
final PsiDocComment comment = newMethod.getDocComment();
if (comment != null) {
comment.delete();
}
final PsiModifierList modifierList = newMethod.getModifierList();
modifierList.setModifierProperty(PsiModifier.ABSTRACT, false);
final Project project = aClass.getProject();
final CodeStyleSettings codeStyleSettings =
CodeStyleSettingsManager.getSettings(project);
if (codeStyleSettings.INSERT_OVERRIDE_ANNOTATION &&
PsiUtil.isLanguageLevel6OrHigher(aClass)) {
modifierList.addAnnotation("java.lang.Override");
}
final PsiElementFactory factory =
JavaPsiFacade.getElementFactory(project);
final PsiCodeBlock codeBlock = factory.createCodeBlock();
newMethod.add(codeBlock);
}
示例7: createReferenceProcessor
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
private static PsiReferenceProcessor createReferenceProcessor(@NotNull final List<UsagesProcessor> processors,
final GlobalInspectionContext context) {
return new PsiReferenceProcessor() {
@Override
public boolean execute(PsiReference reference) {
AnalysisScope scope = context.getRefManager().getScope();
if (scope != null && scope.contains(reference.getElement()) && reference.getElement().getLanguage() == StdLanguages.JAVA ||
PsiTreeUtil.getParentOfType(reference.getElement(), PsiDocComment.class) != null) {
return true;
}
synchronized (processors) {
UsagesProcessor[] processorsArrayed = processors.toArray(new UsagesProcessor[processors.size()]);
for (UsagesProcessor processor : processorsArrayed) {
if (!processor.process(reference)) {
processors.remove(processor);
}
}
}
return !processors.isEmpty();
}
};
}
示例8: getTextStartOffset
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@Override
public int getTextStartOffset(@NotNull final PsiElement parent) {
PsiElement element = parent;
if (element instanceof PsiDocCommentOwner) {
PsiDocComment comment = ((PsiDocCommentOwner)element).getDocComment();
if (comment != null) {
element = comment.getNextSibling();
while (element instanceof PsiWhiteSpace) {
element = element.getNextSibling();
}
}
}
if (element != null) {
TextRange range = element.getTextRange();
if (range != null) {
return range.getStartOffset();
}
LOG.error("Range should not be null: " + element + "; " + element.getClass());
}
LOG.error("Element should not be null: " + parent.getText());
return parent.getTextRange().getStartOffset();
}
示例9: shouldSuggestModifiers
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
private static boolean shouldSuggestModifiers(PsiElement element) {
PsiElement parent = element.getParent();
while (parent != null && (parent instanceof PsiJavaCodeReferenceElement ||
parent instanceof PsiErrorElement || parent instanceof PsiTypeElement ||
parent instanceof PsiMethod || parent instanceof PsiVariable ||
parent instanceof PsiDeclarationStatement || parent instanceof PsiImportList ||
parent instanceof PsiDocComment ||
element.getText().equals(parent.getText()))) {
parent = parent.getParent();
if (parent instanceof JspClassLevelDeclarationStatement) {
parent = parent.getContext();
}
}
if (parent == null) return false;
PsiElement prev = FilterPositionUtil.searchNonSpaceNonCommentBack(element);
if (parent instanceof PsiJavaFile || parent instanceof PsiClass) {
if (prev == null || JavaKeywordCompletion.END_OF_BLOCK.getValue().isAcceptable(element, prev.getParent())) {
return true;
}
}
return false;
}
示例10: copyDocComment
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
private static void copyDocComment(PsiMethod source, PsiMethod target, JVMElementFactory factory) {
final PsiElement navigationElement = source.getNavigationElement();
if (navigationElement instanceof PsiDocCommentOwner) {
final PsiDocComment docComment = ((PsiDocCommentOwner)navigationElement).getDocComment();
if (docComment != null) {
target.addAfter(factory.createDocCommentFromText(docComment.getText()), null);
}
}
final PsiParameter[] sourceParameters = source.getParameterList().getParameters();
final PsiParameterList targetParameterList = target.getParameterList();
RefactoringUtil.fixJavadocsForParams(target, new HashSet<PsiParameter>(Arrays.asList(targetParameterList.getParameters())), new Condition<Pair<PsiParameter, String>>() {
@Override
public boolean value(Pair<PsiParameter, String> pair) {
final int parameterIndex = targetParameterList.getParameterIndex(pair.first);
if (parameterIndex >= 0 && parameterIndex < sourceParameters.length) {
return Comparing.strEqual(pair.second, sourceParameters[parameterIndex].getName());
}
return false;
}
});
}
示例11: clearMethod
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
private void clearMethod(PsiMethod method) throws IncorrectOperationException {
LOG.assertTrue(!method.isPhysical());
PsiCodeBlock codeBlock = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createCodeBlock();
if (method.getBody() != null) {
method.getBody().replace(codeBlock);
}
else {
method.add(codeBlock);
}
if (!myToCopyJavaDoc) {
final PsiDocComment docComment = method.getDocComment();
if (docComment != null) {
docComment.delete();
}
}
}
示例12: select
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
List<TextRange> result = super.select(e, editorText, cursorOffset, editor);
final PsiField field = (PsiField)e;
final TextRange range = field.getTextRange();
final PsiIdentifier first = field.getNameIdentifier();
final TextRange firstRange = first.getTextRange();
final PsiElement last = field.getInitializer();
final int end = last == null ? firstRange.getEndOffset() : last.getTextRange().getEndOffset();
PsiDocComment comment = field.getDocComment();
if (comment != null) {
TextRange commentTextRange = comment.getTextRange();
addRangeElem(result, editorText, comment, commentTextRange.getEndOffset());
}
addRangeElem(result, editorText, first, end);
//addRangeElem (result, editorText, field, textLength, field.getTypeElement(), end);
addRangeElem(result, editorText, field.getModifierList(), range.getEndOffset());
//addRangeElem (result, editorText, field, textLength, field.getDocComment(), end);
result.addAll(expandToWholeLine(editorText, range));
return result;
}
示例13: isAvailable
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
if (element instanceof PsiCompiledElement) return false;
if (!element.getManager().isInProject(element)) return false;
if (!element.getLanguage().isKindOf(JavaLanguage.INSTANCE)) return false;
final PsiElement context = PsiTreeUtil.getParentOfType(element, PsiDeclarationStatement.class, PsiClass.class);
if (context instanceof PsiDeclarationStatement) {
return isAvailableOnDeclarationStatement((PsiDeclarationStatement)context, element);
}
PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class);
if (field != null && PsiTreeUtil.getParentOfType(element, PsiDocComment.class) == null && isAvailableOnField(field)) {
setText(CodeInsightBundle.message("intention.split.declaration.text"));
return true;
}
return false;
}
示例14: tokenize
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@Override
public void tokenize(@NotNull PsiDocComment comment, TokenConsumer consumer) {
final CommentSplitter splitter = CommentSplitter.getInstance();
for (PsiElement el : comment.getChildren()) {
if (el instanceof PsiDocTag) {
PsiDocTag tag = (PsiDocTag)el;
if (!excludedTags.contains(tag.getName())) {
for (PsiElement data : tag.getDataElements()) {
consumer.consumeToken(data, splitter);
}
}
}
else {
consumer.consumeToken(el, splitter);
}
}
}
示例15: getTokenizer
import com.intellij.psi.javadoc.PsiDocComment; //导入依赖的package包/类
@NotNull
@Override
public Tokenizer getTokenizer(PsiElement element) {
if (element instanceof PsiMethod) {
return myMethodNameTokenizer;
}
if (element instanceof PsiDocComment) {
return myDocCommentTokenizer;
}
if (element instanceof PsiLiteralExpression) {
if (SuppressManager.isSuppressedInspectionName((PsiLiteralExpression)element)) {
return EMPTY_TOKENIZER;
}
return myLiteralExpressionTokenizer;
}
if (element instanceof PsiNamedElement) {
return myNamedElementTokenizer;
}
return super.getTokenizer(element);
}