1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-02 05:45:58 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-05-19 19:52:37 -07:00
parent 009a3a7d5f
commit 7e64f6a132
2 changed files with 14 additions and 15 deletions

View file

@ -134,9 +134,7 @@ public class AddIncludeAction extends TextEditorAction {
manager.beginCompoundChange(); manager.beginCompoundChange();
try { try {
edit.apply(document); edit.apply(document);
} catch (MalformedTreeException e) { } catch (MalformedTreeException | BadLocationException e) {
CUIPlugin.log(e);
} catch (BadLocationException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
} }
manager.endCompoundChange(); manager.endCompoundChange();

View file

@ -133,13 +133,13 @@ public class IncludeCreator {
return rootEdit; return rootEdit;
} }
final Map<String, IncludeCandidate> candidatesMap= new HashMap<String, IncludeCandidate>(); final Map<String, IncludeCandidate> candidatesMap= new HashMap<>();
final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false); final IndexFilter filter = IndexFilter.getDeclaredBindingFilter(ast.getLinkage().getLinkageID(), false);
final List<IncludeInfo> requiredIncludes = new ArrayList<IncludeInfo>(); final List<IncludeInfo> requiredIncludes = new ArrayList<>();
final List<UsingDeclaration> usingDeclarations = new ArrayList<UsingDeclaration>(); final List<UsingDeclaration> usingDeclarations = new ArrayList<>();
List<IIndexBinding> bindings = new ArrayList<IIndexBinding>(); List<IIndexBinding> bindings = new ArrayList<>();
try { try {
IIndex index = fContext.getIndex(); IIndex index = fContext.getIndex();
IIndexBinding adaptedBinding= index.adaptBinding(binding); IIndexBinding adaptedBinding= index.adaptBinding(binding);
@ -184,7 +184,7 @@ public class IncludeCreator {
considerForInclusion(definition, macro, index, headerSubstitutor, candidatesMap); considerForInclusion(definition, macro, index, headerSubstitutor, candidatesMap);
} }
final ArrayList<IncludeCandidate> candidates = new ArrayList<IncludeCandidate>(candidatesMap.values()); final ArrayList<IncludeCandidate> candidates = new ArrayList<>(candidatesMap.values());
if (candidates.size() > 1) { if (candidates.size() > 1) {
IncludeCandidate candidate = fAmbiguityResolver.selectElement(candidates); IncludeCandidate candidate = fAmbiguityResolver.selectElement(candidates);
if (candidate == null) if (candidate == null)
@ -245,7 +245,7 @@ public class IncludeCreator {
IASTPreprocessorIncludeStatement[] existingIncludes = ast.getIncludeDirectives(); IASTPreprocessorIncludeStatement[] existingIncludes = ast.getIncludeDirectives();
fContext.addHeadersIncludedPreviously(existingIncludes); fContext.addHeadersIncludedPreviously(existingIncludes);
List<StyledInclude> styledIncludes = new ArrayList<StyledInclude>(); List<StyledInclude> styledIncludes = new ArrayList<>();
// Put the new includes into styledIncludes. // Put the new includes into styledIncludes.
for (IncludeInfo includeInfo : includes) { for (IncludeInfo includeInfo : includes) {
IPath header = fContext.resolveInclude(includeInfo); IPath header = fContext.resolveInclude(includeInfo);
@ -258,7 +258,7 @@ public class IncludeCreator {
Collections.sort(styledIncludes, preferences); Collections.sort(styledIncludes, preferences);
// Populate list of existing includes in the include insertion region. // Populate list of existing includes in the include insertion region.
List<StyledInclude> mergedIncludes = new ArrayList<StyledInclude>(); List<StyledInclude> mergedIncludes = new ArrayList<>();
for (IASTPreprocessorIncludeStatement include : existingIncludes) { for (IASTPreprocessorIncludeStatement include : existingIncludes) {
if (include.isPartOfTranslationUnitFile() && isContainedInRegion(include, includeRegion)) { if (include.isPartOfTranslationUnitFile() && isContainedInRegion(include, includeRegion)) {
String name = new String(include.getName().getSimpleID()); String name = new String(include.getName().getSimpleID());
@ -333,7 +333,7 @@ public class IncludeCreator {
if (usingDeclaration.existingDeclaration.isPartOfTranslationUnitFile() && if (usingDeclaration.existingDeclaration.isPartOfTranslationUnitFile() &&
ASTNodes.endOffset(usingDeclaration.existingDeclaration) <= selection.getOffset()) { ASTNodes.endOffset(usingDeclaration.existingDeclaration) <= selection.getOffset()) {
if (temp == null) if (temp == null)
temp = new ArrayList<UsingDeclaration>(); temp = new ArrayList<>();
temp.add(usingDeclaration); temp.add(usingDeclaration);
} }
} }
@ -386,7 +386,7 @@ public class IncludeCreator {
} }
private List<UsingDeclaration> getUsingDeclarations(IASTTranslationUnit ast) { private List<UsingDeclaration> getUsingDeclarations(IASTTranslationUnit ast) {
List<UsingDeclaration> usingDeclarations = new ArrayList<UsingDeclaration>(); List<UsingDeclaration> usingDeclarations = new ArrayList<>();
IASTDeclaration[] declarations = ast.getDeclarations(); IASTDeclaration[] declarations = ast.getDeclarations();
for (IASTDeclaration declaration : declarations) { for (IASTDeclaration declaration : declarations) {
if (declaration instanceof ICPPASTUsingDeclaration) { if (declaration instanceof ICPPASTUsingDeclaration) {
@ -508,7 +508,7 @@ public class IncludeCreator {
* For ns1::ns2::Name, e.g., it returns [Name, ns2, ns1]. * For ns1::ns2::Name, e.g., it returns [Name, ns2, ns1].
*/ */
private ArrayList<String> getUsingChain(IBinding binding) { private ArrayList<String> getUsingChain(IBinding binding) {
ArrayList<String> chain = new ArrayList<String>(4); ArrayList<String> chain = new ArrayList<>(4);
for (; binding != null; binding = binding.getOwner()) { for (; binding != null; binding = binding.getOwner()) {
String name = binding.getName(); String name = binding.getName();
if (binding instanceof ICPPNamespace) { if (binding instanceof ICPPNamespace) {
@ -534,9 +534,9 @@ public class IncludeCreator {
if (isWorkspaceFile(headerFile.getLocation().getURI())) { if (isWorkspaceFile(headerFile.getLocation().getURI())) {
return headerFile; return headerFile;
} }
ArrayDeque<IIndexFile> front = new ArrayDeque<IIndexFile>(); ArrayDeque<IIndexFile> front = new ArrayDeque<>();
front.add(headerFile); front.add(headerFile);
HashSet<IIndexFile> processed = new HashSet<IIndexFile>(); HashSet<IIndexFile> processed = new HashSet<>();
processed.add(headerFile); processed.add(headerFile);
while (!front.isEmpty()) { while (!front.isEmpty()) {
IIndexFile file = front.remove(); IIndexFile file = front.remove();
@ -680,6 +680,7 @@ public class IncludeCreator {
/** /**
* Returns the fully qualified name for a given index binding. * Returns the fully qualified name for a given index binding.
*
* @param binding * @param binding
* @return binding's fully qualified name * @return binding's fully qualified name
* @throws CoreException * @throws CoreException