Java Code Examples for org.eclipse.jdt.core.dom.SimpleName#toString()
The following examples show how to use
org.eclipse.jdt.core.dom.SimpleName#toString() .
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: LapseView.java From lapse-plus with GNU General Public License v3.0 | 5 votes |
void processNodeSelection(SimpleName sn, HistoryDefinitionLocation defl, CompilationUnit cu, IResource resource, IProgressMonitor monitor){ //_cp.addElement("Visited node " + sn.toString()); if(name2decl(sn, cu, resource) == null) { // only deal with variables logError("No definition for " + sn + " is found"); return; } //Name otherName = decl.getName(); //String var = Name.getFullyQualifiedName(); //fContentProvider.clearElements(); // make the root of the slicing tree HistoryDefinitionLocation dl = new HistoryDefinitionLocation( sn.toString(), (IFile)resource, cu.getLineNumber(sn.getStartPosition()), sn, defl, HistoryDefinitionLocation.INITIAL); if(defl==null){ setCurrentInput(dl); addHistoryEntry(dl); fContentProvider.addElement(dl); } processDecl(sn, cu, resource, dl, new LinkedList<MethodInvocation>(), monitor); //showMessage("Got " + _cp.getElementsCount() + " in the list"); //fViewer.setSelection(new StructuredSelection(covering)); }
Example 2
Source File: MethodInvocationResolver.java From KodeBeagle with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public boolean visit(MethodInvocation node) { SimpleName methodName = node.getName(); List args = node.arguments(); Expression expression = node.getExpression(); Map<String, Integer> scopeBindings = getNodeScopes().get(node); String target = getTarget(expression); String targetType = translateTargetToType(target, scopeBindings); // Add only if you could guess the type of target, else ignore. // TODO: In case of a method in super type, this will still infer it as in "this". if (!targetType.isEmpty()) { List<String> argTypes = translateArgsToTypes(args, scopeBindings); if (!methodStack.empty()) { MethodDeclaration currentMethod = methodStack.peek(); MethodDecl methodDecl = getMethodDecl(currentMethod); List<MethodInvokRef> invoks = methodInvoks.get(methodDecl); if (invoks == null) { invoks = new ArrayList<>(); methodInvoks.put(methodDecl, invoks); } MethodInvokRef methodInvokRef = new MethodInvokRef(methodName.toString(), targetType, target, args .size(), node.getName().getStartPosition(), argTypes, methodName.getLength(), false, getReturnType(node)); invoks.add(methodInvokRef); } } return true; }
Example 3
Source File: MethodInvocationResolver.java From KodeBeagle with Apache License 2.0 | 5 votes |
private MethodDecl getMethodDecl(MethodDeclaration node) { String qualifiedTypeName = currentPackage + "." + Joiner.on(".").skipNulls().join(typesInFile); SimpleName nameNode = node.getName(); String methodName = nameNode.toString(); String returnType = ""; if (node.getReturnType2() != null) { returnType = getNameOfType(node.getReturnType2()); } Map<String, String> params = new HashMap<>(); for (Object p : node.parameters()) { if (p instanceof SingleVariableDeclaration) { SingleVariableDeclaration svd = (SingleVariableDeclaration) p; String varName = svd.getName().toString(); Type type = svd.getType(); String typeName = getNameOfType(type); params.put(varName, typeName); } else { System.err.println("Unxepected AST node type for param - " + p); } } return new MethodDecl(methodName, qualifiedTypeName, returnType, nameNode .getStartPosition(), params); }