本文整理汇总了Java中com.intellij.psi.PsiKeyword类的典型用法代码示例。如果您正苦于以下问题:Java PsiKeyword类的具体用法?Java PsiKeyword怎么用?Java PsiKeyword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiKeyword类属于com.intellij.psi包,在下文中一共展示了PsiKeyword类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verifyExtensionInterfaces
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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() ) );
}
}
}
}
示例2: setScope
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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();
}
示例3: getTargets
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
示例4: visitTryStatement
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FinallyBlockCannotCompleteNormallyInspection.java
示例5: create
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
示例6: getTargets
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
示例7: visitBinaryExpression
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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);
}
示例8: visitMethodCallExpression
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
/**
* 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);
}
}
}
示例9: stopImportListParsing
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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;
}
示例10: parseStatement
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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;
}
示例11: create
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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);
}
示例12: doCollectInformation
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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());
}
}
});
}
示例13: isSimplifiableImplicitReturn
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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);
}
示例14: isSimplifiableImplicitReturnNegated
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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);
}
示例15: addInternal
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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);
}