use of org.eclipse.jdt.core.dom.QualifiedName in project eclipse.jdt.ls by eclipse.
the class NewVariableCorrectionProposal method evaluateFieldModifiers.
private int evaluateFieldModifiers(ASTNode newTypeDecl) {
if (fSenderBinding.isAnnotation()) {
return 0;
}
if (fSenderBinding.isInterface()) {
// for interface members copy the modifiers from an existing field
FieldDeclaration[] fieldDecls = ((TypeDeclaration) newTypeDecl).getFields();
if (fieldDecls.length > 0) {
return fieldDecls[0].getModifiers();
}
return 0;
}
int modifiers = 0;
if (fVariableKind == CONST_FIELD) {
modifiers |= Modifier.FINAL | Modifier.STATIC;
} else {
ASTNode parent = fOriginalNode.getParent();
if (parent instanceof QualifiedName) {
IBinding qualifierBinding = ((QualifiedName) parent).getQualifier().resolveBinding();
if (qualifierBinding instanceof ITypeBinding) {
modifiers |= Modifier.STATIC;
}
} else if (ASTResolving.isInStaticContext(fOriginalNode)) {
modifiers |= Modifier.STATIC;
}
}
ASTNode node = ASTResolving.findParentType(fOriginalNode, true);
if (newTypeDecl.equals(node)) {
modifiers |= Modifier.PRIVATE;
} else if (node instanceof AnonymousClassDeclaration) {
modifiers |= Modifier.PROTECTED;
} else {
modifiers |= Modifier.PUBLIC;
}
return modifiers;
}
use of org.eclipse.jdt.core.dom.QualifiedName in project eclipse.jdt.ls by eclipse.
the class SemanticTokensVisitor method visitSimpleNamesOfName.
/**
* Helper method to recursively visit all the simple names of a {@link Name} node
* using the specified {@link NodeVisitor}.
*
* @param name A {@link Name} node (may be {@code null}).
* @param visitor The {@link NodeVisitor} to use.
*/
private void visitSimpleNamesOfName(Name name, NodeVisitor<SimpleName> visitor) {
if (name == null) {
return;
}
if (name instanceof SimpleName) {
visitor.visit((SimpleName) name);
} else {
QualifiedName qualifiedName = (QualifiedName) name;
visitSimpleNamesOfName(qualifiedName.getQualifier(), visitor);
visitor.visit(qualifiedName.getName());
}
}
use of org.eclipse.jdt.core.dom.QualifiedName in project eclipse.jdt.ls by eclipse.
the class SemanticTokensVisitor method nonPackageNameOfImportDeclarationVisitor.
/**
* {@link NodeVisitor} for {@link Name} nodes inside an import declaration that are not package names.
*
* @param nonPackageName
*/
private void nonPackageNameOfImportDeclarationVisitor(Name nonPackageName) {
if (nonPackageName instanceof SimpleName) {
nonPackageName.accept(this);
} else {
QualifiedName qualifiedName = (QualifiedName) nonPackageName;
Name qualifier = qualifiedName.getQualifier();
if (hasPackageQualifier(qualifiedName)) {
addTokenToSimpleNamesOfName(qualifier, TokenType.NAMESPACE);
} else {
nonPackageNameOfImportDeclarationVisitor(qualifier);
}
qualifiedName.getName().accept(this);
}
}
Aggregations