Skip to content

Commit

Permalink
Merge pull request #384 from TiVo/v15build
Browse files Browse the repository at this point in the history
Version 14.1.5 fixes, on the way to v15.
  • Loading branch information
EBatTiVo committed Jan 18, 2016
2 parents 04b34e9 + c431320 commit d528825
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 50 deletions.
75 changes: 42 additions & 33 deletions common.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,40 +94,8 @@
<loadfile property="idea.sdk.version" srcFile="${idea.ultimate.build}/build.txt"/>
<echo level="debug">Using installed IDEA version of ${idea.sdk.version}</echo>

<!-- Lookup table for properties files. Add new versions here. -->
<condition property="plugin.properties.file" value="idea_v14.1.properties">
<matches pattern="-141." string="${idea.sdk.version}"/>
</condition>
<condition property="plugin.properties.file" value="idea_v14.properties">
<matches pattern="-139." string="${idea.sdk.version}"/>
</condition>
<condition property="plugin.properties.file" value="idea_v13.properties">
<matches pattern="-135." string="${idea.sdk.version}"/>
</condition>
<echo level="debug">Idea property file is ${plugin.properties.file}</echo>

<fail unless="plugin.properties.file">
Unable to load properties.

Could not locate properties for IDEA SDK version ${idea.sdk.version}.

If you are compiling a a newly released version of IDEA, perhaps the version
number(s) must be added to the lookup table in common.xml.
</fail>

<!-- The properties are mostly used as filters, but they can be useful for other things. -->
<property file="${plugin.properties.file}"/>

<!-- defines a path for code specific to an intellij version.
intellij SDK has non-backward compatible changes which requires
some duplicated Java files.
This property defaults to "src/common" if missing, this way you can
choose not to include any version specific code -->
<property name="version.specific.code.location" location="src/common" />

<!-- Pull apart the build version into component pieces -->

<!-- Also look up the property string because we've got the info already here. -->
<script language="javascript">
<![CDATA[
var buildId = project.getProperty("idea.sdk.version");
Expand All @@ -144,6 +112,25 @@
project.setNewProperty("idea.sdk.codeline", codeLine);
project.setNewProperty("idea.sdk.build.number", buildNumber);
project.setNewProperty("idea.sdk.patch.number", patchNumber);
// Lookup table for properties files. Add new versions here.
var propertiesFile = "";
switch(parseInt(codeLine, 10)) {
case 143: propertiesFile = "idea_v15.properties";
case 141:
if (parseInt(buildNumber, 10) <= 2734) {
propertiesFile = "idea_v14.1.properties";
} else {
propertiesFile = "idea_v14.1.5.properties";
}
break;
case 139: propertiesFile = "idea_v14.properties"; break;
case 137: propertiesFile = "idea_v13.properties"; break;
case 135: propertiesFile = "idea_v13.properties"; break;
}
if (0 != propertiesFile.length) {
project.setNewProperty("plugin.properties.file", propertiesFile);
}
]]>
</script>

Expand All @@ -157,6 +144,28 @@
</echo>
</target>

<echo level="debug">Idea property file is ${plugin.properties.file}</echo>

<fail unless="plugin.properties.file">
Unable to load properties.

Could not locate properties for IDEA SDK version ${idea.sdk.version}.

If you are compiling a a newly released version of IDEA, perhaps the version
number(s) must be added to the lookup table in common.xml.
</fail>

<!-- The properties are mostly used as filters, but they can be useful for other things. -->
<property file="${plugin.properties.file}"/>

<!-- defines a path for code specific to an intellij version.
IntelliJ SDK has non-backward compatible changes which require
some duplicated Java files.
This property defaults to "src/common" if it wasn't specified in
the ${plugin.properties.file}, this way you can
choose not to include any version specific code -->
<property name="version.specific.code.location" location="src/common" />

<property name="plugin.autogen.warning">

Expand Down
45 changes: 45 additions & 0 deletions idea_v14.1.5.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright 2000-2013 JetBrains s.r.o.
# Copyright 2014-2016 AS3Boyan
# Copyright 2014-2014 Elias Ku
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# Properties for building against IDEA version 14.
#

# Target version of IDEA that we typically build for.
# This is appended to the name of the intellij-haxe-XXX jar file.
idea.version=14.1.5

# Human-readable versions of IDEA that this build is compatible with.
plugin.compatibility.description=IDEA 14.1.5 and 14.1.6

# ###################################################
# IDEA build IDs that are compatible with this plugin.
# ###################################################
#
# IDEA builds prior to this one will not install this plugin.
#
plugin.installable.since=141.2735
#
# IDEA builds after this one will not install this plugin.
#
plugin.installable.until=141.9999

