diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index 7b67ece7168..57fc90eb90c 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,17 @@ +2003-09-30 Bogdan Gheorghe + + - Created CDTLogWriter class + - Added CDTLogWriter startup/shutdown to CCorePlugin + - Changed Util class to make use of ICLogConstants to distinguish + between PDE and CDT logs. + - Modified the Buffer class to log errors to the CDT log + + * src/org/eclipse/cdt/core/CCorePlugin.java + * src/org/eclipse/cdt/core/ICLogConstants.java + * src/org/eclipse/cdt/internal/core/CDTLogWriter.java + * model/org/eclipse/cdt/internal/core/model/Util.java + * model/org/eclipse/cdt/internal/core/model/Buffer.java + 2003-09-25 Bogdan Gheorghe - Got rid of refs to old dependency service; restructured diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index af4719a1942..9f27bd3ea67 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -1,3 +1,6 @@ +2003-09-30 Bogdan Gheorghe + Changed logging for SourceIndexer to log file in cdt.core + 2003-09-25 Bogdan Gheorghe Integrated the dependency service into the indexer. Changes as follows: diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java index d0a96e06c1d..6d8e8c36986 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java @@ -19,6 +19,7 @@ import java.io.IOException; import java.io.StringReader; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.parser.IParser; import org.eclipse.cdt.core.parser.IScannerInfo; @@ -89,7 +90,7 @@ public class SourceIndexer extends AbstractIndexer { boolean retVal = parser.parse(); if (!retVal) - org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath()); + org.eclipse.cdt.internal.core.model.Util.log(null, "Failed to index " + resourceFile.getFullPath(), ICLogConstants.CDT); if (AbstractIndexer.VERBOSE){ if (!retVal) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java index 1c130746acc..2b3211ab963 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Buffer.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.model; import java.io.ByteArrayInputStream; import java.util.ArrayList; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.model.*; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IOpenable; @@ -224,7 +225,7 @@ public class Buffer implements IBuffer { final IBufferChangedListener listener = (IBufferChangedListener) this.changeListeners.get(i); Platform.run(new ISafeRunnable() { public void handleException(Throwable exception) { - Util.log(exception, "Exception occurred in listener of buffer change notification"); //$NON-NLS-1$ + Util.log(exception, "Exception occurred in listener of buffer change notification", ICLogConstants.CDT); //$NON-NLS-1$ } public void run() throws Exception { listener.bufferChanged(event); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java index 7d139d61b37..85385340517 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Util.java @@ -13,6 +13,7 @@ import java.io.InputStreamReader; import java.text.MessageFormat; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICModelStatusConstants; import org.eclipse.cdt.internal.core.model.IDebugLogConstants.DebugLogConstant; @@ -21,7 +22,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -public class Util { +public class Util implements ICLogConstants { public static boolean VERBOSE_PARSER = false; public static boolean VERBOSE_MODEL = false; @@ -151,33 +152,38 @@ public class Util { } } } - /* * Add a log entry */ - public static void log(Throwable e, String message) { + public static void log(Throwable e, String message, LogConst logType) { IStatus status= new Status( IStatus.ERROR, CCorePlugin.getDefault().getDescriptor().getUniqueIdentifier(), IStatus.ERROR, message, e); - Util.log(status); + Util.log(status, logType); } - public static void log(IStatus status){ - CCorePlugin.getDefault().getLog().log(status); + public static void log(IStatus status, LogConst logType){ + if (logType.equals(ICLogConstants.PDE)){ + CCorePlugin.getDefault().getLog().log(status); + } + else if (logType.equals(ICLogConstants.CDT)){ + CCorePlugin.getDefault().cdtLog.log(status); + } } - public static void log(String message){ + public static void log(String message, LogConst logType){ IStatus status = new Status(IStatus.INFO, CCorePlugin.getDefault().getDescriptor().getUniqueIdentifier(), IStatus.INFO, message, null); - Util.log(status); + Util.log(status, logType); } + public static void debugLog(String message, DebugLogConstant client) { if( CCorePlugin.getDefault() == null ) return; if ( CCorePlugin.getDefault().isDebugging() && isActive(client)) { diff --git a/core/org.eclipse.cdt.core/parser/ChangeLog b/core/org.eclipse.cdt.core/parser/ChangeLog index 6a9b7e42108..a0d7ddd52c2 100644 --- a/core/org.eclipse.cdt.core/parser/ChangeLog +++ b/core/org.eclipse.cdt.core/parser/ChangeLog @@ -1,3 +1,5 @@ +2003-09-30 Bogdan Gheorghe + Added CDT log dump in Parser.fetchToken to catch HandleInclusion failures 2003-09-30 John Camelon Fixed Bug 43503 : Search:f_SD_01 cannot be found in ManyClasses20 Project Fixed Bug 43680 : Fix Parser Error Handling diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java index 7f792e2b717..7fc457c4398 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Parser.java @@ -14,6 +14,7 @@ import java.util.Iterator; import java.util.List; import java.util.Stack; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.parser.Backtrack; import org.eclipse.cdt.core.parser.EndOfFile; import org.eclipse.cdt.core.parser.IParser; @@ -4987,6 +4988,7 @@ public class Parser implements IParser catch (ScannerException e) { Util.debugLog( "ScannerException thrown : " + e.getMessage(), IDebugLogConstants.PARSER ); + org.eclipse.cdt.internal.core.model.Util.log(e, "Scanner Exception", ICLogConstants.CDT); //$NON-NLS-1$h if( e.isSeriousError(mode) ) { failParse(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java index 69a3c74aeec..3a8ef6f0f44 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Preprocessor.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.internal.core.parser; import java.io.Reader; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.core.parser.EndOfFile; import org.eclipse.cdt.core.parser.IPreprocessor; import org.eclipse.cdt.core.parser.IProblemReporter; @@ -48,7 +49,7 @@ public class Preprocessor extends Scanner implements IPreprocessor { catch( ScannerException se ) { // callback IProblem here - org.eclipse.cdt.internal.core.model.Util.log(se, "Preprocessor Exception"); //$NON-NLS-1$h + org.eclipse.cdt.internal.core.model.Util.log(se, "Preprocessor Exception", ICLogConstants.CDT); //$NON-NLS-1$h } catch( EndOfFile eof ) diff --git a/core/org.eclipse.cdt.core/search/ChangeLog b/core/org.eclipse.cdt.core/search/ChangeLog index 385cad28028..d1543463bf9 100644 --- a/core/org.eclipse.cdt.core/search/ChangeLog +++ b/core/org.eclipse.cdt.core/search/ChangeLog @@ -1,3 +1,6 @@ +2003-09-30 Bogdan Gheorghe + - changed logging in JobManager to use new ICLogConstants + 2003-09-30 Andrew Niefer -fix bug43862 - Cannot find macro delcarations using all occurences. * modified CSearchPattern.createMacroPattern diff --git a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java index 97dd2018c4a..7f738ba13e6 100644 --- a/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java +++ b/core/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/processing/JobManager.java @@ -13,6 +13,7 @@ */ package org.eclipse.cdt.internal.core.search.processing; +import org.eclipse.cdt.core.ICLogConstants; import org.eclipse.cdt.internal.core.Util; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; @@ -382,7 +383,7 @@ public abstract class JobManager implements Runnable { } catch (RuntimeException e) { if (this.thread != null) { // if not shutting down // log exception - org.eclipse.cdt.internal.core.model.Util.log(e, "Background Indexer Crash Recovery"); //$NON-NLS-1$ + org.eclipse.cdt.internal.core.model.Util.log(e, "Background Indexer Crash Recovery", ICLogConstants.PDE); //$NON-NLS-1$ // keep job manager alive this.discardJobs(null); @@ -393,7 +394,7 @@ public abstract class JobManager implements Runnable { } catch (Error e) { if (this.thread != null && !(e instanceof ThreadDeath)) { // log exception - org.eclipse.cdt.internal.core.model.Util.log(e, "Background Indexer Crash Recovery"); //$NON-NLS-1$ + org.eclipse.cdt.internal.core.model.Util.log(e, "Background Indexer Crash Recovery", ICLogConstants.PDE); //$NON-NLS-1$ // keep job manager alive this.discardJobs(null); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index a2d6f20f0ed..e0d238f59ca 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.parser.IScannerInfoProvider; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.search.SearchEngine; +import org.eclipse.cdt.internal.core.CDTLogWriter; import org.eclipse.cdt.internal.core.CDescriptorManager; import org.eclipse.cdt.internal.core.CPathEntry; import org.eclipse.cdt.internal.core.model.BufferManager; @@ -113,7 +114,7 @@ public class CCorePlugin extends Plugin { * @see #getDefaultOptions */ public static final String CORE_ENCODING = PLUGIN_ID + ".encoding"; //$NON-NLS-1$ - + public CDTLogWriter cdtLog = null; private static CCorePlugin fgCPlugin; private static ResourceBundle fgResourceBundle; @@ -211,6 +212,10 @@ public class CCorePlugin extends Plugin { if (fCoreModel != null) { fCoreModel.shutdown(); } + + if (cdtLog != null) { + cdtLog.shutdown(); + } } /** @@ -218,7 +223,9 @@ public class CCorePlugin extends Plugin { */ public void startup() throws CoreException { super.startup(); - + + cdtLog = new CDTLogWriter(CCorePlugin.getDefault().getStateLocation().append(".log").toFile()); + //Set debug tracing options CCorePlugin.getDefault().configurePluginDebugOptions(); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICLogConstants.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICLogConstants.java new file mode 100644 index 00000000000..b5faaf4091e --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICLogConstants.java @@ -0,0 +1,31 @@ +/********************************************************************** + * Copyright (c) 2002,2003 Rational Software Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation +***********************************************************************/ + +package org.eclipse.cdt.core; + +/** + * @author bgheorgh + */ +public interface ICLogConstants { + public class LogConst{ + private LogConst( int value ) + { + this.value = value; + } + private final int value; + } + + + public static final LogConst PDE = new LogConst( 1 ); + + public static final LogConst CDT = new LogConst( 2 ); + +} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDTLogWriter.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDTLogWriter.java new file mode 100644 index 00000000000..c4d1466060b --- /dev/null +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CDTLogWriter.java @@ -0,0 +1,209 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; + + +public class CDTLogWriter { + protected File logFile = null; + protected Writer log = null; + protected boolean newSession = true; + + protected static final String SESSION = "*** SESSION";//$NON-NLS-1$ + protected static final String ENTRY = "*** ENTRY";//$NON-NLS-1$ + protected static final String SUBENTRY = "*** SUBENTRY";//$NON-NLS-1$ + protected static final String MESSAGE = "*** MESSAGE";//$NON-NLS-1$ + protected static final String STACK = "*** STACK";//$NON-NLS-1$ + + protected static final String LINE_SEPARATOR; + protected static final String TAB_STRING = "\t";//$NON-NLS-1$ + protected static final long MAXLOG_SIZE = 5000000; + static { + String s = System.getProperty("line.separator");//$NON-NLS-1$ + LINE_SEPARATOR = s == null ? "\n" : s;//$NON-NLS-1$ + } + /** + * + */ + public CDTLogWriter(File log) { + this.logFile = log; + if(log.length() > MAXLOG_SIZE){ + log.delete(); + this.logFile = CCorePlugin.getDefault().getStateLocation().append(".log").toFile(); + } + openLogFile(); + } + + protected void closeLogFile() throws IOException { + try { + if (log != null) { + log.flush(); + log.close(); + } + } finally { + log = null; + } + } + + protected void openLogFile() { + try { + log = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(logFile.getAbsolutePath(), true), "UTF-8"));//$NON-NLS-1$ + if (newSession) { + writeHeader(); + newSession = false; + } + } catch (IOException e) { + // there was a problem opening the log file so log to the console + //log = logForStream(System.err); + } + } + protected void writeHeader() throws IOException { + write(SESSION); + writeSpace(); + String date = getDate(); + write(date); + writeSpace(); + for (int i=SESSION.length()+date.length(); i<78; i++) { + write("-");//$NON-NLS-1$ + } + writeln(); + } + + protected String getDate() { + try { + DateFormat formatter = new SimpleDateFormat("MMM dd, yyyy HH:mm:ss.SS"); //$NON-NLS-1$ + return formatter.format(new Date()); + } catch (Exception e) { + // If there were problems writing out the date, ignore and + // continue since that shouldn't stop us from losing the rest + // of the information + } + return Long.toString(System.currentTimeMillis()); + } + protected Writer logForStream(OutputStream output) { + try { + return new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));//$NON-NLS-1$ + } catch (UnsupportedEncodingException e) { + return new BufferedWriter(new OutputStreamWriter(output)); + } + } + /** + * Writes the given string to the log, followed by the line terminator string. + */ + protected void writeln(String s) throws IOException { + write(s); + writeln(); + } + /** + * Shuts down the log. + */ + public synchronized void shutdown() { + try { + if (logFile != null) { + closeLogFile(); + logFile = null; + } else { + if (log != null) { + Writer old = log; + log = null; + old.flush(); + old.close(); + } + } + } catch (Exception e) { + //we've shutdown the log, so not much else we can do! + e.printStackTrace(); + } + } + + protected void write(Throwable throwable) throws IOException { + if (throwable == null) + return; + write(STACK); + writeSpace(); + boolean isCoreException = throwable instanceof CoreException; + if (isCoreException) + writeln("1");//$NON-NLS-1$ + else + writeln("0");//$NON-NLS-1$ + throwable.printStackTrace(new PrintWriter(log)); + if (isCoreException) { + CoreException e = (CoreException) throwable; + write(e.getStatus(), 0); + } + } + + public synchronized void log(IStatus status){ + try { + this.write(status, 0); + } catch (IOException e) { + } + } + protected void write(IStatus status, int depth) throws IOException { + if (depth == 0) { + write(ENTRY); + } else { + write(SUBENTRY); + writeSpace(); + write(Integer.toString(depth)); + } + writeSpace(); + write(status.getPlugin()); + writeSpace(); + write(Integer.toString(status.getSeverity())); + writeSpace(); + write(Integer.toString(status.getCode())); + writeSpace(); + write(getDate()); + writeln(); + + write(MESSAGE); + writeSpace(); + writeln(status.getMessage()); + + write(status.getException()); + + if (status.isMultiStatus()) { + IStatus[] children = status.getChildren(); + for (int i = 0; i < children.length; i++) { + write(children[i], depth+1); + } + } + } + + protected void writeln() throws IOException { + write(LINE_SEPARATOR); + } + protected void write(String message) throws IOException { + if (message != null) + log.write(message); + } + protected void writeSpace() throws IOException { + write(" ");//$NON-NLS-1$ + } + +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 01323232dd5..90326f53689 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -1,3 +1,7 @@ +2003-09-30 Bogdan Gheorghe + - Added F3 key binding for the Open Declarations Action + - Bug 42047: Added Ctrl+H binding for the C++ Search Dialog + 2003-09-30 Andrew Niefer Bug 43923 - Search: Results pane title missing Working Set's name - implement CSearchUtil.toString( IWorkingSet [] ) diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 7178ffea13b..98bde042e4a 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -51,6 +51,9 @@ ActionDefinition.comment.description= Turn the selected lines into // style comm ActionDefinition.uncomment.name= Uncomment ActionDefinition.uncomment.description= Uncomment the selected // style comment lines +ActionDefinition.opendecl.name= Open Declaration +ActionDefinition.opendecl.description= Open an editor on the selected element's declaration(s) + CEditor.name=C Editor CPluginPreferencePage.name=C/C++ CPluginEditorPreferencePage.name=C/C++ Editor diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 93f8bf1a3b8..0eb7ee5cfc3 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -386,6 +386,18 @@ command="org.eclipse.cdt.ui.edit.text.c.uncomment" configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> + + + + "org.eclipse.cdt.ui.edit.text.java.toggle.presentation"). */ public static final String TOGGLE_PRESENTATION= "org.eclipse.cdt.ui.edit.text.c.toggle.presentation"; //$NON-NLS-1$ + /** + * Action definition ID of the open declaration action + * (value "org.eclipse.cdt.ui.edit.text.java.toggle.presentation"). + */ + public static final String OPEN_DECL= "org.eclipse.cdt.ui.edit.opendecl"; //$NON-NLS-1$ }