Java 类com.intellij.psi.PsiKeyword 实例源码

项目:manifold-ij    文件:ExtensionClassAnnotator.java   
private void verifyExtensionInterfaces( PsiElement element, AnnotationHolder holder )
{
  if( element instanceof PsiJavaCodeReferenceElementImpl &&
      ((PsiJavaCodeReferenceElementImpl)element).getTreeParent() instanceof ReferenceListElement &&
      ((PsiJavaCodeReferenceElementImpl)element).getTreeParent().getText().startsWith( PsiKeyword.IMPLEMENTS ) )
  {
    final PsiElement resolve = element.getReference().resolve();
    if( resolve instanceof PsiExtensibleClass )
    {
      PsiExtensibleClass iface = (PsiExtensibleClass)resolve;
      if( !isStructuralInterface( iface ) )
      {
        TextRange range = new TextRange( element.getTextRange().getStartOffset(),
                                         element.getTextRange().getEndOffset() );
        holder.createErrorAnnotation( range, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.getName() ) );
      }
    }
  }
}
项目:intellij-ce-playground    文件:JavadocGenerationPanel.java   
void setScope(String scope) {
  if (PsiKeyword.PUBLIC.equals(scope)) {
    myScopeSlider.setValue(1);
  }
  else if (PsiKeyword.PROTECTED.equals(scope)) {
    myScopeSlider.setValue(2);
  }
  else if (PsiKeyword.PRIVATE.equals(scope)) {
    myScopeSlider.setValue(4);
  }
  else {
    myScopeSlider.setValue(3);
  }
  handleSlider();
}
项目:intellij-ce-playground    文件:ThrowsUsageTargetProvider.java   
@Override
@Nullable
public UsageTarget[] getTargets(Editor editor, final PsiFile file) {
  if (editor == null || file == null) return null;

  PsiElement element = file.findElementAt(TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()));
  if (element == null) return null;

  if (element instanceof PsiKeyword && PsiKeyword.THROWS.equals(element.getText())) {
    return new UsageTarget[]{new PsiElement2UsageTargetAdapter(element)};
  }

  final PsiElement parent = element.getParent();
  if (parent instanceof PsiThrowStatement) {
    return new UsageTarget[] {new PsiElement2UsageTargetAdapter(parent)};
  }

  return null;
}
项目:intellij-ce-playground    文件:FinallyBlockCannotCompleteNormallyInspection.java   
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
  final PsiCodeBlock finallyBlock = statement.getFinallyBlock();
  if (finallyBlock == null) {
    return;
  }
  if (ControlFlowUtils.codeBlockMayCompleteNormally(finallyBlock)) {
    return;
  }
  final PsiElement[] children = statement.getChildren();
  for (final PsiElement child : children) {
    final String childText = child.getText();
    if (PsiKeyword.FINALLY.equals(childText)) {
      registerError(child);
      return;
    }
  }
}
项目:tools-idea    文件:DfaTypeValue.java   
@NotNull
public DfaTypeValue create(@NotNull PsiType type, boolean nullable) {
  type = TypeConversionUtil.erasure(type);
  mySharedInstance.myType = type;
  mySharedInstance.myCanonicalText = StringUtil.notNullize(type.getCanonicalText(), PsiKeyword.NULL);
  mySharedInstance.myIsNullable = nullable;

  String id = mySharedInstance.toString();
  ArrayList<DfaTypeValue> conditions = myStringToObject.get(id);
  if (conditions == null) {
    conditions = new ArrayList<DfaTypeValue>();
    myStringToObject.put(id, conditions);
  } else {
    for (DfaTypeValue aType : conditions) {
      if (aType.hardEquals(mySharedInstance)) return aType;
    }
  }

  DfaTypeValue result = new DfaTypeValue(type, nullable, myFactory, mySharedInstance.myCanonicalText);
  conditions.add(result);
  return result;
}
项目:tools-idea    文件:ThrowsUsageTargetProvider.java   
@Override
@Nullable
public UsageTarget[] getTargets(Editor editor, final PsiFile file) {
  if (editor == null || file == null) return null;

  PsiElement element = file.findElementAt(TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()));
  if (element == null) return null;

  if (element instanceof PsiKeyword && PsiKeyword.THROWS.equals(element.getText())) {
    return new UsageTarget[]{new PsiElement2UsageTargetAdapter(element)};
  }

  final PsiElement parent = element.getParent();
  if (parent instanceof PsiThrowStatement) {
    return new UsageTarget[] {new PsiElement2UsageTargetAdapter(parent)};
  }

  return null;
}
项目:tools-idea    文件:StringEqualityInspection.java   
@Override
public void visitBinaryExpression(@NotNull PsiBinaryExpression expression) {
  super.visitBinaryExpression(expression);
  if (!ComparisonUtils.isEqualityComparison(expression)) {
    return;
  }
  final PsiExpression lhs = expression.getLOperand();
  if (!ExpressionUtils.hasStringType(lhs)) {
    return;
  }
  final PsiExpression rhs = expression.getROperand();
  if (rhs == null || !ExpressionUtils.hasStringType(rhs)) {
    return;
  }
  final String lhsText = lhs.getText();
  if (PsiKeyword.NULL.equals(lhsText)) {
    return;
  }
  final String rhsText = rhs.getText();
  if (PsiKeyword.NULL.equals(rhsText)) {
    return;
  }
  final PsiJavaToken sign = expression.getOperationSign();
  registerError(sign);
}
项目:tools-idea    文件:FinallyBlockCannotCompleteNormallyInspection.java   
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
  final PsiCodeBlock finallyBlock = statement.getFinallyBlock();
  if (finallyBlock == null) {
    return;
  }
  if (ControlFlowUtils.codeBlockMayCompleteNormally(finallyBlock)) {
    return;
  }
  final PsiElement[] children = statement.getChildren();
  for (final PsiElement child : children) {
    final String childText = child.getText();
    if (PsiKeyword.FINALLY.equals(childText)) {
      registerError(child);
      return;
    }
  }
}
项目:lombok-intellij-plugin    文件:LombokInspection.java   
/**
 * Check MethodCallExpressions for calls for default (argument less) constructor
 * Produce an error if resolved constructor method is build by lombok and contains some arguments
 */