# ###################################################
# Where to find Idea14-specific code.
# ###################################################
version.specific.code.location=src/14.1
4 changes: 2 additions & 2 deletions idea_v14.1.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
idea.version=14.1

# Human-readable versions of IDEA that this build is compatible with.
plugin.compatibility.description=IDEA 14.1.4
plugin.compatibility.description=IDEA 14.1 - 14.1.4

# ###################################################
# IDEA build IDs that are compatible with this plugin.
Expand All @@ -19,7 +19,7 @@ plugin.installable.since=141.0
#
# IDEA builds after this one will not install this plugin.
#
plugin.installable.until=
plugin.installable.until=141.2734

# ###################################################
# Where to find Idea14-specific code.
Expand Down
28 changes: 28 additions & 0 deletions idea_v15.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Properties for building against IDEA version 15.
#

# Target version of IDEA that we typically build for.
# This is appended to the name of the intellij-haxe-XXX jar file.
idea.version=14.1

# Human-readable versions of IDEA that this build is compatible with.
plugin.compatibility.description=IDEA 15

# ###################################################
# IDEA build IDs that are compatible with this plugin.
# ###################################################
#
# IDEA builds prior to this one will not install this plugin.
#
plugin.installable.since=143.0
#
# IDEA builds after this one will not install this plugin.
#
plugin.installable.until=

