1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Code cleanup

This commit is contained in:
Anton Leherbauer 2008-04-15 12:06:04 +00:00
parent 54eba1ba20
commit b7ca58a629
2 changed files with 26 additions and 62 deletions

View file

@ -1071,6 +1071,7 @@ public final class CIndenter {
case Symbols.TokenCASE:
return true;
}
break;
case Symbols.TokenDEFAULT:
return true;
}
@ -1205,6 +1206,7 @@ public final class CIndenter {
case Symbols.TokenRPAREN:
if (isInBlock)
mayBeMethodBody= READ_PARENS;
// fall thru
case Symbols.TokenRBRACKET:
case Symbols.TokenGREATERTHAN:
pos= fPreviousPos;
@ -1281,6 +1283,7 @@ public final class CIndenter {
if (previous == Symbols.TokenIDENT) {
return false;
}
// fall thru
case Symbols.TokenDOUBLECOLON:
case Symbols.TokenOTHER:
continue;
@ -1491,6 +1494,7 @@ public final class CIndenter {
case Symbols.TokenIDENT:
if (!isGenericStarter(getTokenContent()))
break;
// fall thru
case Symbols.TokenQUESTIONMARK:
case Symbols.TokenGREATERTHAN:
if (skipScope(Symbols.TokenLESSTHAN, Symbols.TokenGREATERTHAN))

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others.
* Copyright (c) 2005, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -26,20 +26,16 @@ import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.IWorkingCopyManager;
import org.eclipse.cdt.internal.core.model.CModelManager;
public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
private ITextEditor fEditor;
private IWorkingCopyManager fManager;
private IProgressMonitor fProgressMonitor;
private String txt = null;
// used by tests
protected boolean fInitialProcessDone;
@ -54,6 +50,13 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
public void setDocument(IDocument document) {
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
*/
public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
// only called for incremental reconciler
}
/*
* @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
*/
@ -68,50 +71,6 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
reconcile(false);
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
* Called for incremental reconciler only - currently not used (no shift deltas)
*/
public void reconcile(DirtyRegion dirtyRegion, IRegion region) {
// consistent data needs not further checks !
ITranslationUnit tu = fManager.getWorkingCopy(fEditor.getEditorInput());
if (tu != null && tu.isWorkingCopy()) {
try {
if (tu.isConsistent()) return;
} catch (CModelException e) {}
}
// bug 113518
// local data needs not to be re-parsed
boolean needReconcile = true;
int dOff = dirtyRegion.getOffset();
int dLen = dirtyRegion.getLength();
IDocument doc = fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
if ((doc != null) && (!CWordFinder.isGlobal(doc, dOff))) {
String s = ""; //$NON-NLS-1$
if (dirtyRegion.getType().charAt(2) == 'i') { // insert operation
s = dirtyRegion.getText();
if (!CWordFinder.hasCBraces(s)) {
CModelManager.getDefault().fireShift(tu, dOff, dLen, CWordFinder.countLFs(s));
needReconcile = false;
}
} else { // remove operation
// check whether old document copy is relevant
if (txt != null && (txt.length() == doc.getLength() + dLen)) {
s = txt.substring(dOff, dOff + dLen);
if (!CWordFinder.hasCBraces(s)) {
CModelManager.getDefault().fireShift(tu, dOff, -dLen, -CWordFinder.countLFs(s));
needReconcile = false;
}
}
}
}
if (needReconcile) reconcile(false);
txt = doc.get(); // save doc copy for further use
}
private void reconcile(final boolean initialReconcile) {
boolean computeAST= fEditor instanceof ICReconcilingListener;
IASTTranslationUnit ast= null;
@ -173,4 +132,5 @@ public class CReconcilingStrategy implements IReconcilingStrategy, IReconcilingS
((ICReconcilingListener)fEditor).aboutToBeReconciled();
}
}
}