From 433f9bbc58b73cce503b22c4dc414ddc230d171b Mon Sep 17 00:00:00 2001 From: khartlage Date: Thu, 11 Sep 2003 15:59:56 +0000 Subject: [PATCH 1/1] Improved the phpdoc output --- .../corext/phpdoc/PHPDocBufferCommentReader.java | 84 ++++++++++++++++++++ .../phpdoc/PHPDocCharArrayCommentReader.java | 84 ++++++++++++++++++++ .../corext/phpdoc/PHPDocCommentReader.java | 84 -------------------- .../phpeclipse/mover/obfuscator/PHPIdentifier.java | 10 +- .../phpeclipse/phpeditor/PHPTextHover.java | 25 +++--- 5 files changed, 186 insertions(+), 101 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocBufferCommentReader.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCharArrayCommentReader.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCommentReader.java diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocBufferCommentReader.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocBufferCommentReader.java new file mode 100644 index 0000000..845ff0d --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocBufferCommentReader.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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 net.sourceforge.phpdt.internal.corext.phpdoc; + +import net.sourceforge.phpdt.core.IBuffer; +import net.sourceforge.phpdt.internal.corext.util.Strings; + + +/** + * Reads a phpdoc comment from a phpdoc comment. Skips star-character + * on begin of line + */ +public class PHPDocBufferCommentReader extends SingleCharReader { + + private IBuffer fBuffer; + + private int fCurrPos; + private int fStartPos; + private int fEndPos; + + private boolean fWasNewLine; + + public PHPDocBufferCommentReader(IBuffer buf, int start, int end) { + fBuffer= buf; + fStartPos= start + 3; + fEndPos= end - 2; + + reset(); + } + + /** + * @see java.io.Reader#read() + */ + public int read() { + if (fCurrPos < fEndPos) { + char ch; + if (fWasNewLine) { + do { + ch= fBuffer.getChar(fCurrPos++); + } while (fCurrPos < fEndPos && Character.isWhitespace(ch)); + if (ch == '*') { + if (fCurrPos < fEndPos) { + do { + ch= fBuffer.getChar(fCurrPos++); + } while (ch == '*'); + } else { + return -1; + } + } + } else { + ch= fBuffer.getChar(fCurrPos++); + } + fWasNewLine= Strings.isLineDelimiterChar(ch); + + return ch; + } + return -1; + } + + /** + * @see java.io.Reader#close() + */ + public void close() { + fBuffer= null; + } + + /** + * @see java.io.Reader#reset() + */ + public void reset() { + fCurrPos= fStartPos; + fWasNewLine= true; + } + + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCharArrayCommentReader.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCharArrayCommentReader.java new file mode 100644 index 0000000..4816997 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCharArrayCommentReader.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * 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 net.sourceforge.phpdt.internal.corext.phpdoc; + +import net.sourceforge.phpdt.internal.corext.util.Strings; + +/** + * Reads a phpdoc comment from a phpdoc comment. Skips star-character + * on begin of line + */ +public class PHPDocCharArrayCommentReader extends SingleCharReader { + + private char[] fCharArray; + private int fCurrPos; + private int fStartPos; + private int fEndPos; + + private boolean fWasNewLine; + + public PHPDocCharArrayCommentReader(char[] buf) { + this(buf, 0, buf.length); + } + + public PHPDocCharArrayCommentReader(char[] buf, int start, int end) { + fCharArray = buf; + fStartPos= start + 3; + fEndPos= end - 2; + + reset(); + } + + /** + * @see java.io.Reader#read() + */ + public int read() { + if (fCurrPos < fEndPos) { + char ch; + if (fWasNewLine) { + do { + ch = fCharArray[fCurrPos++]; + } while (fCurrPos < fEndPos && Character.isWhitespace(ch)); + if (ch == '*') { + if (fCurrPos < fEndPos) { + do { + ch = fCharArray[fCurrPos++]; + } while (ch == '*'); + } else { + return -1; + } + } + } else { + ch = fCharArray[fCurrPos++]; + } + fWasNewLine = Strings.isLineDelimiterChar(ch); + + return ch; + } + return -1; + } + + /** + * @see java.io.Reader#close() + */ + public void close() { + fCharArray = null; + } + + /** + * @see java.io.Reader#reset() + */ + public void reset() { + fCurrPos = fStartPos; + fWasNewLine = true; + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCommentReader.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCommentReader.java deleted file mode 100644 index 7b1f275..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/phpdoc/PHPDocCommentReader.java +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * 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 net.sourceforge.phpdt.internal.corext.phpdoc; - -import net.sourceforge.phpdt.core.IBuffer; -import net.sourceforge.phpdt.internal.corext.util.Strings; - - -/** - * Reads a java doc comment from a java doc comment. Skips star-character - * on begin of line - */ -public class PHPDocCommentReader extends SingleCharReader { - - private IBuffer fBuffer; - - private int fCurrPos; - private int fStartPos; - private int fEndPos; - - private boolean fWasNewLine; - - public PHPDocCommentReader(IBuffer buf, int start, int end) { - fBuffer= buf; - fStartPos= start + 3; - fEndPos= end - 2; - - reset(); - } - - /** - * @see java.io.Reader#read() - */ - public int read() { - if (fCurrPos < fEndPos) { - char ch; - if (fWasNewLine) { - do { - ch= fBuffer.getChar(fCurrPos++); - } while (fCurrPos < fEndPos && Character.isWhitespace(ch)); - if (ch == '*') { - if (fCurrPos < fEndPos) { - do { - ch= fBuffer.getChar(fCurrPos++); - } while (ch == '*'); - } else { - return -1; - } - } - } else { - ch= fBuffer.getChar(fCurrPos++); - } - fWasNewLine= Strings.isLineDelimiterChar(ch); - - return ch; - } - return -1; - } - - /** - * @see java.io.Reader#close() - */ - public void close() { - fBuffer= null; - } - - /** - * @see java.io.Reader#reset() - */ - public void reset() { - fCurrPos= fStartPos; - fWasNewLine= true; - } - - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/mover/obfuscator/PHPIdentifier.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/mover/obfuscator/PHPIdentifier.java index 05820af..74098e8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/mover/obfuscator/PHPIdentifier.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/mover/obfuscator/PHPIdentifier.java @@ -72,15 +72,15 @@ public class PHPIdentifier { public String toString() { switch (fType) { case CLASS : - return "class "; + return "class - "; case DEFINE : - return "define "; + return "define - "; case FUNCTION : - return "function "; + return "function - "; case METHOD : - return "method "; + return "method - "; case VARIABLE : - return "variable "; + return "variable - "; } return ""; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java index 308f746..c947cf6 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java @@ -12,11 +12,11 @@ Contributors: package net.sourceforge.phpeclipse.phpeditor; import java.io.FileReader; -import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Vector; +import net.sourceforge.phpdt.internal.corext.phpdoc.PHPDocCharArrayCommentReader; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.builder.IdentifierIndexManager; import net.sourceforge.phpeclipse.builder.PHPIdentifierLocation; @@ -80,28 +80,29 @@ public class PHPTextHover implements ITextHover { PHPIdentifierLocation location; String filename; FileReader phpdocFileReader; + PHPDocCharArrayCommentReader phpdocConverter; StringBuffer hoverInfoBuffer = new StringBuffer(); String workspaceLocation = PHPeclipsePlugin.getWorkspace().getRoot().getLocation().toString(); - boolean foundPHPdoc = false; + // boolean foundPHPdoc = false; for (int i = 0; i < list.size(); i++) { - location = (PHPIdentifierLocation) list.get(0); + location = (PHPIdentifierLocation) list.get(i); + filename = workspaceLocation + location.getFilename(); + hoverInfoBuffer.append(location.toString()); + hoverInfoBuffer.append('\n'); if (location.getPHPDocOffset() >= 0) { - foundPHPdoc = true; - filename = workspaceLocation + location.getFilename(); + // foundPHPdoc = true; phpdocFileReader = new FileReader(filename); - hoverInfoBuffer.append("PHPdoc found in file: "); - hoverInfoBuffer.append(filename); - hoverInfoBuffer.append('\n'); char[] charArray = new char[location.getPHPDocLength()]; phpdocFileReader.skip(location.getPHPDocOffset()); phpdocFileReader.read(charArray, 0, location.getPHPDocLength()); - hoverInfoBuffer.append(charArray); + phpdocConverter = new PHPDocCharArrayCommentReader(charArray); + hoverInfoBuffer.append(phpdocConverter.getString()); hoverInfoBuffer.append('\n'); } } - if (foundPHPdoc) { - hoverInfo = hoverInfoBuffer.toString(); - } + // if (foundPHPdoc) { + hoverInfo = hoverInfoBuffer.toString(); + // } } catch (Throwable e) { // ignore exceptions // e.printStackTrace(); -- 1.7.1