@Override
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
  super.visitMethodCallExpression(methodCall);

  PsiExpressionList list = methodCall.getArgumentList();
  PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression();

  boolean isThisOrSuper = referenceToMethod.getReferenceNameElement() instanceof PsiKeyword;
  final int parameterCount = list.getExpressions().length;
  if (isThisOrSuper && parameterCount == 0) {

    JavaResolveResult[] results = referenceToMethod.multiResolve(true);
    JavaResolveResult resolveResult = results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
    PsiElement resolved = resolveResult.getElement();

    if (resolved instanceof LombokLightMethodBuilder && ((LombokLightMethodBuilder) resolved).getParameterList().getParameters().length != 0) {
      holder.registerProblem(methodCall, "Default constructor doesn't exist", ProblemHighlightType.ERROR);
    }
  }
}
项目:consulo-java    文件:FileParser.java   
private static boolean stopImportListParsing(PsiBuilder b)
{
    IElementType type = b.getTokenType();
    if(IMPORT_LIST_STOPPER_SET.contains(type))
    {
        return true;
    }
    if(type == JavaTokenType.IDENTIFIER)
    {
        String text = b.getTokenText();
        if(PsiKeyword.OPEN.equals(text) || PsiKeyword.MODULE.equals(text))
        {
            return true;
        }
    }
    return false;
}
项目:consulo-java    文件:ModuleParser.java   
private PsiBuilder.Marker parseStatement(PsiBuilder builder)
{
    String kw = builder.getTokenText();
    if(PsiKeyword.REQUIRES.equals(kw))
    {
        return parseRequiresStatement(builder);
    }
    if(PsiKeyword.EXPORTS.equals(kw))
    {
        return parseExportsStatement(builder);
    }
    if(PsiKeyword.OPENS.equals(kw))
    {
        return parseOpensStatement(builder);
    }
    if(PsiKeyword.USES.equals(kw))
    {
        return parseUsesStatement(builder);
    }
    if(PsiKeyword.PROVIDES.equals(kw))
    {
        return parseProvidesStatement(builder);
    }
    return null;
}
项目:consulo-java    文件:DfaConstValue.java   
@Nullable
public DfaValue create(PsiVariable variable)
{
    Object value = variable.computeConstantValue();
    PsiType type = variable.getType();
    if(value == null)
    {
        Boolean boo = computeJavaLangBooleanFieldReference(variable);
        if(boo != null)
        {
            DfaConstValue unboxed = createFromValue(boo, PsiType.BOOLEAN, variable);
            return myFactory.getBoxedFactory().createBoxed(unboxed);
        }
        PsiExpression initializer = variable.getInitializer();
        if(initializer instanceof PsiLiteralExpression && initializer.textMatches(PsiKeyword.NULL))
        {
            return dfaNull;
        }
        return null;
    }
    return createFromValue(value, type, variable);
}
项目:consulo-java    文件:JavaSoftKeywordHighlightingPass.java   
@RequiredReadAction
@Override
public void doCollectInformation(@NotNull ProgressIndicator progressIndicator)
{
    LanguageLevel languageLevel = myFile.getLanguageLevel();

    myFile.accept(new JavaRecursiveElementVisitor()
    {
        @Override
        public void visitKeyword(PsiKeyword keyword)
        {
            if(JavaLexer.isSoftKeyword(keyword.getNode().getChars(), languageLevel))
            {
                ContainerUtil.addIfNotNull(myResults, HighlightInfo.newHighlightInfo(JavaHighlightInfoTypes.JAVA_KEYWORD).range(keyword).create());
            }
        }
    });
}
项目:consulo-java    文件:ThrowsUsageTargetProvider.java   
@Override
@Nullable
public UsageTarget[] getTargets(Editor editor, final PsiFile file) {
  if (editor == null || file == null) return null;

  PsiElement element = file.findElementAt(TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()));
  if (element == null) return null;

  if (element instanceof PsiKeyword && PsiKeyword.THROWS.equals(element.getText())) {
    return new UsageTarget[]{new PsiElement2UsageTargetAdapter(element)};
  }

  final PsiElement parent = element.getParent();
  if (parent instanceof PsiThrowStatement) {
    return new UsageTarget[] {new PsiElement2UsageTargetAdapter(parent)};
  }

  return null;
}
项目:consulo-java    文件:TrivialIfInspection.java   
public static boolean isSimplifiableImplicitReturn(
  PsiIfStatement ifStatement) {
  if (ifStatement.getElseBranch() != null) {
    return false;
  }
  PsiStatement thenBranch = ifStatement.getThenBranch();
  thenBranch = ControlFlowUtils.stripBraces(thenBranch);
  final PsiElement nextStatement =
    PsiTreeUtil.skipSiblingsForward(ifStatement,
                                    PsiWhiteSpace.class);
  if (!(nextStatement instanceof PsiStatement)) {
    return false;
  }

  final PsiStatement elseBranch = (PsiStatement)nextStatement;
  return ConditionalUtils.isReturn(thenBranch, PsiKeyword.TRUE)
         && ConditionalUtils.isReturn(elseBranch, PsiKeyword.FALSE);
}
项目:consulo-java    文件:TrivialIfInspection.java   
public static boolean isSimplifiableImplicitReturnNegated(
  PsiIfStatement ifStatement) {
  if (ifStatement.getElseBranch() != null) {
    return false;
  }
  PsiStatement thenBranch = ifStatement.getThenBranch();
  thenBranch = ControlFlowUtils.stripBraces(thenBranch);

  final PsiElement nextStatement =
    PsiTreeUtil.skipSiblingsForward(ifStatement,
                                    PsiWhiteSpace.class);
  if (!(nextStatement instanceof PsiStatement)) {
    return false;
  }
  final PsiStatement elseBranch = (PsiStatement)nextStatement;
  return ConditionalUtils.isReturn(thenBranch, PsiKeyword.FALSE)
         && ConditionalUtils.isReturn(elseBranch, PsiKeyword.TRUE);
}
项目:consulo-java    文件:FinallyBlockCannotCompleteNormallyInspection.java   
@Override
public void visitTryStatement(@NotNull PsiTryStatement statement) {
  super.visitTryStatement(statement);
  final PsiCodeBlock finallyBlock = statement.getFinallyBlock();
  if (finallyBlock == null) {
    return;
  }
  if (ControlFlowUtils.codeBlockMayCompleteNormally(finallyBlock)) {
    return;
  }
  final PsiElement[] children = statement.getChildren();
  for (final PsiElement child : children) {
    final String childText = child.getText();
    if (PsiKeyword.FINALLY.equals(childText)) {
      registerError(child);
      return;
    }
  }
}
项目:intellij-ce-playground    文件:ModifierListElement.java   
@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
  if (before == null) {
    if (first == last && ElementType.KEYWORD_BIT_SET.contains(first.getElementType())) {
      anchor = getDefaultAnchor((PsiModifierList)SourceTreeToPsiMap.treeElementToPsi(this),
                                (PsiKeyword)SourceTreeToPsiMap.treeElementToPsi(first));
      before = Boolean.TRUE;
    }
  }
  return super.addInternal(first, last, anchor, before);
}
项目:intellij-ce-playground    文件:ModifierListElement.java   
@Nullable
private static ASTNode getDefaultAnchor(PsiModifierList modifierList, PsiKeyword modifier) {
  Integer order = ourModifierToOrderMap.get(modifier.getText());
  if (order == null) return null;
  for (ASTNode child = SourceTreeToPsiMap.psiToTreeNotNull(modifierList).getFirstChildNode(); child != null; child = child.getTreeNext()) {
    if (ElementType.KEYWORD_BIT_SET.contains(child.getElementType())) {
      Integer order1 = ourModifierToOrderMap.get(child.getText());
      if (order1 == null) continue;
      if (order1.intValue() > order.intValue()) {
        return child;
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:NullSmartCompletionContributor.java   
public NullSmartCompletionContributor() {
  extend(CompletionType.SMART, and(JavaSmartCompletionContributor.INSIDE_EXPRESSION,
                                                    not(psiElement().afterLeaf("."))), new ExpectedTypeBasedCompletionProvider() {
    @Override
    protected void addCompletions(final CompletionParameters parameters,
                                  final CompletionResultSet result, final Collection<ExpectedTypeInfo> infos) {
      if (!StringUtil.startsWithChar(result.getPrefixMatcher().getPrefix(), 'n')) {
        return;
      }

      LinkedHashSet<CompletionResult> results = result.runRemainingContributors(parameters, true);
      for (CompletionResult completionResult : results) {
        if (completionResult.isStartMatch()) {
          return;
        }
      }

      for (final ExpectedTypeInfo info : infos) {
        if (!(info.getType() instanceof PsiPrimitiveType)) {
          final LookupElement item = BasicExpressionCompletionContributor.createKeywordLookupItem(parameters.getPosition(), PsiKeyword.NULL);
          result.addElement(JavaSmartCompletionContributor.decorate(item, infos));
          return;
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:HighlightExitPointsHandlerFactory.java   
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(@NotNull Editor editor, @NotNull PsiFile file, @NotNull PsiElement target) {
  if (target instanceof PsiKeyword) {
    if (PsiKeyword.RETURN.equals(target.getText()) || PsiKeyword.THROW.equals(target.getText())) {
      return new HighlightExitPointsHandler(editor, file, target);
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:ChangeExtendsToImplementsFix.java   
public ChangeExtendsToImplementsFix(@NotNull PsiClass aClass, @NotNull PsiClassType classToExtendFrom) {
  super(aClass, classToExtendFrom, true);
  myName = myClassToExtendFrom == null ? getFamilyName() :
           QuickFixBundle.message("exchange.extends.implements.keyword",
                                  aClass.isInterface() == myClassToExtendFrom.isInterface() ? PsiKeyword.IMPLEMENTS : PsiKeyword.EXTENDS,
                                  aClass.isInterface() == myClassToExtendFrom.isInterface() ? PsiKeyword.EXTENDS : PsiKeyword.IMPLEMENTS,
                                  myClassToExtendFrom.getName());
}
项目:intellij-ce-playground    文件:JavaWordSelectioner.java   
@Override
public boolean canSelect(PsiElement e) {
  if (e instanceof PsiKeyword) {
    return true;
  }
  if (e instanceof PsiJavaToken) {
    IElementType tokenType = ((PsiJavaToken)e).getTokenType();
    return tokenType == JavaTokenType.IDENTIFIER || tokenType == JavaTokenType.STRING_LITERAL;
  }
  return false;
}
项目:intellij-ce-playground    文件:IfStatementSelectioner.java   
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
  List<TextRange> result = new ArrayList<TextRange>();
  result.addAll(expandToWholeLine(editorText, e.getTextRange(), false));

  PsiIfStatement statement = (PsiIfStatement)e;

  final PsiKeyword elseKeyword = statement.getElseElement();
  if (elseKeyword != null) {
    final PsiStatement then = statement.getThenBranch();
    if (then != null) {
      final TextRange thenRange = new TextRange(statement.getTextRange().getStartOffset(), then.getTextRange().getEndOffset());
      if (thenRange.contains(cursorOffset)) {
        result.addAll(expandToWholeLine(editorText, thenRange, false));
      }
    }

    result.addAll(expandToWholeLine(editorText,
                                    new TextRange(elseKeyword.getTextRange().getStartOffset(),
                                                  statement.getTextRange().getEndOffset()),
                                    false));

    final PsiStatement branch = statement.getElseBranch();
    if (branch instanceof PsiIfStatement) {
      PsiIfStatement elseIf = (PsiIfStatement)branch;
      final PsiKeyword element = elseIf.getElseElement();
      if (element != null) {
        final PsiStatement elseThen = elseIf.getThenBranch();
        if (elseThen != null) {
          result.addAll(expandToWholeLine(editorText,
                                          new TextRange(elseKeyword.getTextRange().getStartOffset(),
                                                        elseThen.getTextRange().getEndOffset()),
                                          false));
        }
      }
    }
  }

  return result;
}
项目:intellij-ce-playground    文件:JavadocGenerationPanel.java   
String getScope() {
  switch (myScopeSlider.getValue()) {
    case 1:
      return PsiKeyword.PUBLIC;
    case 2:
      return PsiKeyword.PROTECTED;
    case 3:
      return PsiKeyword.PACKAGE;
    case 4:
      return PsiKeyword.PRIVATE;
    default:
      return null;
  }
}
项目:intellij-ce-playground    文件:ChainCompletionLookupElementUtil.java   
public static LookupElement createLookupElement(final PsiMethod method,
                                                final @Nullable TIntObjectHashMap<SubLookupElement> replaceElements) {
  if (method.isConstructor()) {
    //noinspection ConstantConditions
    return LookupElementBuilder.create(String.format("%s %s", PsiKeyword.NEW, method.getContainingClass().getName()));
  } else if (method.hasModifierProperty(PsiModifier.STATIC)) {
    return new ChainCompletionMethodCallLookupElement(method, replaceElements, false, true);
  } else {
    return new ChainCompletionMethodCallLookupElement(method, replaceElements);
  }
}
项目:intellij-ce-playground    文件:TabbedPaneLayoutSourceGenerator.java   
public void generateComponentLayout(final LwComponent component,
                                    final FormSourceCodeGenerator generator,
                                    final String variable,
                                    final String parentVariable) {
  final LwTabbedPane.Constraints tabConstraints = (LwTabbedPane.Constraints)component.getCustomLayoutConstraints();
  if (tabConstraints == null){
    throw new IllegalArgumentException("tab constraints cannot be null: " + component.getId());
  }

  generator.startMethodCall(parentVariable, "addTab");
  generator.push(tabConstraints.myTitle);
  if (tabConstraints.myIcon != null || tabConstraints.myToolTip != null) {
    if (tabConstraints.myIcon == null) {
      generator.pushVar(PsiKeyword.NULL);
    }
    else {
      generator.pushIcon(tabConstraints.myIcon);
    }
  }
  generator.pushVar(variable);
  if (tabConstraints.myToolTip != null) {
    generator.push(tabConstraints.myToolTip);
  }
  generator.endMethod();

  int index = component.getParent().indexOfComponent(component);
  if (tabConstraints.myDisabledIcon != null) {
    generator.startMethodCall(parentVariable, "setDisabledIconAt");
    generator.push(index);
    generator.pushIcon(tabConstraints.myDisabledIcon);
    generator.endMethod();
  }
  if (!tabConstraints.myEnabled) {
    generator.startMethodCall(parentVariable, "setEnabledAt");
    generator.push(index);
    generator.push(tabConstraints.myEnabled);
    generator.endMethod();
  }
}
项目:tools-idea    文件:ModifierListElement.java   
@Override
public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) {
  if (before == null) {
    if (first == last && ElementType.KEYWORD_BIT_SET.contains(first.getElementType())) {
      anchor = getDefaultAnchor((PsiModifierList)SourceTreeToPsiMap.treeElementToPsi(this),
                                (PsiKeyword)SourceTreeToPsiMap.treeElementToPsi(first));
      before = Boolean.TRUE;
    }
  }
  return super.addInternal(first, last, anchor, before);
}
项目:tools-idea    文件:ModifierListElement.java   
@Nullable
private static ASTNode getDefaultAnchor(PsiModifierList modifierList, PsiKeyword modifier) {
  Integer order = ourModifierToOrderMap.get(modifier.getText());
  if (order == null) return null;
  for (ASTNode child = SourceTreeToPsiMap.psiToTreeNotNull(modifierList).getFirstChildNode(); child != null; child = child.getTreeNext()) {
    if (ElementType.KEYWORD_BIT_SET.contains(child.getElementType())) {
      Integer order1 = ourModifierToOrderMap.get(child.getText());
      if (order1 == null) continue;
      if (order1.intValue() > order.intValue()) {
        return child;
      }
    }
  }
  return null;
}
项目:tools-idea    文件:NullSmartCompletionContributor.java   
public NullSmartCompletionContributor() {
  extend(CompletionType.SMART, and(JavaSmartCompletionContributor.INSIDE_EXPRESSION,
                                                    not(psiElement().afterLeaf("."))), new ExpectedTypeBasedCompletionProvider() {
    @Override
    protected void addCompletions(final CompletionParameters parameters,
                                  final CompletionResultSet result, final Collection<ExpectedTypeInfo> infos) {
      if (!StringUtil.startsWithChar(result.getPrefixMatcher().getPrefix(), 'n')) {
        return;
      }

      LinkedHashSet<CompletionResult> results = result.runRemainingContributors(parameters, true);
      for (CompletionResult completionResult : results) {
        if (completionResult.isStartMatch()) {
          return;
        }
      }

      for (final ExpectedTypeInfo info : infos) {
        if (!(info.getType() instanceof PsiPrimitiveType)) {
          final LookupItem item = (LookupItem)BasicExpressionCompletionContributor.createKeywordLookupItem(parameters.getPosition(), PsiKeyword.NULL);
          item.setAttribute(LookupItem.TYPE, PsiType.NULL);
          result.addElement(JavaSmartCompletionContributor.decorate(item, infos));
          return;
        }
      }
    }
  });
}
项目:tools-idea    文件:ChainCompletionLookupElementUtil.java   
public static LookupElement createLookupElement(final PsiMethod method,
                                                final @Nullable TIntObjectHashMap<SubLookupElement> replaceElements) {
  if (method.isConstructor()) {
    //noinspection ConstantConditions
    return LookupElementBuilder.create(String.format("%s %s", PsiKeyword.NEW, method.getContainingClass().getName()));
  } else if (method.hasModifierProperty(PsiModifier.STATIC)) {
    return new ChainCompletionMethodCallLookupElement(method, replaceElements, false, true);
  } else {
    return new ChainCompletionMethodCallLookupElement(method, replaceElements);
  }
}
项目:tools-idea    文件:HighlightExitPointsHandlerFactory.java   
@Override
public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
  int offset = TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
  PsiElement target = file.findElementAt(offset);
  if (target instanceof PsiKeyword) {
    if (PsiKeyword.RETURN.equals(target.getText()) || PsiKeyword.THROW.equals(target.getText())) {
      return new HighlightExitPointsHandler(editor, file, target);
    }
  }
  return null;
}
项目:tools-idea    文件:ChangeExtendsToImplementsFix.java   
public ChangeExtendsToImplementsFix(PsiClass aClass, PsiClassType classToExtendFrom) {
  super(aClass, classToExtendFrom, true);
  myName = QuickFixBundle.message("exchange.extends.implements.keyword",
                                  aClass.isInterface() == myClassToExtendFrom.isInterface() ? PsiKeyword.IMPLEMENTS : PsiKeyword.EXTENDS,
                                  aClass.isInterface() == myClassToExtendFrom.isInterface() ? PsiKeyword.EXTENDS : PsiKeyword.IMPLEMENTS,
                                  myClassToExtendFrom.getName());
}
项目:tools-idea    文件:JavaWordSelectioner.java   
@Override
public boolean canSelect(PsiElement e) {
  if (e instanceof PsiKeyword) {
    return true;
  }
  if (e instanceof PsiJavaToken) {
    IElementType tokenType = ((PsiJavaToken)e).getTokenType();
    return tokenType == JavaTokenType.IDENTIFIER || tokenType == JavaTokenType.STRING_LITERAL;
  }
  return false;
}
项目:tools-idea    文件:IfStatementSelectioner.java   
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
  List<TextRange> result = new ArrayList<TextRange>();
  result.addAll(expandToWholeLine(editorText, e.getTextRange(), false));

  PsiIfStatement statement = (PsiIfStatement)e;

  final PsiKeyword elseKeyword = statement.getElseElement();
  if (elseKeyword != null) {
    result.addAll(expandToWholeLine(editorText,
                                    new TextRange(elseKeyword.getTextRange().getStartOffset(),
                                                  statement.getTextRange().getEndOffset()),
                                    false));

    final PsiStatement branch = statement.getElseBranch();
    if (branch instanceof PsiIfStatement) {
      PsiIfStatement elseIf = (PsiIfStatement)branch;
      final PsiKeyword element = elseIf.getElseElement();
      if (element != null) {
        result.addAll(expandToWholeLine(editorText,
                                        new TextRange(elseKeyword.getTextRange().getStartOffset(),
                                                      elseIf.getThenBranch().getTextRange().getEndOffset()),
                                        false));
      }
    }
  }

  return result;
}
项目:tools-idea    文件:JavadocGenerationPanel.java   
void setScope(String scope) {
  if (PsiKeyword.PUBLIC.equals(scope)) {
    myScopeSlider.setValue(1);
  }
  else if (PsiKeyword.PROTECTED.equals(scope)) {
    myScopeSlider.setValue(2);
  }
  else if (PsiKeyword.PRIVATE.equals(scope)) {
    myScopeSlider.setValue(4);
  }
  else {
    myScopeSlider.setValue(3);
  }
  handleSlider();
}
项目:tools-idea    文件:JavadocGenerationPanel.java   
String getScope() {
  switch (myScopeSlider.getValue()) {
    case 1:
      return PsiKeyword.PUBLIC;
    case 2:
      return PsiKeyword.PROTECTED;
    case 3:
      return PsiKeyword.PACKAGE;
    case 4:
      return PsiKeyword.PRIVATE;
    default:
      return null;
  }
}
项目:tools-idea    文件:TabbedPaneLayoutSourceGenerator.java   
public void generateComponentLayout(final LwComponent component,
                                    final FormSourceCodeGenerator generator,
                                    final String variable,
                                    final String parentVariable) {
  final LwTabbedPane.Constraints tabConstraints = (LwTabbedPane.Constraints)component.getCustomLayoutConstraints();
  if (tabConstraints == null){
    throw new IllegalArgumentException("tab constraints cannot be null: " + component.getId());
  }

  generator.startMethodCall(parentVariable, "addTab");
  generator.push(tabConstraints.myTitle);
  if (tabConstraints.myIcon != null || tabConstraints.myToolTip != null) {
    if (tabConstraints.myIcon == null) {
      generator.pushVar(PsiKeyword.NULL);
    }
    else {
      generator.pushIcon(tabConstraints.myIcon);
    }
  }
  generator.pushVar(variable);
  if (tabConstraints.myToolTip != null) {
    generator.push(tabConstraints.myToolTip);
  }
  generator.endMethod();

  int index = component.getParent().indexOfComponent(component);
  if (tabConstraints.myDisabledIcon != null) {
    generator.startMethodCall(parentVariable, "setDisabledIconAt");
    generator.push(index);
    generator.pushIcon(tabConstraints.myDisabledIcon);
    generator.endMethod();
  }
  if (!tabConstraints.myEnabled) {
    generator.startMethodCall(parentVariable, "setEnabledAt");
    generator.push(index);
    generator.push(tabConstraints.myEnabled);
    generator.endMethod();
  }
}
项目:lombok-intellij-plugin    文件:PsiTypeUtil.java   
@NotNull
public static String getReturnValueOfType(@Nullable PsiType type) {
  if (type instanceof PsiPrimitiveType) {
    if (PsiType.BOOLEAN.equals(type)) {
      return PsiKeyword.FALSE;
    } else {
      return "0";
    }
  } else if (PsiType.VOID.equals(type)) {
    return "";
  } else {
    return PsiKeyword.NULL;
  }
}
项目:consulo-ui-designer    文件:TabbedPaneLayoutSourceGenerator.java   
public void generateComponentLayout(final LwComponent component,
                                    final FormSourceCodeGenerator generator,
                                    final String variable,
                                    final String parentVariable) {
  final LwTabbedPane.Constraints tabConstraints = (LwTabbedPane.Constraints)component.getCustomLayoutConstraints();
  if (tabConstraints == null){
    throw new IllegalArgumentException("tab constraints cannot be null: " + component.getId());
  }

  generator.startMethodCall(parentVariable, "addTab");
  generator.push(tabConstraints.myTitle);
  if (tabConstraints.myIcon != null || tabConstraints.myToolTip != null) {
    if (tabConstraints.myIcon == null) {
      generator.pushVar(PsiKeyword.NULL);
    }
    else {
      generator.pushIcon(tabConstraints.myIcon);
    }
  }
  generator.pushVar(variable);
  if (tabConstraints.myToolTip != null) {
    generator.push(tabConstraints.myToolTip);
  }
  generator.endMethod();

  int index = component.getParent().indexOfComponent(component);
  if (tabConstraints.myDisabledIcon != null) {
    generator.startMethodCall(parentVariable, "setDisabledIconAt");
    generator.push(index);
    generator.pushIcon(tabConstraints.myDisabledIcon);
    generator.endMethod();
  }
  if (!tabConstraints.myEnabled) {
    generator.startMethodCall(parentVariable, "setEnabledAt");
    generator.push(index);
    generator.push(tabConstraints.myEnabled);
    generator.endMethod();
  }
}