org.eclipse.jdt.core.dom.SynchronizedStatement Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.SynchronizedStatement.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CodeBlock.java From SimFix with GNU General Public License v2.0 | 6 votes |
private SynchronizedStmt visit(SynchronizedStatement node) { int startLine = _cunit.getLineNumber(node.getStartPosition()); int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength()); SynchronizedStmt synchronizedStmt = new SynchronizedStmt(startLine, endLine, node); if(node.getExpression() != null){ Expr expression = (Expr) process(node.getExpression()); expression.setParent(synchronizedStmt); synchronizedStmt.setExpression(expression); } Blk blk = (Blk) process(node.getBody()); blk.setParent(synchronizedStmt); synchronizedStmt.setBlock(blk); return synchronizedStmt; }
Example #2
Source File: CFGBranchNode.java From JDeodorant with MIT License | 6 votes |
protected void processBlockStatement(Set<AbstractStatement> nestedStatements, CompositeStatementObject blockStatement) { for(AbstractStatement statementInsideBlock : blockStatement.getStatements()) { if(statementInsideBlock instanceof TryStatementObject) { CompositeStatementObject tryStatement = (CompositeStatementObject)statementInsideBlock; processTryStatement(nestedStatements, tryStatement); } else if(statementInsideBlock.getStatement() instanceof LabeledStatement || statementInsideBlock.getStatement() instanceof SynchronizedStatement) { CompositeStatementObject labeledStatement = (CompositeStatementObject)statementInsideBlock; processLabeledStatement(nestedStatements, labeledStatement); } else if(statementInsideBlock.getStatement() instanceof Block) { CompositeStatementObject blockStatement2 = (CompositeStatementObject)statementInsideBlock; processBlockStatement(nestedStatements, blockStatement2); } else nestedStatements.add(statementInsideBlock); } }
Example #3
Source File: NecessaryParenthesesChecker.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static boolean locationNeedsParentheses(StructuralPropertyDescriptor locationInParent) { if (locationInParent instanceof ChildListPropertyDescriptor && locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) { // e.g. argument lists of MethodInvocation, ClassInstanceCreation, dimensions of ArrayCreation ... return false; } if (locationInParent == VariableDeclarationFragment.INITIALIZER_PROPERTY || locationInParent == SingleVariableDeclaration.INITIALIZER_PROPERTY || locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == EnhancedForStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY || locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == AssertStatement.MESSAGE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY || locationInParent == SwitchStatement.EXPRESSION_PROPERTY || locationInParent == SwitchCase.EXPRESSION_PROPERTY || locationInParent == ArrayAccess.INDEX_PROPERTY || locationInParent == ThrowStatement.EXPRESSION_PROPERTY || locationInParent == SynchronizedStatement.EXPRESSION_PROPERTY || locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) { return false; } return true; }
Example #4
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 5 votes |
public boolean visit(SynchronizedStatement stmnt){ /* * synchronized ( Expression ) Block */ styledString.append("synchronized", new StyledStringStyler(keywordStyle)); appendSpace(); appendOpenParenthesis(); handleExpression((Expression) stmnt.getExpression()); appendClosedParenthesis(); return false; }
Example #5
Source File: ASTNodeMatcher.java From JDeodorant with MIT License | 5 votes |
public boolean match(SynchronizedStatement node, Object other) { if (!(other instanceof SynchronizedStatement)) { return false; } SynchronizedStatement o = (SynchronizedStatement) other; if(isNestedUnderAnonymousClassDeclaration(node) && isNestedUnderAnonymousClassDeclaration(o)) { return super.match(node, o); } return ( safeSubtreeMatch(node.getExpression(), o.getExpression())); }
Example #6
Source File: CFGBranchNode.java From JDeodorant with MIT License | 5 votes |
public Set<CFGNode> getImmediatelyNestedNodesFromAST() { Set<CFGNode> nestedNodes = new LinkedHashSet<CFGNode>(); AbstractStatement abstractStatement = getStatement(); if(abstractStatement instanceof CompositeStatementObject) { Set<AbstractStatement> nestedStatements = new LinkedHashSet<AbstractStatement>(); CompositeStatementObject composite = (CompositeStatementObject)abstractStatement; List<AbstractStatement> statements = composite.getStatements(); for(AbstractStatement statement : statements) { if(statement.getStatement() instanceof Block) { CompositeStatementObject blockStatement = (CompositeStatementObject)statement; processBlockStatement(nestedStatements, blockStatement); } else if(statement.getStatement() instanceof LabeledStatement || statement.getStatement() instanceof SynchronizedStatement) { CompositeStatementObject labeledStatement = (CompositeStatementObject)statement; processLabeledStatement(nestedStatements, labeledStatement); } else if(statement instanceof TryStatementObject) { CompositeStatementObject tryStatement = (CompositeStatementObject)statement; processTryStatement(nestedStatements, tryStatement); } else nestedStatements.add(statement); } List<BasicBlock> nestedBasicBlocks = getNestedBasicBlocks(); if(this instanceof CFGBranchDoLoopNode) nestedBasicBlocks.add(getBasicBlock()); else nestedBasicBlocks.add(0, getBasicBlock()); for(BasicBlock nestedBlock : nestedBasicBlocks) { List<CFGNode> nodes = nestedBlock.getAllNodes(); for(CFGNode node : nodes) { if(nestedStatements.contains(node.getStatement())) { nestedNodes.add(node); } } } } return nestedNodes; }
Example #7
Source File: CFGBranchIfNode.java From JDeodorant with MIT License | 5 votes |
public Set<CFGNode> getImmediatelyNestedNodesInFalseControlFlow() { Set<CFGNode> nestedNodes = new LinkedHashSet<CFGNode>(); AbstractStatement abstractStatement = getStatement(); if(abstractStatement instanceof CompositeStatementObject) { Set<AbstractStatement> nestedStatements = new LinkedHashSet<AbstractStatement>(); CompositeStatementObject composite = (CompositeStatementObject)abstractStatement; List<AbstractStatement> statements = composite.getStatements(); if(statements.size() == 2) { AbstractStatement falseControlFlowStatement = statements.get(1); if(falseControlFlowStatement.getStatement() instanceof Block) { CompositeStatementObject blockStatement = (CompositeStatementObject)falseControlFlowStatement; processBlockStatement(nestedStatements, blockStatement); } else if(falseControlFlowStatement.getStatement() instanceof LabeledStatement || falseControlFlowStatement.getStatement() instanceof SynchronizedStatement) { CompositeStatementObject labeledStatement = (CompositeStatementObject)falseControlFlowStatement; processLabeledStatement(nestedStatements, labeledStatement); } else if(falseControlFlowStatement instanceof TryStatementObject) { CompositeStatementObject tryStatement = (CompositeStatementObject)falseControlFlowStatement; processTryStatement(nestedStatements, tryStatement); } else nestedStatements.add(falseControlFlowStatement); List<BasicBlock> nestedBasicBlocks = getNestedBasicBlocks(); nestedBasicBlocks.add(0, getBasicBlock()); for(BasicBlock nestedBlock : nestedBasicBlocks) { List<CFGNode> nodes = nestedBlock.getAllNodes(); for(CFGNode node : nodes) { if(nestedStatements.contains(node.getStatement())) { nestedNodes.add(node); } } } } } return nestedNodes; }
Example #8
Source File: CFGBranchIfNode.java From JDeodorant with MIT License | 5 votes |
public Set<CFGNode> getImmediatelyNestedNodesInTrueControlFlow() { Set<CFGNode> nestedNodes = new LinkedHashSet<CFGNode>(); AbstractStatement abstractStatement = getStatement(); if(abstractStatement instanceof CompositeStatementObject) { Set<AbstractStatement> nestedStatements = new LinkedHashSet<AbstractStatement>(); CompositeStatementObject composite = (CompositeStatementObject)abstractStatement; List<AbstractStatement> statements = composite.getStatements(); AbstractStatement trueControlFlowStatement = statements.get(0); if(trueControlFlowStatement.getStatement() instanceof Block) { CompositeStatementObject blockStatement = (CompositeStatementObject)trueControlFlowStatement; processBlockStatement(nestedStatements, blockStatement); } else if(trueControlFlowStatement.getStatement() instanceof LabeledStatement || trueControlFlowStatement.getStatement() instanceof SynchronizedStatement) { CompositeStatementObject labeledStatement = (CompositeStatementObject)trueControlFlowStatement; processLabeledStatement(nestedStatements, labeledStatement); } else if(trueControlFlowStatement instanceof TryStatementObject) { CompositeStatementObject tryStatement = (CompositeStatementObject)trueControlFlowStatement; processTryStatement(nestedStatements, tryStatement); } else nestedStatements.add(trueControlFlowStatement); List<BasicBlock> nestedBasicBlocks = getNestedBasicBlocks(); nestedBasicBlocks.add(0, getBasicBlock()); for(BasicBlock nestedBlock : nestedBasicBlocks) { List<CFGNode> nodes = nestedBlock.getAllNodes(); for(CFGNode node : nodes) { if(nestedStatements.contains(node.getStatement())) { nestedNodes.add(node); } } } } return nestedNodes; }
Example #9
Source File: StatementAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void endVisit(SynchronizedStatement node) { ASTNode firstSelectedNode= getFirstSelectedNode(); if (getSelection().getEndVisitSelectionMode(node) == Selection.SELECTED) { if (firstSelectedNode == node.getBody()) { invalidSelection(RefactoringCoreMessages.StatementAnalyzer_synchronized_statement); } } super.endVisit(node); }
Example #10
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void endVisit(SynchronizedStatement node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getExpression()); process(info, node.getBody()); }
Example #11
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(final SynchronizedStatement node) { this.appendToBuffer("synchronized ("); node.getExpression().accept(this); this.appendToBuffer(") "); node.getBody().accept(this); return false; }
Example #12
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(SynchronizedStatement node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getExpression()); process(info, node.getBody()); }
Example #13
Source File: ConstraintCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(SynchronizedStatement node) { add(fCreator.create(node)); return true; }
Example #14
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(SynchronizedStatement node) { endVisitNode(node); }
Example #15
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(SynchronizedStatement node) { return visitNode(node); }
Example #16
Source File: StatementCollector.java From JDeodorant with MIT License | 4 votes |
public boolean visit(SynchronizedStatement node) { statementList.add(node); controlStatementList.add(node); return true; }
Example #17
Source File: ExtractStatementsVisitor.java From JDeodorant with MIT License | 4 votes |
public boolean visit(SynchronizedStatement node) { statementsList.add(node); controlStatementsList.add(node); return true; }
Example #18
Source File: AstMatchingNodeFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(SynchronizedStatement node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
Example #19
Source File: AstVisitor.java From jdt2famix with Eclipse Public License 1.0 | 4 votes |
/** * Handles synchronized(a) {} */ @Override public boolean visit(SynchronizedStatement node) { importer.createAccessFromExpression((Expression) node.getExpression()); return true; }
Example #20
Source File: SynchronizedStatementObject.java From JDeodorant with MIT License | 4 votes |
public SynchronizedStatementObject(Statement statement, AbstractMethodFragment parent) { super(statement, StatementType.SYNCHRONIZED, parent); AbstractExpression abstractExpression = new AbstractExpression( ((SynchronizedStatement)statement).getExpression(), this); this.addExpression(abstractExpression); }
Example #21
Source File: CodeSearch.java From SimFix with GNU General Public License v2.0 | 4 votes |
public boolean visit(SynchronizedStatement node) { return true; }
Example #22
Source File: ConstraintCreator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 2 votes |
/** * @param node the AST node * @return array of type constraints, may be empty * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SynchronizedStatement) */ public ITypeConstraint[] create(SynchronizedStatement node) { return EMPTY_ARRAY; }