本文整理汇总了Java中org.eclipse.jdt.core.dom.Initializer类的典型用法代码示例。如果您正苦于以下问题:Java Initializer类的具体用法?Java Initializer怎么用?Java Initializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Initializer类属于org.eclipse.jdt.core.dom包,在下文中一共展示了Initializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeDestinations
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private void initializeDestinations() {
List<ASTNode> result = new ArrayList<>();
BodyDeclaration decl = fAnalyzer.getEnclosingBodyDeclaration();
ASTNode current = ASTResolving.findParentType(decl.getParent());
if (fAnalyzer.isValidDestination(current)) {
result.add(current);
}
if (current != null && (decl instanceof MethodDeclaration || decl instanceof Initializer || decl instanceof FieldDeclaration)) {
ITypeBinding binding = ASTNodes.getEnclosingType(current);
ASTNode next = ASTResolving.findParentType(current.getParent());
while (next != null && binding != null && binding.isNested()) {
if (fAnalyzer.isValidDestination(next)) {
result.add(next);
}
current = next;
binding = ASTNodes.getEnclosingType(current);
next = ASTResolving.findParentType(next.getParent());
}
}
fDestinations = result.toArray(new ASTNode[result.size()]);
fDestination = fDestinations[fDestinationIndex];
}
示例2: checkInitialConditions
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
initAST();
if (fTempDeclarationNode == null || fTempDeclarationNode.resolveBinding() == null)
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.RenameTempRefactoring_must_select_local);
if (!Checks.isDeclaredIn(fTempDeclarationNode, MethodDeclaration.class)
&& !Checks.isDeclaredIn(fTempDeclarationNode, Initializer.class)
&& !Checks.isDeclaredIn(fTempDeclarationNode, LambdaExpression.class)) {
if (JavaModelUtil.is18OrHigher(fCu.getJavaProject()))
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.RenameTempRefactoring_only_in_methods_initializers_and_lambda);
return RefactoringStatus.createFatalErrorStatus(
RefactoringCoreMessages.RenameTempRefactoring_only_in_methods_and_initializers);
}
initNames();
return new RefactoringStatus();
}
示例3: initializeDestinations
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private void initializeDestinations() {
List<ASTNode> result = new ArrayList<ASTNode>();
BodyDeclaration decl = fAnalyzer.getEnclosingBodyDeclaration();
ASTNode current = ASTResolving.findParentType(decl.getParent());
if (fAnalyzer.isValidDestination(current)) {
result.add(current);
}
if (current != null
&& (decl instanceof MethodDeclaration
|| decl instanceof Initializer
|| decl instanceof FieldDeclaration)) {
ITypeBinding binding = ASTNodes.getEnclosingType(current);
ASTNode next = ASTResolving.findParentType(current.getParent());
while (next != null && binding != null && binding.isNested()) {
if (fAnalyzer.isValidDestination(next)) {
result.add(next);
}
current = next;
binding = ASTNodes.getEnclosingType(current);
next = ASTResolving.findParentType(next.getParent());
}
}
fDestinations = result.toArray(new ASTNode[result.size()]);
fDestination = fDestinations[fDestinationIndex];
}
示例4: computeConstantDeclarationLocation
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private void computeConstantDeclarationLocation() throws JavaModelException {
if (isDeclarationLocationComputed()) return;
BodyDeclaration lastStaticDependency = null;
Iterator<BodyDeclaration> decls =
getContainingTypeDeclarationNode().bodyDeclarations().iterator();
while (decls.hasNext()) {
BodyDeclaration decl = decls.next();
int modifiers;
if (decl instanceof FieldDeclaration) modifiers = ((FieldDeclaration) decl).getModifiers();
else if (decl instanceof Initializer) modifiers = ((Initializer) decl).getModifiers();
else {
continue; /* this declaration is not a field declaration
or initializer, so the placement of the constant
declaration relative to it does not matter */
}
if (Modifier.isStatic(modifiers) && depends(getSelectedExpression(), decl))
lastStaticDependency = decl;
}
if (lastStaticDependency == null) fInsertFirst = true;
else fToInsertAfter = lastStaticDependency;
}
示例5: isStaticFieldOrStaticInitializer
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private static boolean isStaticFieldOrStaticInitializer(BodyDeclaration node) {
if (node instanceof MethodDeclaration || node instanceof AbstractTypeDeclaration) return false;
int modifiers;
if (node instanceof FieldDeclaration) {
modifiers = ((FieldDeclaration) node).getModifiers();
} else if (node instanceof Initializer) {
modifiers = ((Initializer) node).getModifiers();
} else {
Assert.isTrue(false);
return false;
}
if (!Modifier.isStatic(modifiers)) return false;
return true;
}
示例6: addExtractCheckedLocalProposal
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
/**
* Fix for {@link IProblem#NullableFieldReference}
*
* @param context context
* @param problem problem to be fixed
* @param proposals accumulator for computed proposals
*/
public static void addExtractCheckedLocalProposal(
IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
CompilationUnit compilationUnit = context.getASTRoot();
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
ASTNode selectedNode = problem.getCoveringNode(compilationUnit);
SimpleName name = findProblemFieldName(selectedNode, problem.getProblemId());
if (name == null) return;
ASTNode method = ASTNodes.getParent(selectedNode, MethodDeclaration.class);
if (method == null) method = ASTNodes.getParent(selectedNode, Initializer.class);
if (method == null) return;
proposals.add(new ExtractToNullCheckedLocalProposal(cu, compilationUnit, name, method));
}
示例7: checkInitialConditions
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException {
initAST();
if (fTempDeclarationNode == null || fTempDeclarationNode.resolveBinding() == null)
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameTempRefactoring_must_select_local);
if (!Checks.isDeclaredIn(fTempDeclarationNode, MethodDeclaration.class)
&& !Checks.isDeclaredIn(fTempDeclarationNode, Initializer.class)
&& !Checks.isDeclaredIn(fTempDeclarationNode, LambdaExpression.class)) {
if (JavaModelUtil.is18OrHigher(fCu.getJavaProject()))
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameTempRefactoring_only_in_methods_initializers_and_lambda);
return RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.RenameTempRefactoring_only_in_methods_and_initializers);
}
initNames();
return new RefactoringStatus();
}
示例8: initializeDestinations
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private void initializeDestinations() {
List<ASTNode> result= new ArrayList<ASTNode>();
BodyDeclaration decl= fAnalyzer.getEnclosingBodyDeclaration();
ASTNode current= ASTResolving.findParentType(decl.getParent());
if (fAnalyzer.isValidDestination(current)) {
result.add(current);
}
if (current != null && (decl instanceof MethodDeclaration || decl instanceof Initializer || decl instanceof FieldDeclaration)) {
ITypeBinding binding= ASTNodes.getEnclosingType(current);
ASTNode next= ASTResolving.findParentType(current.getParent());
while (next != null && binding != null && binding.isNested()) {
if (fAnalyzer.isValidDestination(next)) {
result.add(next);
}
current= next;
binding= ASTNodes.getEnclosingType(current);
next= ASTResolving.findParentType(next.getParent());
}
}
fDestinations= result.toArray(new ASTNode[result.size()]);
fDestination= fDestinations[fDestinationIndex];
}
示例9: isStaticFieldOrStaticInitializer
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private static boolean isStaticFieldOrStaticInitializer(BodyDeclaration node) {
if(node instanceof MethodDeclaration || node instanceof AbstractTypeDeclaration)
return false;
int modifiers;
if(node instanceof FieldDeclaration) {
modifiers = ((FieldDeclaration) node).getModifiers();
} else if(node instanceof Initializer) {
modifiers = ((Initializer) node).getModifiers();
} else {
Assert.isTrue(false);
return false;
}
if(!Modifier.isStatic(modifiers))
return false;
return true;
}
示例10: addExtractCheckedLocalProposal
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
/**
* Fix for {@link IProblem#NullableFieldReference}
* @param context context
* @param problem problem to be fixed
* @param proposals accumulator for computed proposals
*/
public static void addExtractCheckedLocalProposal(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) {
CompilationUnit compilationUnit = context.getASTRoot();
ICompilationUnit cu= (ICompilationUnit) compilationUnit.getJavaElement();
ASTNode selectedNode= problem.getCoveringNode(compilationUnit);
SimpleName name= findProblemFieldName(selectedNode, problem.getProblemId());
if (name == null)
return;
ASTNode method= ASTNodes.getParent(selectedNode, MethodDeclaration.class);
if (method == null)
method= ASTNodes.getParent(selectedNode, Initializer.class);
if (method == null)
return;
proposals.add(new ExtractToNullCheckedLocalProposal(cu, compilationUnit, name, method));
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:NullAnnotationsCorrectionProcessor.java
示例11: computeLastStatementSelected
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private void computeLastStatementSelected() {
ASTNode[] nodes= getSelectedNodes();
if (nodes.length == 0) {
fIsLastStatementSelected= false;
} else {
Block body= null;
if (fEnclosingBodyDeclaration instanceof MethodDeclaration) {
body= ((MethodDeclaration) fEnclosingBodyDeclaration).getBody();
} else if (fEnclosingBodyDeclaration instanceof Initializer) {
body= ((Initializer) fEnclosingBodyDeclaration).getBody();
}
if (body != null) {
List<Statement> statements= body.statements();
fIsLastStatementSelected= nodes[nodes.length - 1] == statements.get(statements.size() - 1);
}
}
}
示例12: initializeDestinations
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private void initializeDestinations() {
List<ASTNode> result= new ArrayList<ASTNode>();
BodyDeclaration decl= fAnalyzer.getEnclosingBodyDeclaration();
ASTNode current= getNextParent(decl);
result.add(current);
if (decl instanceof MethodDeclaration || decl instanceof Initializer || decl instanceof FieldDeclaration) {
ITypeBinding binding= ASTNodes.getEnclosingType(current);
ASTNode next= getNextParent(current);
while (next != null && binding != null && binding.isNested()) {
result.add(next);
current= next;
binding= ASTNodes.getEnclosingType(current);
next= getNextParent(next);
}
}
fDestinations= result.toArray(new ASTNode[result.size()]);
fDestination= fDestinations[fDestinationIndex];
}
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion-Juno38,代码行数:19,代码来源:ExtractMethodRefactoring.java
示例13: lineFromNumber
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
private int lineFromNumber(final ASTNode node)
{
int nodeStart = node.getStartPosition();
/**
* Skip the java documentation in body declaration nodes.
*/
if (node instanceof AbstractTypeDeclaration)
{
nodeStart = ((AbstractTypeDeclaration) node).getName().getStartPosition();
}
else if (node instanceof EnumConstantDeclaration)
{
nodeStart = ((EnumConstantDeclaration) node).getName().getStartPosition();
}
else if (node instanceof Initializer)
{
nodeStart = ((Initializer) node).getBody().getStartPosition();
}
else if (node instanceof MethodDeclaration)
{
nodeStart = ((MethodDeclaration) node).getName().getStartPosition();
}
return ASTTools.lineNumber(node, nodeStart);
}
示例14: visit
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
/**
* Type or instance initializer (entry point).
*
* ['static'] '{' statement '}'
*/
@Override
public boolean visit(final Initializer node)
{
// initializers are processed only at the top level
if (mdg.parent() != null)
{
return false;
}
final int lineNo = lineStart(node);
// new dependence
createDependence(LK_INITIALIZER, lineNo, mdg.parent());
// recursively append "body" dependences
if (node.getBody() != null)
{
appendRecursive(lineNo, mdg.parent(), node.getBody());
processJumpDependences();
}
// visit children
return false;
}
示例15: getMemberFromOffset
import org.eclipse.jdt.core.dom.Initializer; //导入依赖的package包/类
public static IMember getMemberFromOffset(ITextEditor javaEditor, int offset) throws JavaModelException {
ITypeRoot element= JavaUI.getEditorInputTypeRoot(javaEditor.getEditorInput());
CompilationUnit ast = SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, null);
NodeFinder finder= new NodeFinder(ast, offset, 0);
ASTNode node= finder.getCoveringNode();
while(node != null) {
if(node instanceof Initializer) {
TypeDeclaration typeDeclaration = (TypeDeclaration) node.getParent();
IType type = (IType) typeDeclaration.resolveBinding().getJavaElement();
for(IInitializer initializer : type.getInitializers()) {
if(node.getStartPosition() == initializer.getSourceRange().getOffset()
&& Flags.isStatic(initializer.getFlags())) {
return initializer;
}
}
}
if(node instanceof MethodDeclaration) {
IMethodBinding binding = ((MethodDeclaration) node).resolveBinding();
return (IMethod) binding.getJavaElement();
}
node = node.getParent();
}
return null;
}