本文整理汇总了Java中com.intellij.codeInsight.TailType.HUMBLE_SPACE_BEFORE_WORD属性的典型用法代码示例。如果您正苦于以下问题:Java TailType.HUMBLE_SPACE_BEFORE_WORD属性的具体用法?Java TailType.HUMBLE_SPACE_BEFORE_WORD怎么用?Java TailType.HUMBLE_SPACE_BEFORE_WORD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.codeInsight.TailType
的用法示例。
在下文中一共展示了TailType.HUMBLE_SPACE_BEFORE_WORD属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReturnTail
private static TailType getReturnTail(PsiElement position) {
PsiElement scope = position;
while(true){
if (scope instanceof PsiFile || scope instanceof PsiClassInitializer){
return TailType.NONE;
}
if (scope instanceof PsiMethod){
final PsiMethod method = (PsiMethod)scope;
if(method.isConstructor() || PsiType.VOID.equals(method.getReturnType())) {
return TailType.SEMICOLON;
}
return TailType.HUMBLE_SPACE_BEFORE_WORD;
}
if (scope instanceof PsiLambdaExpression) {
final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression)scope));
if (PsiType.VOID.equals(returnType)) {
return TailType.SEMICOLON;
}
return TailType.HUMBLE_SPACE_BEFORE_WORD;
}
scope = scope.getParent();
}
}
示例2: addBreakContinue
private static void addBreakContinue(Consumer<LookupElement> result, PsiElement position) {
PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);
LookupElement br = createKeyword(position, PsiKeyword.BREAK);
LookupElement cont = createKeyword(position, PsiKeyword.CONTINUE);
TailType tailType;
if (psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
psiElement(PsiClassInitializer.class))).accepts(position)) {
tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
}
else {
tailType = TailType.SEMICOLON;
}
br = TailTypeDecorator.withTail(br, tailType);
cont = TailTypeDecorator.withTail(cont, tailType);
if (loop != null && PsiTreeUtil.isAncestor(loop.getBody(), position, false)) {
result.consume(br);
result.consume(cont);
}
if (psiElement().inside(PsiSwitchStatement.class).accepts(position)) {
result.consume(br);
}
}
示例3: addBreakContinue
private static void addBreakContinue(CompletionResultSet result, PsiElement position) {
PsiLoopStatement loop = PsiTreeUtil.getParentOfType(position, PsiLoopStatement.class);
LookupElement br = createKeyword(position, PsiKeyword.BREAK);
LookupElement cont = createKeyword(position, PsiKeyword.CONTINUE);
TailType tailType;
if (psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class),
or(psiElement(PsiFile.class), psiElement(PsiMethod.class),
psiElement(PsiClassInitializer.class))).accepts(position)) {
tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
}
else {
tailType = TailType.SEMICOLON;
}
br = TailTypeDecorator.withTail(br, tailType);
cont = TailTypeDecorator.withTail(cont, tailType);
if (loop != null && new InsideElementFilter(new ClassFilter(PsiStatement.class)).isAcceptable(position, loop)) {
result.addElement(br);
result.addElement(cont);
}
if (psiElement().inside(PsiSwitchStatement.class).accepts(position)) {
result.addElement(br);
}
}
示例4: getReturnTail
private static TailType getReturnTail(PsiElement position)
{
PsiElement scope = position;
while(true)
{
if(scope instanceof PsiFile || scope instanceof PsiClassInitializer)
{
return TailType.NONE;
}
if(scope instanceof PsiMethod)
{
final PsiMethod method = (PsiMethod) scope;
if(method.isConstructor() || PsiType.VOID.equals(method.getReturnType()))
{
return TailType.SEMICOLON;
}
return TailType.HUMBLE_SPACE_BEFORE_WORD;
}
if(scope instanceof PsiLambdaExpression)
{
final PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(((PsiLambdaExpression) scope));
if(PsiType.VOID.equals(returnType))
{
return TailType.SEMICOLON;
}
return TailType.HUMBLE_SPACE_BEFORE_WORD;
}
scope = scope.getParent();
}
}
示例5: addBreakContinue
private void addBreakContinue()
{
PsiLoopStatement loop = PsiTreeUtil.getParentOfType(myPosition, PsiLoopStatement.class, true, PsiLambdaExpression.class, PsiMember.class);
LookupElement br = createKeyword(PsiKeyword.BREAK);
LookupElement cont = createKeyword(PsiKeyword.CONTINUE);
TailType tailType;
if(psiElement().insideSequence(true, psiElement(PsiLabeledStatement.class), or(psiElement(PsiFile.class), psiElement(PsiMethod.class), psiElement(PsiClassInitializer.class))).accepts
(myPosition))
{
tailType = TailType.HUMBLE_SPACE_BEFORE_WORD;
}
else
{
tailType = TailType.SEMICOLON;
}
br = TailTypeDecorator.withTail(br, tailType);
cont = TailTypeDecorator.withTail(cont, tailType);
if(loop != null && PsiTreeUtil.isAncestor(loop.getBody(), myPosition, false))
{
addKeyword(br);
addKeyword(cont);
}
if(psiElement().inside(PsiSwitchStatement.class).accepts(myPosition))
{
addKeyword(br);
}
for(PsiLabeledStatement labeled : psiApi().parents(myPosition).takeWhile(notInstanceOf(PsiMember.class)).filter(PsiLabeledStatement.class))
{
addKeyword(TailTypeDecorator.withTail(LookupElementBuilder.create("break " + labeled.getName()).bold(), TailType.SEMICOLON));
}
}