本文整理汇总了Java中com.intellij.psi.PsiKeyword类的典型用法代码示例。如果您正苦于以下问题:Java PsiKeyword类的具体用法?Java PsiKeyword怎么用?Java PsiKeyword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PsiKeyword类属于com.intellij.psi包,在下文中一共展示了PsiKeyword类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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() ) );
}
}
}
}
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:20,代码来源:ExtensionClassAnnotator.java
示例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();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavadocGenerationPanel.java
示例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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ThrowsUsageTargetProvider.java
示例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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:DfaTypeValue.java
示例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;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ThrowsUsageTargetProvider.java
示例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);
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:StringEqualityInspection.java
示例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);
}
}
}
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:LombokInspection.java
示例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;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:FileParser.java
示例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;
}
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:ModuleParser.java
示例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);
}
开发者ID:consulo,项目名称:consulo-java,代码行数:23,代码来源:DfaConstValue.java
示例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());
}
}
});
}
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:JavaSoftKeywordHighlightingPass.java
示例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);
}
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:TrivialIfInspection.java
示例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);
}
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:TrivialIfInspection.java
示例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);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ModifierListElement.java
示例16: getDefaultAnchor
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:ModifierListElement.java
示例17: NullSmartCompletionContributor
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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;
}
}
}
});
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:NullSmartCompletionContributor.java
示例18: createHighlightUsagesHandler
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:HighlightExitPointsHandlerFactory.java
示例19: ChangeExtendsToImplementsFix
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
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());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ChangeExtendsToImplementsFix.java
示例20: canSelect
import com.intellij.psi.PsiKeyword; //导入依赖的package包/类
@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;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JavaWordSelectioner.java
注:本文中的com.intellij.psi.PsiKeyword类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论