1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-10 02:25:25 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2013-07-28 13:54:50 -07:00
parent 83c26578b8
commit 4545b4c873
6 changed files with 45 additions and 28 deletions

View file

@ -167,7 +167,7 @@ public abstract class ASTNode implements IASTNode {
if (floc != null && ast != null) {
ILocationResolver lr= (ILocationResolver) ast.getAdapter(ILocationResolver.class);
if (lr != null) {
return lr.getUnpreprocessedSignature(getFileLocation());
return lr.getUnpreprocessedSignature(floc);
}
}
return CharArrayUtils.EMPTY;

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
@ -31,7 +31,9 @@ import org.eclipse.cdt.internal.core.dom.Linkage;
class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
private final char[] fName;
private final IBinding fBinding;
public ASTPreprocessorName(IASTNode parent, ASTNodeProperty property, int startNumber, int endNumber, char[] name, IBinding binding) {
public ASTPreprocessorName(IASTNode parent, ASTNodeProperty property, int startNumber,
int endNumber, char[] name, IBinding binding) {
super(parent, property, startNumber, endNumber);
fName= name;
fBinding= binding;
@ -41,31 +43,38 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
public IBinding resolveBinding() {
return fBinding;
}
@Override
public IBinding resolvePreBinding() {
return fBinding;
}
@Override
public IBinding getBinding() {
return fBinding;
}
@Override
public IBinding getPreBinding() {
return fBinding;
}
@Override
public ILinkage getLinkage() {
final IASTTranslationUnit tu= getTranslationUnit();
return tu == null ? Linkage.NO_LINKAGE : tu.getLinkage();
}
@Override
public IASTCompletionContext getCompletionContext() {
return null;
}
@Override
public boolean isDeclaration() {
return false;
}
@Override
public boolean isDefinition() {
return false;
@ -74,14 +83,17 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
public boolean isReference() {
return false;
}
@Override
public char[] toCharArray() {
return fName;
}
}
@Override
public char[] getSimpleID() {
return fName;
}
@Override
public char[] getLookupKey() {
return fName;
@ -91,6 +103,7 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
public String toString() {
return new String(fName);
}
@Override
public void setBinding(IBinding binding) {assert false;}
@ -98,14 +111,17 @@ class ASTPreprocessorName extends ASTPreprocessorNode implements IASTName {
public int getRoleOfName(boolean allowResolution) {
return IASTNameOwner.r_unclear;
}
@Override
public IASTName getLastName() {
return this;
}
@Override
public boolean isQualified() {
return false;
}
@Override
public IASTName copy() {
throw new UnsupportedOperationException();
@ -134,18 +150,18 @@ class ASTPreprocessorDefinition extends ASTPreprocessorName {
}
}
class ASTBuiltinName extends ASTPreprocessorDefinition {
private final IASTFileLocation fFileLocation;
public ASTBuiltinName(IASTNode parent, ASTNodeProperty property, IASTFileLocation floc, char[] name, IBinding binding) {
public ASTBuiltinName(IASTNode parent, ASTNodeProperty property, IASTFileLocation floc,
char[] name, IBinding binding) {
super(parent, property, -1, -1, name, binding);
fFileLocation= floc;
}
@Override
public boolean contains(IASTNode node) {
return node==this;
return node == this;
}
@Override
@ -181,7 +197,8 @@ class ASTBuiltinName extends ASTPreprocessorDefinition {
class ASTMacroReferenceName extends ASTPreprocessorName {
private ImageLocationInfo fImageLocationInfo;
public ASTMacroReferenceName(IASTNode parent, ASTNodeProperty property, int offset, int endOffset, IMacroBinding macro, ImageLocationInfo imgLocationInfo) {
public ASTMacroReferenceName(IASTNode parent, ASTNodeProperty property,
int offset, int endOffset, IMacroBinding macro, ImageLocationInfo imgLocationInfo) {
super(parent, property, offset, endOffset, macro.getNameCharArray(), macro);
fImageLocationInfo= imgLocationInfo;
}

View file

@ -509,7 +509,6 @@ class ASTMacroDefinition extends ASTPreprocessorNode implements IASTPreprocessor
fExpansionOffset= expansionOffset;
}
@Override
public String getContainingFilename() {
if (fName instanceof ASTBuiltinName) {
@ -534,7 +533,7 @@ class ASTMacroDefinition extends ASTPreprocessorNode implements IASTPreprocessor
@Override
public int getRoleForName(IASTName n) {
return (fName == n) ? r_definition : r_unclear;
return fName == n ? r_definition : r_unclear;
}
@Override
@ -545,6 +544,7 @@ class ASTMacroDefinition extends ASTPreprocessorNode implements IASTPreprocessor
@Override
public void setExpansion(String exp) {assert false;}
@Override
public void setName(IASTName name) {assert false;}

View file

@ -1928,10 +1928,10 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
return false;
}
}
final boolean contentAssist = fContentAssistLimit>=0 && fCurrentContext == fRootContext;
final boolean contentAssist = fContentAssistLimit >= 0 && fCurrentContext == fRootContext;
final ITokenSequence input= stopAtNewline ? fLineInputToMacroExpansion : fInputToMacroExpansion;
final MacroExpander expander = withinExpansion ? new MacroExpander(this, fMacroDictionary,
fLocationMap, fLexOptions) : fMacroExpander;
final MacroExpander expander = withinExpansion ?
new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions) : fMacroExpander;
TokenList replacement= expander.expand(input, options, macro, identifier, contentAssist, fCurrentContext);
final IASTName[] expansions= expander.clearImplicitExpansions();
final ImageLocationInfo[] ili= expander.clearImageLocationInfos();

View file

@ -57,12 +57,12 @@ public class LocationMap implements ILocationResolver {
private ArrayList<ASTMacroDefinition> fBuiltinMacros= new ArrayList<ASTMacroDefinition>();
private ArrayList<ASTPreprocessorName> fMacroReferences= new ArrayList<ASTPreprocessorName>();
private LocationCtxFile fRootContext= null;
private LocationCtx fCurrentContext= null;
private LocationCtxFile fRootContext;
private LocationCtx fCurrentContext;
private int fLastChildInsertionOffset;
// stuff computed on demand
private IdentityHashMap<IBinding, IASTPreprocessorMacroDefinition> fMacroDefinitionMap= null;
private IdentityHashMap<IBinding, IASTPreprocessorMacroDefinition> fMacroDefinitionMap;
private List<ISkippedIndexedFilesListener> fSkippedFilesListeners= new ArrayList<ISkippedIndexedFilesListener>();
public LocationMap(LexerOptions lexOptions) {

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner;
@ -49,6 +49,7 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
fOffset= offset;
fLength= length;
}
@Override
public int getNodeOffset() { return fOffset; }
@Override
@ -87,7 +88,7 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
fMacroLocations= getMacroLocations(resolver);
fFilePath= tu.getFilePath();
fSource= resolver.getUnpreprocessedSignature(loc);
fBoundaries= new int[count*2+1];
fBoundaries= new int[count * 2 + 1];
fDelegates= new SingleMacroExpansionExplorer[count];
final int firstOffset= loc.getNodeOffset();
@ -102,12 +103,12 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
IASTFileLocation refLoc= expansion.getFileLocation();
int from= refLoc.getNodeOffset()-firstOffset;
int to= from+refLoc.getNodeLength();
IASTNode enclosing= nodeLocator.findEnclosingNode(from+firstOffset-1, 2);
IASTNode enclosing= nodeLocator.findEnclosingNode(from + firstOffset - 1, 2);
boolean isPPCond= enclosing instanceof IASTPreprocessorIfStatement ||
enclosing instanceof IASTPreprocessorElifStatement;
fBoundaries[++bidx]= from;
fBoundaries[++bidx]= to;
fDelegates[++didx]= new SingleMacroExpansionExplorer(new String(fSource, from, to-from),
fDelegates[++didx]= new SingleMacroExpansionExplorer(new String(fSource, from, to - from),
refs.toArray(new IASTName[refs.size()]), fMacroLocations,
fFilePath, refLoc.getStartingLineNumber(), isPPCond,
(LexerOptions) tu.getAdapter(LexerOptions.class));
@ -182,7 +183,7 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
*/
private List<ReplaceEdit> combineReplaceEdits(int count) {
ArrayList<ReplaceEdit> edits= new ArrayList<ReplaceEdit>();
for (int i=0; i < count; i++) {
for (int i= 0; i < count; i++) {
IMacroExpansionStep step= fDelegates[i].getFullExpansion();
shiftAndAddEdits(fBoundaries[2*i], step.getReplacements(), edits);
}
@ -200,11 +201,10 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
}
}
@Override
public int getExpansionStepCount() {
int result= 0;
for (int i=0; i < fDelegates.length; i++) {
for (int i= 0; i < fDelegates.length; i++) {
result+= fDelegates[i].getExpansionStepCount();
}
return result;
@ -223,7 +223,7 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
StringBuilder before= new StringBuilder();
before.append(fSource, 0, fBoundaries[0]);
for (i=0; i < fDelegates.length; i++) {
for (i= 0; i < fDelegates.length; i++) {
final SingleMacroExpansionExplorer delegate = fDelegates[i];
int dsteps= delegate.getExpansionStepCount();
if (step < dsteps) {
@ -239,9 +239,9 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
}
final int shift= before.length();
final int end= fBoundaries[2*i+1];
final int end= fBoundaries[2 * i + 1];
before.append(dresult.getCodeBeforeStep());
before.append(fSource, end, fSource.length-end);
before.append(fSource, end, fSource.length - end);
List<ReplaceEdit> replacements= new ArrayList<ReplaceEdit>();
shiftAndAddEdits(shift, dresult.getReplacements(), replacements);
@ -251,9 +251,9 @@ public class MultiMacroExpansionExplorer extends MacroExpansionExplorer {
}
private void appendGap(StringBuilder result, int i) {
int idx= 2*i+1;
int idx= 2 * i + 1;
int gapFrom= fBoundaries[idx];
int gapTo= fBoundaries[++idx];
result.append(fSource, gapFrom, gapTo-gapFrom);
result.append(fSource, gapFrom, gapTo - gapFrom);
}
}