From: Martin W. <mar...@us...> - 2005-09-02 15:59:26
|
Update of /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14673/src/org/asdt/core/util Modified Files: TextScanHelper.java StreamUtilities.java ASInternals.java ASKeywords.java JavaDocKeywords.java UTFUtilities.java ExpressionResolver.java ASTypes.java Added Files: IWordList.java WordList.java Log Message: Cleaned up javadoc comments. Refactor word list classes. Standardised spelling of 'classpathes' to classpath. --- NEW FILE: IWordList.java --- /******************************************************************************* * ActionScript Development Toolkit * Copyright (C) 2005 ASDT Team * * http://www.asdt.org http://sourceforge.net/projects/aseclipseplugin/ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307, USA. * ******************************************************************************/ package org.asdt.core.util; /** * Common interface for classes that read and store a list of words * @author Martin Wood */ public interface IWordList { /** * @return an array containing the list of words */ public String[] getWordList(); /** * Load word list from named file * @param fileName */ public void loadWordList(String fileName); /** * @return The number of words in the list */ public int getWordCount(); } Index: JavaDocKeywords.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/JavaDocKeywords.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** JavaDocKeywords.java 8 Jun 2005 16:49:48 -0000 1.3 --- JavaDocKeywords.java 2 Sep 2005 15:59:13 -0000 1.4 *************** *** 33,89 **** /** * @author Nico Zimmermann */ ! public class JavaDocKeywords { ! private List keywords; ! ! private static JavaDocKeywords asKeywords; public JavaDocKeywords() { ! loadKeywords(); } public static JavaDocKeywords getInstance() { ! if (asKeywords == null) { ! asKeywords = new JavaDocKeywords(); ! } ! return asKeywords; ! } ! ! private void loadKeywords() { ! keywords = new ArrayList(); ! BufferedReader reader; ! InputStream is = getClass().getResourceAsStream("javaDocKeywords.txt"); ! if (is != null) { ! reader = new BufferedReader(new InputStreamReader(is)); ! String keyword; ! try { ! while ((keyword = reader.readLine()) != null) { ! keywords.add(keyword); ! } ! } catch (IOException e) { ! e.printStackTrace(); ! } ! } else { ! System.out.println("FileNotFound"); } } - - /** - * getList of keywords - */ - public String[] getKeywords() { - String[] keywordArray = new String[keywords.size()]; - keywords.toArray(keywordArray); - return keywordArray; - } - - /** - * get amout of keywords - */ - public int keywordsCount() { - return keywords.size(); - - } - } \ No newline at end of file --- 33,53 ---- /** + * List of tags used in javadoc comments including html tags. * @author Nico Zimmermann */ ! public class JavaDocKeywords extends WordList{ + private static JavaDocKeywords javaDocKeywords; + private String keywordsFile = "javaDocKeywords.txt"; + public JavaDocKeywords() { ! loadWordList(keywordsFile); } public static JavaDocKeywords getInstance() { ! if (javaDocKeywords == null) { ! javaDocKeywords = new JavaDocKeywords(); } + return javaDocKeywords; } } \ No newline at end of file Index: TextScanHelper.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/TextScanHelper.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TextScanHelper.java 4 Aug 2005 21:29:55 -0000 1.7 --- TextScanHelper.java 2 Sep 2005 15:59:13 -0000 1.8 *************** *** 81,154 **** } - - - /** - * @param document - * the Document where it should be found - * @param region - * the region in which should be searched (the offset must be the - * openbracket) - * @return - */ - public int findMatchingCloseBracket(IDocument document, int offset) - { - - try - { - int bracketCount = 0; - for (int i = offset; i < document.getLength(); i++) - { - // count the open bracket - if (document.getChar(i) == '{') - { - bracketCount++; - } - // close bracket found? - if (document.getChar(i) == '}') - { - bracketCount--; - if (bracketCount == 0) - { - // we got it ! - return i; - } - } - } - - } - catch (BadLocationException e) - { - // TODO catchBlock - //Do nothing. Just return -1 - } - - return -1; - - } - - /** - * finds the block between two brackets - * - * @param document - * @param region - * @return - */ - public IRegion findBock(IDocument document, IRegion region) - { - Region blockRegion = null; - int lastOffset = region.getOffset() + region.getLength(); - int openBracket = findNextOpenBracket(document, region); - if (openBracket != -1) - { - Region openRegion = new Region(openBracket, lastOffset - openBracket); - int closeBracket = findMatchingCloseBracket(document, openRegion.getOffset()); - if (closeBracket != -1) - { - blockRegion = new Region(openBracket, closeBracket - openBracket); - } - } - return blockRegion; - } - public WordRegion[] getWords(IDocument document, IRegion region) { --- 81,84 ---- *************** *** 258,263 **** * @param offset * @param document ! * @return ! * @throws BadLocationException */ public int getWordStart(int offset, IDocument document) --- 188,192 ---- * @param offset * @param document ! * @return position of the start of the word */ public int getWordStart(int offset, IDocument document) *************** *** 334,338 **** * @param offset * @param untilOffset cuts the word at given offset ! * @return * @throws BadLocationException */ --- 263,267 ---- * @param offset * @param untilOffset cuts the word at given offset ! * @return word region at the document offset * @throws BadLocationException */ *************** *** 365,369 **** * @param document * @param offset ! * @return * @throws BadLocationException */ --- 294,298 ---- * @param document * @param offset ! * @return word region containing the full expression at the offset * @throws BadLocationException */ *************** *** 428,432 **** * @param closeBraceOffset the offset of the closeBrace * @param openBrace the Type of the openbrace "(","{","[" ! * @return * @throws BadLocationException */ --- 357,361 ---- * @param closeBraceOffset the offset of the closeBrace * @param openBrace the Type of the openbrace "(","{","[" ! * @return position of open brace to match given closing brace * @throws BadLocationException */ *************** *** 463,467 **** * @param closeBraceOffset the offset of the closeBrace * @param closeBrace the Type of the openbrace "(","{","[" ! * @return * @throws BadLocationException */ --- 392,396 ---- * @param closeBraceOffset the offset of the closeBrace * @param closeBrace the Type of the openbrace "(","{","[" ! * @return position of matching closing brace for the given opening brace * @throws BadLocationException */ Index: UTFUtilities.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/UTFUtilities.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** UTFUtilities.java 31 Jul 2005 01:01:00 -0000 1.4 --- UTFUtilities.java 2 Sep 2005 15:59:13 -0000 1.5 *************** *** 111,115 **** /** * Add the BOM to the Editorfile ! * @param document * @author Ralf Bokelberg */ --- 111,115 ---- /** * Add the BOM to the Editorfile ! * @param file * @author Ralf Bokelberg */ Index: ASKeywords.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/ASKeywords.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ASKeywords.java 23 Aug 2005 23:05:49 -0000 1.4 --- ASKeywords.java 2 Sep 2005 15:59:13 -0000 1.5 *************** *** 34,48 **** /** * @author Peter Schreiber ! * */ ! public class ASKeywords { ! ! private List keywords; private static ASKeywords asKeywords; ! public ASKeywords() { ! loadKeywords(); } --- 34,48 ---- /** + * ActionScript 2 keyword list * @author Peter Schreiber ! * @author Martin Wood */ ! public class ASKeywords extends WordList{ private static ASKeywords asKeywords; ! private String keywordsFile = "keywords.txt"; ! public ASKeywords() { ! loadWordList(keywordsFile); } *************** *** 53,94 **** return asKeywords; } - - private void loadKeywords() { - keywords = new ArrayList(); - BufferedReader reader; - InputStream is = getClass().getResourceAsStream("keywords.txt"); - if (is != null) { - reader = new BufferedReader(new InputStreamReader(is)); - String keyword; - try { - while ((keyword = reader.readLine()) != null) { - keywords.add(keyword); - } - } catch (IOException e) { - e.printStackTrace(); - } - } else { - System.out.println("Keywords : FileNotFound"); - } - } - - /** - * getList of keywords - * - * @return - */ - public String[] getKeywords() { - String[] keywordArray = new String[keywords.size()]; - keywords.toArray(keywordArray); - return keywordArray; - } - - /** - * get amout of keywords - * - * @return - */ - public int keywordsCount() { - return keywords.size(); - } } \ No newline at end of file --- 53,55 ---- Index: ASTypes.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/ASTypes.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ASTypes.java 8 Jun 2005 16:49:48 -0000 1.3 --- ASTypes.java 2 Sep 2005 15:59:13 -0000 1.4 *************** *** 27,47 **** package org.asdt.core.util; - import java.io.BufferedReader; - import java.io.IOException; - import java.io.InputStream; - import java.io.InputStreamReader; - import java.util.ArrayList; - import java.util.List; /** * @author Peter Schreiber ! * */ ! public class ASTypes { ! private List types; private static ASTypes asTypes; ! public ASTypes() { ! loadTypes(); } --- 27,44 ---- package org.asdt.core.util; /** + * ActionScript 2 built in types. Only 'Void' is currently used as AS2 doesnt have + * named primitive types like int, float etc.. * @author Peter Schreiber ! * @author Martin Wood */ ! public class ASTypes extends WordList{ ! private static ASTypes asTypes; ! private String typeFile = "types.txt"; ! public ASTypes() { ! loadWordList(typeFile); } *************** *** 55,98 **** return asTypes; } - - private void loadTypes() { - types = new ArrayList(); - BufferedReader reader; - InputStream is = getClass().getResourceAsStream("types.txt"); - if (is != null) { - reader = new BufferedReader(new InputStreamReader(is)); - String type; - try { - while ((type = reader.readLine()) != null) { - types.add(type); - } - } catch (IOException e) { - e.printStackTrace(); - } - } else { - System.out.println("FileNotFound"); - } - } - - /** - * getList of keywords - * - * @return - */ - public String[] getTypes() { - String[] keywordArray = new String[types.size()]; - types.toArray(keywordArray); - return keywordArray; - } - - /** - * get amout of keywords - * - * @return - */ - public int typesCount() { - return types.size(); - - } - } \ No newline at end of file --- 52,54 ---- Index: ASInternals.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/ASInternals.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASInternals.java 23 Aug 2005 23:05:49 -0000 1.1 --- ASInternals.java 2 Sep 2005 15:59:13 -0000 1.2 *************** *** 26,48 **** package org.asdt.core.util; - import java.io.BufferedReader; - import java.io.IOException; - import java.io.InputStream; - import java.io.InputStreamReader; - import java.util.ArrayList; - import java.util.List; /** * @author Peter Schreiber ! * */ ! public class ASInternals { ! ! private List internals; private static ASInternals asInternals; ! public ASInternals() { ! loadInternals(); } --- 26,42 ---- package org.asdt.core.util; /** + * Flash player built in objects and functions, e.g. _root, fscommand * @author Peter Schreiber ! * @author Martin Wood */ ! public class ASInternals extends WordList{ private static ASInternals asInternals; ! private String internalsFile = "internals.txt"; ! public ASInternals() { ! loadWordList(internalsFile); } *************** *** 53,94 **** return asInternals; } - - private void loadInternals() { - internals = new ArrayList(); - BufferedReader reader; - InputStream is = getClass().getResourceAsStream("internals.txt"); - if (is != null) { - reader = new BufferedReader(new InputStreamReader(is)); - String internal; - try { - while ((internal = reader.readLine()) != null) { - internals.add(internal); - } - } catch (IOException e) { - e.printStackTrace(); - } - } else { - System.out.println("Internals : FileNotFound"); - } - } - - /** - * getList of internals - * - * @return - */ - public String[] getInternals() { - String[] internalsArray = new String[internals.size()]; - internals.toArray(internalsArray); - return internalsArray; - } - - /** - * get amout of internals - * - * @return - */ - public int internalsCount() { - return internals.size(); - } } \ No newline at end of file --- 47,49 ---- Index: ExpressionResolver.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/ExpressionResolver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ExpressionResolver.java 8 Jun 2005 16:49:48 -0000 1.3 --- ExpressionResolver.java 2 Sep 2005 15:59:13 -0000 1.4 *************** *** 71,75 **** * @param classpath * @param offset ! * @return */ public ASClass getTypeForExpression(String expression, ASClass object, IProject project, List classpath, int offset) --- 71,75 ---- * @param classpath * @param offset ! * @return the actionscript class resulting from the expression */ public ASClass getTypeForExpression(String expression, ASClass object, IProject project, List classpath, int offset) *************** *** 159,163 **** * [] will be also ignored * @param expression ! * @return */ private List getExpressionParts(String expression) --- 159,163 ---- * [] will be also ignored * @param expression ! * @return list of parts that make up the expression */ private List getExpressionParts(String expression) --- NEW FILE: WordList.java --- /******************************************************************************* * ActionScript Development Toolkit * Copyright (C) 2005 ASDT Team * * http://www.asdt.org http://sourceforge.net/projects/aseclipseplugin/ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) any later * version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307, USA. * ******************************************************************************/ package org.asdt.core.util; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; /** * Allows the loading of a list of words from a file * Each line of the file will be treated as one word. * * @author Martin Wood */ public class WordList implements IWordList { private List wordList; /* (non-Javadoc) * @see org.asdt.core.util.IWordList#getWordList() */ public String[] getWordList() { String[] wordArray = new String[wordList.size()]; wordList.toArray(wordArray); return wordArray; } /* (non-Javadoc) * @see org.asdt.core.util.IWordList#loadWordList(java.lang.String) */ public void loadWordList(String wordListFile) { // create the list anyway, even if wordListFile may be empty // so further calls to getWordList dont generate null pointer exceptions wordList = new ArrayList(); if(wordListFile == null) { // TODO : is it worth throwing an exception here? // or should just specify in the comments for this class // how to use it :) // e.g. throw new FileNotSpecifiedException(); System.err.println("No file specified for word list"); return; } BufferedReader reader; InputStream is = getClass().getResourceAsStream(wordListFile); if (is != null) { reader = new BufferedReader(new InputStreamReader(is)); String word; try { while ((word = reader.readLine()) != null) { wordList.add(word); } } catch (IOException e) { e.printStackTrace(); } } else { /** * TODO : should we use a logging system? * or just use System.out ? */ System.err.println(wordListFile + " : FileNotFound"); } } /* (non-Javadoc) * @see org.asdt.core.util.IWordList#getWordCount() */ public int getWordCount() { return wordList.size(); } } Index: StreamUtilities.java =================================================================== RCS file: /cvsroot/aseclipseplugin/org.asdt.core/src/org/asdt/core/util/StreamUtilities.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StreamUtilities.java 15 Jun 2005 14:08:19 -0000 1.1 --- StreamUtilities.java 2 Sep 2005 15:59:13 -0000 1.2 *************** *** 44,48 **** * * @param stream ! * @return * @throws IOException */ --- 44,48 ---- * * @param stream ! * @return string representation of the input stream * @throws IOException */ |