本文整理汇总了Java中com.intellij.codeInsight.TailType.SEMICOLON属性的典型用法代码示例。如果您正苦于以下问题:Java TailType.SEMICOLON属性的具体用法?Java TailType.SEMICOLON怎么用?Java TailType.SEMICOLON使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.intellij.codeInsight.TailType
的用法示例。
在下文中一共展示了TailType.SEMICOLON属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addExpressionKeywords
private static void addExpressionKeywords(CompletionParameters parameters, Consumer<LookupElement> result, PsiElement position, @Nullable PsiElement prevLeaf) {
if (psiElement(JavaTokenType.DOUBLE_COLON).accepts(prevLeaf)) {
PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiMethodReferenceExpression.class);
TailType tail = parent != null && !LambdaHighlightingUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
result.consume(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), tail));
return;
}
if (isExpressionPosition(position)) {
if (PsiTreeUtil.getParentOfType(position, PsiAnnotation.class) == null) {
result.consume(TailTypeDecorator.withTail(createKeyword(position, PsiKeyword.NEW), TailType.INSERT_SPACE));
result.consume(createKeyword(position, PsiKeyword.NULL));
}
if (mayExpectBoolean(parameters)) {
result.consume(createKeyword(position, PsiKeyword.TRUE));
result.consume(createKeyword(position, PsiKeyword.FALSE));
}
}
}
示例3: 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);
}
}
示例4: fillCompletions
@Override
public void fillCompletions(final CompletionParameters parameters, final CompletionResultSet result) {
PsiElement position = parameters.getPosition();
if (!inComment(position)) {
if (AFTER_DOUBLE_COLON.accepts(position)) {
PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(parameters.getPosition(), PsiMethodReferenceExpression.class);
TailType tail = parent != null && !LambdaHighlightingUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.NEW), tail));
return;
}
if (isSuitableForClass(position)) {
PsiElement scope = position.getParent();
while (scope != null && !(scope instanceof PsiFile)) {
if (scope instanceof PsiClass && ((PsiClass)scope).isInterface()) {
result.addElement(new OverrideableSpace(createKeyword(position, PsiKeyword.DEFAULT), TailType.HUMBLE_SPACE_BEFORE_WORD));
break;
}
scope = scope.getParent();
}
}
}
super.fillCompletions(parameters, result);
}
示例5: 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);
}
}
示例6: getTailType
private static TailType getTailType(final char completionChar, LookupItem item)
{
switch(completionChar)
{
case '.':
return new CharTailType('.', false);
case ',':
return TailType.COMMA;
case ';':
return TailType.SEMICOLON;
case '=':
return TailType.EQ;
case ' ':
return TailType.SPACE;
case ':':
return TailType.CASE_COLON; //?
case '<':
case '>':
case '\"':
}
final TailType attr = item.getTailType();
return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
示例7: getTailType
private static TailType getTailType(final char completionChar, LookupItem item){
switch(completionChar){
case '.': return new CharTailType('.', false);
case ',': return TailType.COMMA;
case ';': return TailType.SEMICOLON;
case '=': return TailType.EQ;
case ' ': return TailType.SPACE;
case ':': return TailType.CASE_COLON; //?
case '<':
case '>':
case '\"':
}
final TailType attr = item.getTailType();
return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
示例8: getDefaultTailType
@Nullable
public static TailType getDefaultTailType(final char completionChar) {
switch(completionChar){
case '.': return new CharTailType('.', false);
case ',': return TailType.COMMA;
case ';': return TailType.SEMICOLON;
case '=': return TailType.EQ;
case ' ': return TailType.SPACE;
case ':': return TailType.CASE_COLON; //?
}
return null;
}
示例9: getTailType
protected TailType getTailType(final char completionChar, LookupItem item){
switch(completionChar){
case '.': return new CharTailType('.', false);
case ',': return TailType.COMMA;
case ';': return TailType.SEMICOLON;
case '=': return TailType.EQ;
case ' ': return TailType.SPACE;
case ':': return TailType.CASE_COLON; //?
case '<':
case '>':
case '\"':
}
final TailType attr = item.getTailType();
return attr == TailType.UNKNOWN ? TailType.NONE : attr;
}
示例10: 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();
}
}
示例11: addExpressionKeywords
private void addExpressionKeywords(boolean statementPosition)
{
if(psiElement(JavaTokenType.DOUBLE_COLON).accepts(myPrevLeaf))
{
PsiMethodReferenceExpression parent = PsiTreeUtil.getParentOfType(myPosition, PsiMethodReferenceExpression.class);
TailType tail = parent != null && !LambdaHighlightingUtil.insertSemicolon(parent.getParent()) ? TailType.SEMICOLON : TailType.NONE;
addKeyword(new OverrideableSpace(createKeyword(PsiKeyword.NEW), tail));
return;
}
if(isExpressionPosition(myPosition))
{
if(PsiTreeUtil.getParentOfType(myPosition, PsiAnnotation.class) == null)
{
if(!statementPosition)
{
addKeyword(TailTypeDecorator.withTail(createKeyword(PsiKeyword.NEW), TailType.INSERT_SPACE));
}
addKeyword(createKeyword(PsiKeyword.NULL));
}
if(mayExpectBoolean(myParameters))
{
addKeyword(createKeyword(PsiKeyword.TRUE));
addKeyword(createKeyword(PsiKeyword.FALSE));
}
}
}
示例12: 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));
}
}
示例13: insertTail
public static boolean insertTail(InsertionContext context, LookupElement item, TailType tailType, boolean hasTail)
{
TailType toInsert = tailType;
LookupItem<?> lookupItem = item.as(LookupItem.CLASS_CONDITION_KEY);
if(lookupItem == null || lookupItem.getAttribute(LookupItem.TAIL_TYPE_ATTR) != TailType.UNKNOWN)
{
if(!hasTail && item.getObject() instanceof PsiMethod && PsiType.VOID.equals(((PsiMethod) item.getObject()).getReturnType()))
{
PsiDocumentManager.getInstance(context.getProject()).commitAllDocuments();
if(psiElement().beforeLeaf(psiElement().withText(".")).accepts(context.getFile().findElementAt(context.getTailOffset() - 1)))
{
return false;
}
boolean insertAdditionalSemicolon = true;
PsiElement leaf = context.getFile().findElementAt(context.getStartOffset());
PsiElement composite = leaf == null ? null : leaf.getParent();
if(composite instanceof PsiMethodReferenceExpression && LambdaHighlightingUtil.insertSemicolon(composite.getParent()))
{
insertAdditionalSemicolon = false;
}
else if(composite instanceof PsiReferenceExpression)
{
PsiElement parent = composite.getParent();
if(parent instanceof PsiMethodCallExpression)
{
parent = parent.getParent();
}
if(parent instanceof PsiLambdaExpression && !LambdaHighlightingUtil.insertSemicolonAfter((PsiLambdaExpression) parent))
{
insertAdditionalSemicolon = false;
}
}
if(insertAdditionalSemicolon)
{
toInsert = TailType.SEMICOLON;
}
}
}
toInsert.processTail(context.getEditor(), context.getTailOffset());
return true;
}