Skip to content

Commit

Permalink
Fixing some compiler warnings and bumping dependency versions
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbylight committed Oct 3, 2022
1 parent 29e2342 commit ff5e817
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 34 deletions.
4 changes: 2 additions & 2 deletions RSTALanguageSupport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ assert JavaVersion.current().isJava8Compatible()
archivesBaseName = 'languagesupport'

dependencies {
api 'com.fifesoft:rsyntaxtextarea:3.2.1-SNAPSHOT'
api 'com.fifesoft:autocomplete:3.2.0'
api 'com.fifesoft:rsyntaxtextarea:3.3.0'
api 'com.fifesoft:autocomplete:3.3.0'
implementation 'org.mozilla:rhino:1.7.14'
testImplementation 'junit:junit:4.13.2'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,9 @@ public void warning(String message, String sourceName, int line,
});
env.setRecoverFromErrors(true);
Parser parser = new Parser(env);
StringReader r = new StringReader(text);
ParseText pt = new ParseText();
try {
AstRoot root = parser.parse(r, null, 0);
AstRoot root = parser.parse(text, null, 0);
ParseTextVisitor visitor = new ParseTextVisitor(text);
root.visitAll(visitor);
pt.isNew = visitor.isNew();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import javax.swing.text.Element;

import org.fife.io.DocumentReader;
import org.fife.rsta.ac.js.ast.VariableResolver;
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
Expand Down Expand Up @@ -243,18 +242,15 @@ public ParseResult parse(RSyntaxDocument doc, String style) {
int lineCount = root.getElementCount();
result.setParsedLines(0, lineCount - 1);

DocumentReader r = new DocumentReader(doc);
ErrorCollector errorHandler = new ErrorCollector();
CompilerEnvirons env = createCompilerEnvironment(errorHandler, langSupport);
long start = System.currentTimeMillis();
try {
Parser parser = new Parser(env);
astRoot = parser.parse(r, null, 0);
String text = doc.getText(0, doc.getLength());
astRoot = parser.parse(text, null, 0);
long time = System.currentTimeMillis() - start;
result.setParseTime(time);
} catch (IOException ioe) { // Never happens
result.setError(ioe);
ioe.printStackTrace();
} catch (RhinoException re) {
// Shouldn't happen since we're passing an ErrorCollector in
int line = re.lineNumber();
Expand All @@ -269,8 +265,6 @@ public ParseResult parse(RSyntaxDocument doc, String style) {
result.setError(e); // catch all
}

r.close();

// Get any parser errors.
switch (langSupport.getErrorParser()) {
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@ public void parseScript(String scriptText, TypeDeclarationOptions options)
{
CompilerEnvirons env = JavaScriptParser.createCompilerEnvironment(new JavaScriptParser.JSErrorReporter(), provider.getLanguageSupport());
Parser parser = new Parser(env);
StringReader r = new StringReader(scriptText);
try {
AstRoot root = parser.parse(r, null, 0);
CodeBlock block = provider.iterateAstRoot(root, preProcessingCompletions, "", Integer.MAX_VALUE, options);
provider.recursivelyAddLocalVars(preProcessingCompletions, block, 0, null, false, true);
}
catch(IOException io) {
//ignore this
}
AstRoot root = parser.parse(scriptText, null, 0);
CodeBlock block = provider.iterateAstRoot(root, preProcessingCompletions, "", Integer.MAX_VALUE, options);
provider.recursivelyAddLocalVars(preProcessingCompletions, block, 0, null, false, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.fife.rsta.ac.js.resolver;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -65,16 +63,15 @@ public JavaScriptCompletionResolver(SourceCompletionProvider provider) {
* @param text to compile and resolve
*/
@Override
public JavaScriptType compileText(String text) throws IOException {
public JavaScriptType compileText(String text) {
CompilerEnvirons env = JavaScriptParser.createCompilerEnvironment(new JavaScriptParser.JSErrorReporter(), provider.getLanguageSupport());

String parseText = JavaScriptHelper.removeLastDotFromText(text);

int charIndex = JavaScriptHelper.findIndexOfFirstOpeningBracket(parseText);
env.setRecoverFromErrors(true);
Parser parser = new Parser(env);
StringReader r = new StringReader(parseText);
AstRoot root = parser.parse(r, null, 0);
AstRoot root = parser.parse(parseText, null, 0);
CompilerNodeVisitor visitor = new CompilerNodeVisitor(charIndex == 0);
root.visitAll(visitor);
return lastJavaScriptType;
Expand All @@ -86,17 +83,15 @@ public JavaScriptType compileText(String text) throws IOException {
* @return TypeDeclaration for node or null if not found.
*/
@Override
public TypeDeclaration resolveParamNode(String text) throws IOException {
public TypeDeclaration resolveParamNode(String text) {

if(text != null) {
CompilerEnvirons env = JavaScriptParser.createCompilerEnvironment(new JavaScriptParser.JSErrorReporter(), provider.getLanguageSupport());


int charIndex = JavaScriptHelper.findIndexOfFirstOpeningBracket(text);
env.setRecoverFromErrors(true);
Parser parser = new Parser(env);
StringReader r = new StringReader(text);
AstRoot root = parser.parse(r, null, 0);
AstRoot root = parser.parse(text, null, 0);
CompilerNodeVisitor visitor = new CompilerNodeVisitor(charIndex == 0);
root.visitAll(visitor);
}
Expand Down Expand Up @@ -554,7 +549,6 @@ public boolean visit(AstNode node) {
return true;
}


public ArrayList<AstNode> getAllNodes() {
return all;
}
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//plugins {
// id 'com.github.spotbugs' version '4.7.1'
// id 'com.github.spotbugs' version '5.0.12'
//}

group = 'com.fifesoft'
Expand All @@ -16,7 +16,7 @@ allprojects {
}

wrapper {
gradleVersion = '7.4.1'
gradleVersion = '7.5.1'
}

tasks.withType(Javadoc) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit ff5e817

Please sign in to comment.