# ###################################################
# Where to find Idea14-specific code.
# ###################################################
# Use the 14.1 source tree, for the moment.
version.specific.code.location=src/14.1
64 changes: 64 additions & 0 deletions src/common/com/intellij/plugins/haxe/build/ApiInvoker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2014-2016 AS3Boyan
* Copyright 2014-2014 Elias Ku
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.plugins.haxe.build;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
* Created by ebishton on 1/16/16.
*/
public class ApiInvoker<R> {

private Object myInstance;
private Method myMethodToInvoke;
private String myDebugName;

public ApiInvoker(Object o, String methodName, Class<?>... argTypes) {
Class klass;
myDebugName = "";
try {
if (o instanceof Class) {
// We're looking for a static method.
myInstance = null;
klass = (Class) o;
} else {
// We have an instance method.
myInstance = o;
klass = o.getClass();
}
myDebugName = (null == klass ? "<unknown>" : klass.getName())
+ "." + methodName;
// Don't stop of null klass... Just let the exception be thrown
// naturally.
myMethodToInvoke = klass.getDeclaredMethod(methodName, argTypes);
} catch (NoSuchMethodException e) {
throw new UnsupportedApiException("Didn't find " + myDebugName + ";", e);
}
}

public R invoke(Object... args) {
try {
return (R) myMethodToInvoke.invoke(myInstance, args);
} catch (IllegalAccessException e) {
throw new UnsupportedApiException("Error invoking " + myDebugName + ";", e);
} catch (InvocationTargetException e) {
throw new UnsupportedApiException("Error invoking " + myDebugName + ";", e.getCause());
}
}
}
42 changes: 28 additions & 14 deletions src/common/com/intellij/plugins/haxe/build/IdeaTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,39 @@
public class IdeaTarget {

// Loads the string at compile-time from a templatized class.
public static final String SDK_VERSION_STRING = IdeaSDKIdentifier.BUILD_IDENTIFIER;
public static final String SDK_TYPE = IdeaSDKIdentifier.BUILD_TYPE;
public static final int SDK_CODELINE = IdeaSDKIdentifier.BUILD_CODELINE;
public static final int SDK_BUILD_NUMBER = IdeaSDKIdentifier.BUILD_NUMBER;
public static final int SDK_BUILD_PATCH = IdeaSDKIdentifier.BUILD_PATCH;
private static final String SDK_VERSION_STRING = IdeaSDKIdentifier.BUILD_IDENTIFIER;
private static final String SDK_TYPE = IdeaSDKIdentifier.BUILD_TYPE;
private static final int SDK_CODELINE = IdeaSDKIdentifier.BUILD_CODELINE;
private static final int SDK_BUILD_NUMBER = IdeaSDKIdentifier.BUILD_NUMBER;
private static final int SDK_BUILD_PATCH = IdeaSDKIdentifier.BUILD_PATCH;

// Add new constants for specific requirements here.
// All of these should be boolean constants. They will
// be used by the compiler to eliminate dead code, and to
// All of these should be boolean constants resolvable at compile time.
// They will be used by the compiler to eliminate dead code, and to
// allow non-compatible code to exist in the same file.
//
// Always use the most generic of the compatibility strings possible.
// Specific code inflection points (breaking changes in a codeline)
// that require special handling should be placed here as well, perhaps
// even documenting the change(s) that necessitated the check.
//
// When writing code using these constants, always use the most generic
// of the compatibility strings possible.
//

public static final boolean IS_VERSION_15_1_COMPATIBLE = (SDK_CODELINE >= 145);
public static final boolean IS_VERSION_15_0_COMPATIBLE = (SDK_CODELINE >= 143);
public static final boolean IS_VERSION_15_COMPATIBLE = (IS_VERSION_15_0_COMPATIBLE || IS_VERSION_15_1_COMPATIBLE);

public static final boolean IS_VERSION_13_COMPATIBLE = (SDK_CODELINE == 133 || SDK_CODELINE == 135);
public static final boolean IS_VERSION_13_0_COMPATIBLE = (SDK_CODELINE == 133);
public static final boolean IS_VERSION_13_1_COMPATIBLE = (SDK_CODELINE == 135);
public static final boolean IS_VERSION_14_1_5_COMPATIBLE = (SDK_CODELINE > 141 ||
( SDK_CODELINE == 141 && SDK_BUILD_NUMBER >= 2735));
public static final boolean IS_VERSION_14_1_6_COMPATIBLE = (SDK_CODELINE > 141 ||
( SDK_CODELINE == 141 && SDK_BUILD_NUMBER >= 3056));

public static final boolean IS_VERSION_14_COMPATIBLE = (SDK_CODELINE == 139 || SDK_CODELINE == 141);
public static final boolean IS_VERSION_14_0_COMPATIBLE = (SDK_CODELINE == 139);
public static final boolean IS_VERSION_14_1_COMPATIBLE = (SDK_CODELINE == 141);
public static final boolean IS_VERSION_14_1_COMPATIBLE = (SDK_CODELINE >= 141);
public static final boolean IS_VERSION_14_0_COMPATIBLE = (SDK_CODELINE >= 139);
public static final boolean IS_VERSION_14_COMPATIBLE = (IS_VERSION_14_0_COMPATIBLE || IS_VERSION_14_1_COMPATIBLE);

public static final boolean IS_VERSION_13_1_COMPATIBLE = (SDK_CODELINE >= 137);
public static final boolean IS_VERSION_13_0_COMPATIBLE = (SDK_CODELINE >= 135);
public static final boolean IS_VERSION_13_COMPATIBLE = (IS_VERSION_13_0_COMPATIBLE || IS_VERSION_13_1_COMPATIBLE);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.plugins.haxe.build;

/**
* Created by ebishton on 1/17/16.
*/
class UnsupportedApiException extends UnsupportedOperationException {
public UnsupportedApiException() {
super();
}

public UnsupportedApiException(String reason) {
super(reason);
}

public UnsupportedApiException(String reason, Throwable cause) {
super(reason + ":" + cause.getMessage(), cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import com.intellij.formatting.FormattingDocumentModel;
import com.intellij.formatting.FormattingModel;
import com.intellij.formatting.FormattingModelProvider;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.plugins.haxe.build.ApiInvoker;
import com.intellij.plugins.haxe.build.IdeaTarget;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import org.jetbrains.annotations.NotNull;
Expand All @@ -32,10 +35,18 @@
public class HaxeFormattingModel implements FormattingModel {
private final FormattingModel myModel;

// Need an abstract method call because of an API change.
private final ApiInvoker<TextRange> shiftIndentInsideRangeInvoker;

public HaxeFormattingModel(final PsiFile file,
CodeStyleSettings settings,
final Block rootBlock) {
myModel = FormattingModelProvider.createFormattingModelForPsiFile(file, rootBlock, settings);

shiftIndentInsideRangeInvoker = new ApiInvoker<TextRange>(myModel, "shiftIndentInsideRange",
IdeaTarget.IS_VERSION_14_1_5_COMPATIBLE
? new Class<?>[] {ASTNode.class, TextRange.class, int.class }
: new Class<?>[] {TextRange.class, int.class} );
}

@NotNull
Expand All @@ -52,8 +63,14 @@ public TextRange replaceWhiteSpace(TextRange textRange, String whiteSpace) {
return myModel.replaceWhiteSpace(textRange, whiteSpace);
}

// @Override
public TextRange shiftIndentInsideRange(ASTNode node, TextRange range, int i) {
return shiftIndentInsideRangeInvoker.invoke(node, range, i);
}

// @Override
public TextRange shiftIndentInsideRange(TextRange range, int indent) {
return myModel.shiftIndentInsideRange(range, indent);
return shiftIndentInsideRangeInvoker.invoke(range, indent);
}

public void commitChanges() {
Expand Down

0 comments on commit d528825

Please sign in to comment.