Skip to content
Permalink
Browse files

cdt: transit from getNames() to getQualifier() and getLastName()

Signed-off-by: runsisi <runsisi@hust.edu.cn>
  • Loading branch information...
runsisi committed Sep 30, 2019
1 parent 3a2a7df commit ffca9ef7748693c70668c769855d9642ffe34eaa
Showing with 18 additions and 1 deletion.
  1. +18 −1 BracketeerCDT/src/com/chookapp/org/bracketeer/cdt/ClosingBracketHintVisitor.java
@@ -11,6 +11,8 @@
package com.chookapp.org.bracketeer.cdt;

import java.util.EmptyStackException;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@@ -37,6 +39,7 @@
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTIfStatement;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNameSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@@ -457,12 +460,26 @@ private void addBrackets(IASTName name) throws BadLocationException
}
else if( name instanceof ICPPASTQualifiedName)
{
IASTName[] names = ((ICPPASTQualifiedName) name).getNames();
List<IASTName> names = getNames((ICPPASTQualifiedName) name);
for (IASTName n : names)
addBrackets(n);
}
}

private List<IASTName> getNames(ICPPASTQualifiedName qualifiedName) {
final IASTName lastName = qualifiedName.getLastName();
final List<IASTName> names = new ArrayList<IASTName>();
for (ICPPASTNameSpecifier name : qualifiedName.getQualifier()) {
if (name instanceof IASTName) {
names.add((IASTName) name);
}
}
if (lastName != null) {
names.add(lastName);
}
return names;
}

private void addBrackets(IASTNode[] args) throws BadLocationException
{
if(args == null || args.length == 0)

0 comments on commit ffca9ef

Please sign in to comment.
You can’t perform that action at this time.